Class: APIMatchers::HTTPStatusCode::Base
- Inherits:
-
Object
- Object
- APIMatchers::HTTPStatusCode::Base
- Defined in:
- lib/api_matchers/http_status_code/base.rb
Direct Known Subclasses
BeBadRequest, BeInternalServerError, BeNotFound, BeOk, BeUnauthorized, BeUnprocessableEntity, CreateResource
Instance Attribute Summary collapse
-
#setup ⇒ Object
readonly
Returns the value of attribute setup.
Instance Method Summary collapse
- #expected_status_code ⇒ Object
-
#find_http_status_code(actual) ⇒ Object
If have some configuration about the method to call on actual that method will be called.
-
#initialize(setup) ⇒ Base
constructor
A new instance of Base.
-
#matches?(actual) ⇒ Boolean
Matches the actual with the expected http status code.
Constructor Details
#initialize(setup) ⇒ Base
Returns a new instance of Base.
6 7 8 |
# File 'lib/api_matchers/http_status_code/base.rb', line 6 def initialize(setup) @setup = setup end |
Instance Attribute Details
#setup ⇒ Object (readonly)
Returns the value of attribute setup.
4 5 6 |
# File 'lib/api_matchers/http_status_code/base.rb', line 4 def setup @setup end |
Instance Method Details
#expected_status_code ⇒ Object
17 18 19 |
# File 'lib/api_matchers/http_status_code/base.rb', line 17 def expected_status_code raise NotImplementedError, "not implemented on #{self}" end |
#find_http_status_code(actual) ⇒ Object
If have some configuration about the method to call on actual that method will be called.
23 24 25 26 27 28 29 |
# File 'lib/api_matchers/http_status_code/base.rb', line 23 def find_http_status_code(actual) if @setup.http_status_method.present? actual.send(@setup.http_status_method) else actual end end |
#matches?(actual) ⇒ Boolean
Matches the actual with the expected http status code
12 13 14 15 |
# File 'lib/api_matchers/http_status_code/base.rb', line 12 def matches?(actual) @http_status_code = find_http_status_code(actual) @http_status_code.equal?(expected_status_code) end |