I'm not 100% happy with a project at work, where we're building out a jsonapi from a legacy rails app (part rewrite in-place, part move to react for front-end) - and after setting it up rswag with integration tests generating swagger schemas has been pretty nice. Not quite decided on what I think about activemodel::serializer... But it mostly works, without too much tweaking.
Rswag looks cool, will try it out. There are tests for rails controllers and I have recently setup Cypress for component testing, will be focusing on tests the coming days.
require "test_helper"
class FoldersControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end
Same for empty model tests etc - I'd strongly encourage removing them - as they just add noise.
Btw, if not doing tdd, time is probably better spent on integration tests than controller/model tests. Main challenge I've found with rails projects that were put in use with no tests, is there's a big effort to set up test data/fixtures from scratch. One option can sometimes be to just set up a test database with real data (database dump as a fixture).
> and I have recently setup Cypress for component testing
That's nice, and probably a good focus for a project like this.
Ed: as for mocking/integration testing apis - which might be useful here, there's "vcr":
https://github.com/vcr/vcr
I'm not 100% happy with a project at work, where we're building out a jsonapi from a legacy rails app (part rewrite in-place, part move to react for front-end) - and after setting it up rswag with integration tests generating swagger schemas has been pretty nice. Not quite decided on what I think about activemodel::serializer... But it mostly works, without too much tweaking.
I've also adopted some ideas from:
https://github.com/guillaumebriday/jsonapi-scopes
For filtering/sorting - I think something like it should be in rails, really.
Rswag: https://github.com/rswag/rswag