Module: ApiRspecta::ApiRequestsHelpers::ResponseHelpers
- Defined in:
- lib/api_rspecta.rb
Instance Method Summary collapse
- #response_status(status) ⇒ Object
- #should_respond_created ⇒ Object
- #should_respond_not_authenticated ⇒ Object
- #should_respond_not_authorized ⇒ Object
- #should_respond_not_found ⇒ Object
- #should_respond_ok ⇒ Object
- #should_respond_with_error_for(field) ⇒ Object
- #should_respond_with_errors_for(fields) ⇒ Object
- #should_respond_with_no_content ⇒ Object
Instance Method Details
#response_status(status) ⇒ Object
74 75 76 |
# File 'lib/api_rspecta.rb', line 74 def response_status(status) expect(response.status).to eq(status) end |
#should_respond_created ⇒ Object
54 55 56 |
# File 'lib/api_rspecta.rb', line 54 def should_respond_created response_status 201 end |
#should_respond_not_authenticated ⇒ Object
62 63 64 |
# File 'lib/api_rspecta.rb', line 62 def should_respond_not_authenticated response_status 401 end |
#should_respond_not_authorized ⇒ Object
66 67 68 |
# File 'lib/api_rspecta.rb', line 66 def response_status 403 end |
#should_respond_not_found ⇒ Object
70 71 72 |
# File 'lib/api_rspecta.rb', line 70 def should_respond_not_found response_status 404 end |
#should_respond_ok ⇒ Object
50 51 52 |
# File 'lib/api_rspecta.rb', line 50 def should_respond_ok response_status 200 end |
#should_respond_with_error_for(field) ⇒ Object
78 79 80 81 |
# File 'lib/api_rspecta.rb', line 78 def should_respond_with_error_for(field) response_status 422 expect(json["errors"]).to have_key(field.to_s) end |
#should_respond_with_errors_for(fields) ⇒ Object
83 84 85 |
# File 'lib/api_rspecta.rb', line 83 def should_respond_with_errors_for(fields) fields.each { |field| should_respond_with_error_for(field) } end |
#should_respond_with_no_content ⇒ Object
58 59 60 |
# File 'lib/api_rspecta.rb', line 58 def should_respond_with_no_content response_status 204 end |