Sha256: 536f40cfd3d27db2de0bb91d980730bfbaa762b9cac5084e4ecb31cc777f4e14

Contents?: true

Size: 853 Bytes

Versions: 3

Compression:

Stored size: 853 Bytes

Contents

module RSpec::Rails::Matchers
  module RedirectTo
    class RedirectTo
      include RSpec::Matchers::BaseMatcher

      def initialize(scope, expected)
        super(expected)
        @scope = scope
      end

      # @api private
      def matches?(actual)
        match_unless_raises ActiveSupport::TestCase::Assertion do
          @scope.assert_redirected_to(expected)
        end
      end

      # @api private
      def failure_message_for_should
        rescued_exception.message
      end

      # @api private
      def failure_message_for_should_not
        "expected not to redirect to #{expected.inspect}, but did"
      end
    end

    # Delegates to `assert_redirected_to`
    #
    # @example
    #
    #     response.should redirect_to(:action => "new")
    def redirect_to(target)
      RedirectTo.new(self, target)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rspec-rails-2.8.1 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-2.8.0 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-2.8.0.rc2 lib/rspec/rails/matchers/redirect_to.rb