Skip to content

Instantly share code, notes, and snippets.

@dannguyen
Last active January 18, 2019 17:49
Show Gist options
  • Save dannguyen/6595597 to your computer and use it in GitHub Desktop.
Save dannguyen/6595597 to your computer and use it in GitHub Desktop.
Running rails engine with rspec
# http://viget.com/extend/rails-engine-testing-with-rspec-capybara-and-factorygirl
rails plugin new my_engine --dummy-path=spec/dummy --skip-test-unit --mountable
# or, the full monty:
rails plugin new active_scraper --mountable --dummy-path=spec/dummy --skip-test-unit --skip-javascript --skip-sprockets --skip-action-view
# https://github.com/rspec/rspec-rails
rails generate rspec:install
# edit engine.rb
module MyEngine
class Engine < ::Rails::Engine
isolate_namespace MyEngine
# monkey patch via: http://pivotallabs.com/leave-your-migrations-in-your-rails-engines/
initializer :append_migrations do |app|
unless app.root.to_s.match root.to_s
app.config.paths["db/migrate"] += config.paths["db/migrate"].expanded
end
end
config.generators do |g|
g.test_framework :rspec, :fixture => false
g.assets false
g.helper false
end
end
end
@imi56
Copy link

imi56 commented Jun 12, 2018

How to run this task from the console?

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