Sha256: e8ef3174d3dbb1d0e7d9be32b380840c2cc817fcb2b0de806a9374ed461e435c
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true RSpec::Matchers.define :have_http_status do |expected| match do |response| response.status == response_codes[expected] end failure_message do |response| 'expected last response status to be ' \ "#{response_codes.fetch(expected, 'unknown')}, " \ "but was #{response.status}" end def response_codes { ok: 200, not_authorized: 401, not_found: 404, redirect: 302 }.freeze end end RSpec::Matchers.define :have_content_type do |expected| match do |response| response.content_type == content_types[expected] end failure_message do |response| 'expected last response to have content type ' \ "'#{content_types.fetch(expected, 'unknown')}', " \ "but was '#{response.content_type}'" end def content_types { html: 'text/html;charset=utf-8', json: 'application/json' }.freeze end end RSpec::Matchers.define :redirect_to do |expected| match do |response| path(response) == expected end failure_message do |response| "expected last response to redirect to '#{expected}', " \ "but it redirected to '#{path(response)}'" end def path(response) URI(response.location).path end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hoboken-0.9.0 | lib/hoboken/templates/spec/rack_matchers.rb.tt |