-
Notifications
You must be signed in to change notification settings - Fork 242
Testing Engine Assets
Michael edited this page Aug 18, 2014
·
9 revisions
It's a common technique to have a dummy application within your engine test suite, and Teaspoon makes it really easy to get setup in that way.
Change the configuration to specify where the root of where your specs live. You can do this in an initializer in the dummy application, which you can get by running the rails g teaspoon:install
generator from within the dummy app.
spec/teaspoon_env.rb
unless defined?(Rails)
ENV["RAILS_ROOT"] = File.expand_path("../dummy", __FILE__)
require File.expand_path("../dummy/config/environment", __FILE__)
end
Teaspoon.configure do |config|
config.root = Your::Engine.root
end
Note that we require Rails from the dummy application. After doing that you can create the spec/javascripts path in the root of your engine.
It's also common that you'd want the rake tasks from the root of your engine as well. You can add the rake tasks to your own RakeFile by mapping it to run app:teaspoon
:
# Load the dummy app's rake tasks
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
load "rails/tasks/engine.rake"
desc "Run the javascript specs"
task :teaspoon => "app:teaspoon"