spec/spec/rails/example/controller_spec_spec.rb in dchelimsky-rspec-rails-1.1.11.7 vs spec/spec/rails/example/controller_spec_spec.rb in dchelimsky-rspec-rails-1.1.12

- old
+ new

@@ -4,12 +4,10 @@ ['integration', 'isolation'].each do |mode| describe "A controller example running in #{mode} mode", :type => :controller do controller_name :controller_spec integrate_views if mode == 'integration' - specify "this example should be pending, not an error" - it "should provide controller.session as session" do get 'action_with_template' session.should equal(controller.session) end @@ -158,9 +156,60 @@ else cookies['cookie_key'].should == ["cookie value"] end end + end + + describe "with an error that is not rescued in the controller" do + context "without rails' error handling" do + it "raises the error" do + lambda do + get 'other_error_action' + end.should raise_error(ControllerSpecController::UnRescuedError) + end + end + context "with rails' error handling" do + it "does not raise the error" do + controller.use_rails_error_handling! + lambda do + get 'other_error_action' + end.should_not raise_error + end + end + end + + if Rails::VERSION::MAJOR >= 2 + describe "with an error that is rescued in the controller" do + context "without rails' error handling" do + it "does not raise error" do + lambda do + get 'rescued_error_action' + end.should_not raise_error + end + + it "executes rescue_from" do + get 'rescued_error_action' + response.body.should == 'Rescued!' + end + end + + context "with rails' error handling" do + before(:each) do + controller.use_rails_error_handling! + end + it "does not raise error" do + lambda do + get 'rescued_error_action' + end.should_not raise_error + end + + it "executes rescue_from" do + get 'rescued_error_action' + response.body.should == 'Rescued!' + end + end + end end it "should support custom routes" do route_for(:controller => "custom_route_spec", :action => "custom_route").should == "/custom_route" end