describe "when the shopper exists" do
      it "should return a single shopper" do
        get :show, {id: shopper.id }
        expect(response.status).to eql(200)
        shopper_json = JSON.parse(response.body, {:symbolize_names => true})

        expect(shopper_json[:id]).to eql(shopper.id)
        expect(shopper_json).to have_key(:client)
        expect(shopper_json).to have_key(:cover)
        expect(shopper_json).to have_key(:pages)
      end
    end


it 'assigns all timetable, shopper, clients and user versions as @versions' do
  xhr :get, :index, { month: 0 }
  body = JSON.parse(response.body)["results"]
  serialized_version = VersionSerializer.new(
      current_month_version.decorate, 
      root: false
    ).as_json.stringify_keys

  expect(body).to include(serialized_version)
end

As Saint Sandy says:

The API's index/show action is a query method

and you only test the result for query methods.

 

 

Also supposedly you are testing the serializers in another layer, so you can have the confidence of using it here.

Made with Slides.com