Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6071075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:00:23+00:00 2026-05-23T10:00:23+00:00

What’s the problem I wanna test a before filter that render errors in XML

  • 0

What’s the problem

I wanna test a before filter that render errors in XML and JSON if failing.
When testing it from a classic controller it works fine, when testing from
the ApplicationController directly it fails.

A light version of the code

specs/controller/admin_controller_spec.rb

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe AdminController do
  controller(AdminController) do
    def index
      render :text => 'ok'
    end
  end

  it "should include errors properly formated" do
    get :index, :format => 'xml'
    response.body.should == "block"
  end
end

app/controller/admin_controller.rb

class AdminController < ApplicationController
  before_filter :block_something

  protected

    def block_something
      respond_to do |wants|
        wants.xml {
          render :text => 'block' 
        }
      end
    end
end

Error from tests

Failure/Error: get :index, :format => format
  TypeError:
    can't convert nil into String

Update, with backtrace : thanks Ryan Bigg for the recommendation

It gives different controller and filter names than the example above. The app use admin_controller.rb and block_suspended filter.

 # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:61:in `<<'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:61:in `build_path'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:54:in `find_templates'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:20:in `find_all'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:39:in `cached'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/template/resolver.rb:19:in `find_all'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:21:in `find_all'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:20:in `each'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:20:in `find_all'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:21:in `find_all'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:20:in `each'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:20:in `find_all'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/paths.rb:28:in `exists?'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_view/lookup_context.rb:90:in `template_exists?'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/view_paths.rb:11:in `__send__'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/view_paths.rb:11:in `template_exists?'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/layouts.rb:272:in `_layout'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/layouts.rb:345:in `_default_layout'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/layouts.rb:323:in `_layout_for_option'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/layouts.rb:290:in `_normalize_options'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/rendering.rb:41:in `_normalize_options'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/compatibility.rb:50:in `_normalize_options'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/rendering.rb:101:in `render_to_string'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/rendering.rb:93:in `render'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/rendering.rb:17:in `render'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:40:in `render_without_wicked_pdf'
     # /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/core_ext/benchmark.rb:5:in `ms'
     # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
     # /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/core_ext/benchmark.rb:5:in `ms'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:40:in `render_without_wicked_pdf'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
     # /Library/Ruby/Gems/1.8/gems/activerecord-3.0.4/lib/active_record/railties/controller_runtime.rb:15:in `cleanup_view_runtime'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:39:in `render_without_wicked_pdf'
     # ./app/controllers/admin_controller.rb:36:in `block_suspended'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/mime_responds.rb:192:in `call'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/mime_responds.rb:192:in `respond_to'
     # ./app/controllers/admin_controller.rb:33:in `block_suspended'
     # /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:466:in `_run__1727617933__process_action__199225275__callbacks'
     # /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:409:in `send'
     # /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
     # /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:93:in `send'
     # /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:93:in `run_callbacks'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/callbacks.rb:17:in `process_action'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
     # /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/notifications.rb:52:in `instrument'
     # /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
     # /Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/notifications.rb:52:in `instrument'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/rescue.rb:17:in `process_action'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/base.rb:119:in `process'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/abstract_controller/rendering.rb:41:in `process'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/metal/testing.rb:12:in `process_with_new_base_test'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/test_case.rb:412:in `process'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/test_case.rb:47:in `process'
     # /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_controller/test_case.rb:350:in `get'
     # ./spec/controllers/admin_controller_spec.rb:272
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:29:in `instance_eval'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:29:in `run_in'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:64:in `run_all'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:64:in `each'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:64:in `run_all'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/hooks.rb:110:in `run_hook'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:191:in `eval_before_eachs'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:191:in `each'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:191:in `eval_before_eachs'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:144:in `run_before_each'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:48:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:106:in `with_around_hooks'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:46:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:99:in `with_pending_capture'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:98:in `catch'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:98:in `with_pending_capture'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example.rb:45:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:262:in `run_examples'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:258:in `map'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:258:in `run_examples'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:232:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `map'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `map'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `map'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `map'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/example_group.rb:233:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:27:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:27:in `map'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:27:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/reporter.rb:12:in `report'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:24:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:55:in `run_in_process'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:46:in `run'
     # /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:10:in `autorun'
     # /usr/bin/rspec:19

Any thought on why this appends? If not the right way to test it, how to test such behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:00:24+00:00Added an answer on May 23, 2026 at 10:00 am

    I’ve now upgraded to ruby 1.9.2 and all specs passes without any changes required.

    Looks like a limitation of Ruby 1.8.7 that would need extra workarounds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have some data like this: 1 2 3 4 5 9 2 6
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.