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.
On Dec 12, 2007 9:50 AM, Alvin Schur <a.schur at nucleus.com> wrote:> 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 doTry :type instead and see if that works.> 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. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Dec 12, 2007, at 10:56 AM, David Chelimsky wrote:> On Dec 12, 2007 9:50 AM, Alvin Schur <a.schur at nucleus.com> wrote: >> 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 > > Try :type instead and see if that works.Yep. I had a bunch of regressions with :behaviour_type => ..., which started to fail a few weeks ago. Changing it to :type seemed to fix it up. Scott
David Chelimsky wrote:> On Dec 12, 2007 9:50 AM, Alvin Schur <a.schur at nucleus.com <http://rubyforge.org/mailman/listinfo/rspec-users>> wrote: > >/ 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 />> Try :type instead and see if that works.This did work, thanks.