Building a Rails Engine #13 -- How to test a mountable Rails engine without a dummy app
Testing a Rails Engine with RSpec How to test a mountable Rails engine without a dummy app -- just an in-memory SQLite database and 60 lines of spec_helper. Context This is part 13 of the series wh...

Source: DEV Community
Testing a Rails Engine with RSpec How to test a mountable Rails engine without a dummy app -- just an in-memory SQLite database and 60 lines of spec_helper. Context This is part 13 of the series where we build DataPorter, a mountable Rails engine for data import workflows. In part 12, we extended the Source layer to support JSON files and API endpoints. We have been writing specs throughout the series, but we never stepped back to explain how the test suite works. A Rails engine is not a Rails app. There is no config/database.yml. There is no spec/rails_helper.rb generated by rspec-rails. There is no schema to load, no test database to create, no ApplicationController to inherit from. Every piece of infrastructure that a typical Rails project gives you for free -- the database connection, the load paths, the base controller class -- has to be set up manually in a gem's test suite. In this article, we look at the full testing strategy: the spec_helper that bootstraps a minimal Rails env