changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec_on_rails/spec/rails/extensions/action_controller_rescue_action_spec.rb

changeset 16: 01fd3f10ae84
author: moriq@moriq.com
date: Mon Mar 10 10:13:18 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec_on_rails
1require File.dirname(__FILE__) + '/../../spec_helper'
2
3module 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
54end