Hi, I am just getting started with Rails & Rspec. I have something that looks like this currently in a request spec:
describe 'GET repairs/index/1' do let!(:repair) { FactoryBot.create(:repair) } before do # TODO: check if there is a better way to call the get here *get '/api/v1/repairs/' + repair.id.to_s* end it 'returns status code 200' do expect(response).to have_http_status(200) end it 'returns a valid json response' do expect(response.content_type).to eq('application/json; charset=utf-8') end it 'returns the first repairs' do # TODO: currently json return 6 attributes, that is why we have eq(6), we should validate attributes of object *expect(JSON.parse(response.body).size).to eq(6)* end end It does work; however, I am trying to understand to see how I can first build the GET request in a better way. Also, the get request returns a JSON, should I parse the JSON into a repair object and expect on the model attributes? Thanks! -- You received this message because you are subscribed to the Google Groups "rspec" group. To unsubscribe from this group and stop receiving emails from it, send an email to rspec+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/270ce60b-8e73-49ea-8b34-96db0ddfbb44n%40googlegroups.com.