Here are the steps:
1. Create the engine:
> rails plugin new icmoc_core -T --mountable --full --dummy-path=spec/test_app * -T tells the generator to skip Test::Unit * --mountable tells the generator that you want a namespaced engine * --full tells the generator that you want app and config directories * --dummy-path is the rails app that is generated for your tests. It's called test/dummy by default, but I never liked calling it that.
2. Add rails-rspec and factory_bot_rails as a dependencies in your Gemfile:
source "http://rubygems.org" gemspec gem "rspec-rails", "~> 2.12.2" gem "factory_bot_rails", "~> 4.0"
Then bundle install.
3. Now edit your engine's lib/icmoc_core/engine.rb file to include rspec:
module IcmocCore class Engine < ::Rails::Engine isolate_namespace GemName config.generators do |g| g.test_framework :rspec g.fixture_replacement :factory_bot, :dir => 'spec/factories' end end end
4. Run the rspec generator:
> rails generate rspec:install
5. After creating some models and migrations, run the migrations for the test app and the test database:
> bundle exec rake app:db:migrate > bundle exec rake app:db:test:prepare
Now you have a Rails engine configured to use RSpec.