Updated to latest rspec
[gitorious:georgyos-clone.git] / vendor / plugins / rspec-rails / spec / rails / extensions / action_controller_rescue_action_spec.rb
1 require File.dirname(__FILE__) + '/../../spec_helper'
2
3 module ActionController
4   describe "Rescue", "#rescue_action in default mode" do
5     before(:each) do
6       @fixture = Object.new
7       @fixture.extend ActionController::Rescue
8       class << @fixture
9         public :rescue_action
10       end
11     end
12
13     it "should raise the passed in exception so examples fail fast" do
14       proc {@fixture.rescue_action(RuntimeError.new("Foobar"))}.should raise_error(RuntimeError, "Foobar")
15     end
16   end
17
18   class RescueOverriddenController < ActionController::Base
19     def rescue_action(error)
20       "successfully overridden"
21     end
22   end
23
24   describe "Rescue", "#rescue_action, when overridden" do
25     before(:each) do
26       @fixture = RescueOverriddenController.new
27     end
28
29     it "should do whatever the overridden method does" do
30       @fixture.rescue_action(RuntimeError.new("Foobar")).should == "successfully overridden"
31     end
32   end
33
34   class SearchController < ActionController::Base
35   end
36
37   describe "Rescue", "#rescue_action when told to use rails error handling" do
38     before(:each) do
39       @controller = SearchController.new
40       @controller.use_rails_error_handling!
41       class << @controller
42         public :rescue_action
43       end
44     end
45
46     it "should use Rails exception handling" do
47       exception = RuntimeError.new("The Error")
48       exception.stub!(:backtrace).and_return(caller)
49       @controller.should_receive(:rescue_action_locally).with(exception)
50
51       @controller.rescue_action(exception)
52     end
53   end
54 end