Class: RSpec::Http::ResponseCodeMatcher
- Inherits:
-
Object
- Object
- RSpec::Http::ResponseCodeMatcher
- Defined in:
- lib/rspec/http/response_code_matcher.rb
Instance Method Summary collapse
- #common_message ⇒ Object
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(expected_code) ⇒ ResponseCodeMatcher
constructor
A new instance of ResponseCodeMatcher.
- #matches?(target) ⇒ Boolean
Constructor Details
#initialize(expected_code) ⇒ ResponseCodeMatcher
4 5 6 |
# File 'lib/rspec/http/response_code_matcher.rb', line 4 def initialize(expected_code) @expected_code = expected_code end |
Instance Method Details
#common_message ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/rspec/http/response_code_matcher.rb', line 25 def = "have a response code of #{@expected_code}, but got #{@target.status}" if @target.status == 302 || @target.status == 201 += " with a location of #{@target['Location'] || @target['location']}" end end |
#description ⇒ Object
13 14 15 |
# File 'lib/rspec/http/response_code_matcher.rb', line 13 def description "Response code should be #{@expected_code}" end |
#failure_message ⇒ Object
17 18 19 |
# File 'lib/rspec/http/response_code_matcher.rb', line 17 def "Expected #{@target} to #{common_message}" end |
#failure_message_when_negated ⇒ Object
21 22 23 |
# File 'lib/rspec/http/response_code_matcher.rb', line 21 def "Expected #{@target} to not #{common_message}" end |
#matches?(target) ⇒ Boolean
8 9 10 11 |
# File 'lib/rspec/http/response_code_matcher.rb', line 8 def matches?(target) @target = target @target.status == @expected_code end |