Sha256: 4c2869d5548956d78afa30095c7539ef8770dc84e1582430ae598fc7f1d9e8c5

Contents?: true

Size: 1.58 KB

Versions: 12

Compression:

Stored size: 1.58 KB

Contents

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

module ActionController
  describe "Rescue", "#rescue_action in default mode" do
    before(:each) do
      @fixture = Object.new
      @fixture.extend ActionController::Rescue
      def @fixture.rescue_with_handler(exception)
        false
      end
      class << @fixture
        public :rescue_action
      end
    end

    it "should raise the passed in exception so examples fail fast" do
      proc {@fixture.rescue_action(RuntimeError.new("Foobar"))}.should raise_error(RuntimeError, "Foobar")
    end
  end

  class RescueOverriddenController < ActionController::Base
    def rescue_action(error)
      "successfully overridden"
    end
  end

  describe "Rescue", "#rescue_action, when overridden" do
    before(:each) do
      @fixture = RescueOverriddenController.new
    end

    it "should do whatever the overridden method does" do
      @fixture.rescue_action(RuntimeError.new("Foobar")).should == "successfully overridden"
    end
  end

  class SearchController < ActionController::Base
  end

  describe "Rescue", "#rescue_action when told to use rails error handling" do
    before(:each) do
      @controller = SearchController.new
      @controller.use_rails_error_handling!
      class << @controller
        public :rescue_action
      end
    end

    it "should use Rails exception handling" do
      exception = RuntimeError.new("The Error")
      exception.stub!(:backtrace).and_return(caller)
      @controller.should_receive(:rescue_action_locally).with(exception)

      @controller.rescue_action(exception)
    end
  end
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
dchelimsky-rspec-rails-1.1.12 spec/spec/rails/extensions/action_controller_rescue_action_spec.rb
dchelimsky-rspec-rails-1.1.99.1 spec/spec/rails/extensions/action_controller_rescue_action_spec.rb
dchelimsky-rspec-rails-1.1.99.2 spec/spec/rails/extensions/action_controller_rescue_action_spec.rb
dchelimsky-rspec-rails-1.1.99.3 spec/spec/rails/extensions/action_controller_rescue_action_spec.rb
dchelimsky-rspec-rails-1.1.99.4 spec/spec/rails/extensions/action_controller_rescue_action_spec.rb
dchelimsky-rspec-rails-1.1.99.5 spec/spec/rails/extensions/action_controller_rescue_action_spec.rb
rspec-rails-1.1.12 spec/spec/rails/extensions/action_controller_rescue_action_spec.rb
spree-0.6.0 vendor/plugins/rspec-rails/spec/spec/rails/extensions/action_controller_rescue_action_spec.rb
spree-0.7.0 vendor/plugins/rspec-rails/spec/spec/rails/extensions/action_controller_rescue_action_spec.rb
spree-0.7.1 vendor/plugins/rspec-rails/spec/spec/rails/extensions/action_controller_rescue_action_spec.rb
spree-0.8.0 vendor/plugins/rspec-rails/spec/spec/rails/extensions/action_controller_rescue_action_spec.rb
spree-0.8.1 vendor/plugins/rspec-rails/spec/spec/rails/extensions/action_controller_rescue_action_spec.rb