Sha256: 9b334499fb07e95b86d4b7b9d2b4a48abbc62e237075802ba4faba71cb051cdf

Contents?: true

Size: 958 Bytes

Versions: 47

Compression:

Stored size: 958 Bytes

Contents

module RSpec
  module Rails
    module Matchers
      # Matcher for redirects.
      module RedirectTo
        # @private
        class RedirectTo < RSpec::Rails::Matchers::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

47 entries across 44 versions & 7 rubygems

Version Path
rspec-rails-7.1.1 lib/rspec/rails/matchers/redirect_to.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/rspec-rails-7.1.0/lib/rspec/rails/matchers/redirect_to.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/rspec-rails-7.1.0/lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-7.1.0 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-7.0.2 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-7.0.1 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-7.0.0 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-6.1.5 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-6.1.4 lib/rspec/rails/matchers/redirect_to.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rspec-rails-6.1.3/lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-6.1.3 lib/rspec/rails/matchers/redirect_to.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/rspec-rails-6.0.4/lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-6.1.2 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-6.1.1 lib/rspec/rails/matchers/redirect_to.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rspec-rails-5.1.2/lib/rspec/rails/matchers/redirect_to.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rspec-rails-5.1.1/lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-6.1.0 lib/rspec/rails/matchers/redirect_to.rb
rspec-rails-6.0.4 lib/rspec/rails/matchers/redirect_to.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rspec-rails-5.1.2/lib/rspec/rails/matchers/redirect_to.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rspec-rails-5.1.1/lib/rspec/rails/matchers/redirect_to.rb