class BugTest
Replace this with the code necessary to make your test fail.
Replace this with the code necessary to make your test fail.
Public Instance Methods
json_api_headers()
click to toggle source
# File lib/bug_report_templates/rails_5_latest.rb, line 89 def json_api_headers {'Accept' => JSONAPI::MEDIA_TYPE, 'CONTENT_TYPE' => JSONAPI::MEDIA_TYPE} end
test_create_your_models()
click to toggle source
# File lib/bug_report_templates/rails_5_latest.rb, line 106 def test_create_your_models json_request = { 'data' => { type: 'your_models', attributes: { name: 'Jane Doe' } } } post '/your_models', json_request.to_json, json_api_headers assert last_response.created? refute_nil YourModel.find_by(name: 'Jane Doe') end
test_index_your_models()
click to toggle source
# File lib/bug_report_templates/rails_5_latest.rb, line 93 def test_index_your_models record = YourModel.create! name: 'John Doe' get '/your_models', nil, json_api_headers assert last_response.ok? json_response = JSON.parse(last_response.body) refute_nil json_response['data'] refute_empty json_response['data'] refute_empty json_response['data'].first assert record.id.to_s, json_response['data'].first['id'] assert 'your_models', json_response['data'].first['type'] assert({'name' => 'John Doe'}, json_response['data'].first['attributes']) end
Private Instance Methods
app()
click to toggle source
# File lib/bug_report_templates/rails_5_latest.rb, line 122 def app Rails.application end