← Back to Upcase

Which tests to write in JSON Rails API?


(Samnang Chhun) #1

I’m following outside-in development for developing web applications in Rails, but I’m confusing when I’m developing JSON API in Rails because using request spec(similar Rack::Test) is almost the same test with controller specs because we hit one url with optional params, then we get back the response, so it seems to me almost the same thing.

One more thing, I’m using rails-api with active-model-serializer, I also feel have a duplicate tests for parsing response body into hash, and then check all attributes to have correct data, but I feel this very similar when I already have my serializer’s unit tests. But if they don’t test most attributes in response body how can we guarantee controller picks up the correct serializer to render json.