Last active
January 18, 2019 17:49
-
-
Save dannguyen/6595597 to your computer and use it in GitHub Desktop.
Running rails engine with rspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to run this task from the console?