module RailsStuff::RSpecHelpers::Matchers::RedirectWithTurbolinks

Public Instance Methods

active_support_assertion(location) click to toggle source
# File lib/rails_stuff/rspec_helpers/matchers/redirect_with_turbolinks.rb, line 39
def active_support_assertion(location)
  redirect_is       = @scope.send(:normalize_argument_to_redirection, location)
  redirect_expected = @scope.send(:normalize_argument_to_redirection, @expected)
  message = "Expected response to be a Turbolinks redirect to <#{redirect_expected}>" \
    " but was a redirect to <#{redirect_is}>"
  @scope.assert_operator redirect_expected, :===, redirect_is, message
rescue ActiveSupport::TestCase::Assertion => e
  raise XhrFailure, e
end
failure_message() click to toggle source
Calls superclass method
# File lib/rails_stuff/rspec_helpers/matchers/redirect_with_turbolinks.rb, line 18
def failure_message
  @scope.request ? super : 'Request was not performed'
end
matches?(response) click to toggle source
Calls superclass method
# File lib/rails_stuff/rspec_helpers/matchers/redirect_with_turbolinks.rb, line 9
def matches?(response)
  return unless @scope.request
  if @scope.request.xhr?
    match_unless_raises(XhrFailure) { matches_xhr?(response) }
  else
    super
  end
end
matches_xhr?(response) click to toggle source
# File lib/rails_stuff/rspec_helpers/matchers/redirect_with_turbolinks.rb, line 22
def matches_xhr?(response)
  unless be_ok.matches?(response)
    raise XhrFailure, "Expect #{response.inspect} to be OK for Turbolinks redirect"
  end
  location, _options = turbolinks_location(response)
  raise XhrFailure, "No Turbolinks redirect in\n\n#{response.body}" unless location
  active_support_assertion(location)
end