Skip to content

Instantly share code, notes, and snippets.

@mattgoldman
Last active December 22, 2015 23:09
Show Gist options
  • Save mattgoldman/6544452 to your computer and use it in GitHub Desktop.
Save mattgoldman/6544452 to your computer and use it in GitHub Desktop.
Rails 4 Engine using RSpec & Factory Girl

Run this command, replace gem_name

$   rails plugin new gem_name -T --mountable --dummy-path=spec/dummy # for namespaced mountable engine
$   rails plugin new gem_name -T --full --dummy-path=spec/dummy # for basic engine

Add the following to the Gemfile

gem "rspec-rails", "2.14.0.rc1"
gem "factory_girl_rails", "4.2.1"

Bundle locally

$   bundle install --path vendor

Add the following to lib/gem_name/engine.rb

config.generators do |g|
  g.test_framework :rspec
  g.fixture_replacement :factory_girl, :dir => 'spec/factories'
end

Run the following to setup RSpec

$   bundle exec rails generate rspec:install

Run the following from within spec/dummy to run the dummy app, using the engine

$   rails s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment