[rspec-users] undefined method: controller_name

Alvin Schur a.schur at nucleus.com
Wed Dec 12 10:50:52 EST 2007


With rspec 1.0.8 I have a spec in the directory: 
spec/units/controllers/application_controller_spec.rb

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

class DummyController < ApplicationController
  def index
    raise "Prevent index from rendering"
  end
end

describe ApplicationController, "Handling errors in production", 
:behaviour_type => :controller do
  controller_name :dummy
 
  before(:each) do
    # set up request and response
    lambda { get :index }.should raise_error
  end
 
  it "should display 'file not found' when a routing error occurs" do
    
controller.rescue_action_in_public(ActionController::RoutingError.new("this 
page does not exist"))
    response.should render_template("error/404") 
  end
end

and it works.


After updating to rspec revision 3136 and running script/generate rspec, 
I get the following error:

kwigger:~/workspace/eTriever-spec-tmp alvin$ script/spec  --backtrace 
spec/unit/controllers/application_controller_spec2.rb
./spec/unit/controllers/application_controller_spec2.rb:10: undefined 
method `controller_name' for 
Spec::Rails::Example::RailsExampleGroup::Subclass_1:Class (NoMethodError)
        from 
/Users/alvin/workspace/eTriever-spec-tmp/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:39:in 
`module_eval'
        from 
/Users/alvin/workspace/eTriever-spec-tmp/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:39:in 
`describe'
        from 
/Users/alvin/workspace/eTriever-spec-tmp/vendor/plugins/rspec/lib/spec/extensions/class.rb:14:in 
`instance_eval'
        from 
/Users/alvin/workspace/eTriever-spec-tmp/vendor/plugins/rspec/lib/spec/extensions/class.rb:14:in 
`subclass'
        from 
/Users/alvin/workspace/eTriever-spec-tmp/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:37:in 
`describe'
        from 
/Users/alvin/workspace/eTriever-spec-tmp/vendor/plugins/rspec/lib/spec/example/example_group_factory.rb:43:in 
`create_example_group'
        from 
/Users/alvin/workspace/eTriever-spec-tmp/vendor/plugins/rspec/lib/spec/extensions/main.rb:27:in 
`describe'
        from ./spec/unit/controllers/application_controller_spec2.rb:9
        from 
/Users/alvin/workspace/eTriever-spec-tmp/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:14:in 
`load'
        from 
/Users/alvin/workspace/eTriever-spec-tmp/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:14:in 
`load_files'
        from 
/Users/alvin/workspace/eTriever-spec-tmp/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:13:in 
`each'
        from 
/Users/alvin/workspace/eTriever-spec-tmp/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:13:in 
`load_files'
        from 
/Users/alvin/workspace/eTriever-spec-tmp/vendor/plugins/rspec/lib/spec/runner/options.rb:83:in 
`run_examples'
        from 
/Users/alvin/workspace/eTriever-spec-tmp/vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in 
`run'
        from script/spec:4



Is there a better way to write this spec in 3136?

Thanks,
Alvin.



More information about the rspec-users mailing list