Last active
February 11, 2018 10:15
-
-
Save dannguyen/6202994 to your computer and use it in GitHub Desktop.
RSpec helper (spec_helper.rb) for a Rails Engine setup, as per http://stackoverflow.com/questions/7452037/testing-rails-3-1-mountable-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
# Rails Engine call | |
`rails plugin new MY_ENGINE --dummy-path=spec/dummy --skip-test-unit --full --database=mysql` | |
or `rails plugin new ENGINE_NAME --dummy-path=spec/dummy --skip-test-unit --mountable --database=mysql` | |
# Configure spec_helper.rb | |
ENV["RAILS_ENV"] = "test" | |
require File.expand_path("../dummy/config/environment.rb", __FILE__) | |
require 'rspec/rails' | |
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../') | |
# Requires supporting ruby files with custom matchers and macros, etc, | |
# in spec/support/ and its subdirectories. | |
Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f } | |
RSpec.configure do |config| | |
config.use_transactional_fixtures = true | |
# Use color in STDOUT | |
config.color_enabled = true | |
# Use color not only in STDOUT but also in pagers and files | |
config.tty = true | |
# Use the specified formatter | |
config.formatter = :documentation # :progress, :html, :textmate | |
config.before(:each) do | |
end | |
config.after(:each) do | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment