Sha256: f5fc3544d1b75770ad175af0358222eefb7da0fb38626adde9020c8571adaadc

Contents?: true

Size: 960 Bytes

Versions: 37

Compression:

Stored size: 960 Bytes

Contents

module RSpec
  module Rails
    module Matchers
      # Matcher for redirects.
      module RedirectTo
        # @private
        class RedirectTo < RSpec::Matchers::BuiltIn::BaseMatcher
          def initialize(scope, expected)
            @expected = expected
            @scope = scope
          end

          def matches?(_)
            match_unless_raises ActiveSupport::TestCase::Assertion do
              @scope.assert_redirected_to(@expected)
            end
          end

          def failure_message
            rescued_exception.message
          end

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

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

Version data entries

37 entries across 36 versions & 5 rubygems

Version Path
rspec-rails-3.8.3 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.8.2 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.8.1 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.8.0 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.7.2 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.7.1 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.7.0 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.6.1 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.6.0 lib/rspec/rails/matchers/redirect_to.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/rspec-rails-3.5.2/lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.6.0.beta2 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.6.0.beta1 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.5.2 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.5.1 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.5.0 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.5.0.beta4 lib/rspec/rails/matchers/redirect_to.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/rspec-rails-3.4.2/lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.5.0.beta3 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.5.0.beta2 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-3.5.0.beta1 lib/rspec/rails/matchers/redirect_to.rb