Closed jwmay2012 closed 9 years ago
Move all specs out of the dummy app, into the engine root/specs. Are you testing the dummy app, or is the dummy app the means to test your engine? The former should be your answer fwiw, which makes my recommendation make more sense.
Jeremy Jackson
On Nov 3, 2014, at 12:26 PM, Jordan May(Intern2) notifications@github.com wrote:
Following the instructions here: https://github.com/modeset/teaspoon/wiki/Testing-Engine-Assets If I start the rails server in the dummy app, the web interface runs the tests that are outside the dummy directory propertly. If I run 'rake teaspoon' in the dummy directory everything is also good. But if I run 'rake teaspoon' at the root of my engine it says Teaspoon::EnvironmentNotFound: Unable to load Teaspoon environment in {spec/teaspoon_env.rb, test/teaspoon_env.rb, teaspoon_env.rb} That file is in dummy/spec. How do I get it to be seen by my engine's rake task?
— Reply to this email directly or view it on GitHub.
I had this same problem. My specs were properly placed into the engine specs/folder, but the teaspoon_env.rb file was in the dummy app as the wiki page pointed out. Running the specs from the dummy app worked fine, but from the engine it did try to look for the teaspoon_env.rb file in "engine_root/spec/".
Moving the teaspoon_env.rb from the dummy to the engine solved the problem for me.
I had a similar issue where when my teaspoon_env.rb
was in the dummy app the rake task would fail and when it was in the engine root the in browser specs would fail. I ended up setting up dotenv in my dummy app and set TEASPOON_ENV=/absolute/path/to/teaspoon_env.rb
. That solved the issue for me.
Today I ran into this issue and played with a bunch of different things until I got this to work.
From the root of an engine you should be able to run the app:teaspoon
rake task, which will fail because it can't find the spec/teaspoon_env.rb
or config/environment.rb
. Since we are able to hook into those couple of ENV vars though, we can get in front of the app:teaspoon
rake task being called with something like this in <engine root>/Rakefile
desc 'Run the javascript specs'
task :teaspoon do
ENV['TEASPOON_ENV'] = File.expand_path('../spec/dummy/spec/teaspoon_env.rb', __FILE__)
ENV['TEASPOON_RAILS_ENV'] = File.expand_path('../spec/dummy/config/environment.rb', __FILE__)
Rake::Task["app:teaspoon"].invoke
end
All looks good :) :+1:
Thanks for the heads up! :+1: Just as an aside, teaspoon is tested with teaspoon, and the teaspoon specs aren't in the dummy app -- they're in the engine top level specs. That's the official recommendation, but settings the envs works as well. I guess the reasoning behind putting them at the engine spec level, is because the dummy app is just the stub used to test your engine, and I don't put things like the rspec specs or capybara features in the dummy app either. That same logic seemed to apply to the javascript ones as well.
@jejacks0n yeah I would have to agree with that. My first attempt had it situated as such but I couldn't figure out what was going on so I went with the instructions in the wiki until I got it to work. Now that I have a better working knowledge of its internals I'm going to do just that - move the js specs from within the dummy app to the engine specs dir.
Glad it worked. Feel free to check out the dummy app from teaspoon, it's lightweight, and I think there's a few specific changes that are needed in general?
Jeremy Jackson
On Aug 26, 2015, at 8:16 AM, Joel Oliveira notifications@github.com wrote:
@jejacks0n yeah I would have to agree with that. My first attempt had it situated as such but I couldn't figure out what was going on so I went with the instructions in the wiki until I got it to work. Now that I have a better working knowledge of its internals I'm going to do just that - move the js specs from within the dummy app to the engine specs dir.
— Reply to this email directly or view it on GitHub.
Following the instructions here: https://github.com/modeset/teaspoon/wiki/Testing-Engine-Assets If I start the rails server in the dummy app, the web interface runs the tests that are outside the dummy directory propertly. If I run 'rake teaspoon' in the dummy directory everything is also good. But if I run 'rake teaspoon' at the root of my engine it says Teaspoon::EnvironmentNotFound: Unable to load Teaspoon environment in {spec/teaspoon_env.rb, test/teaspoon_env.rb, teaspoon_env.rb} That file is in dummy/spec. How do I get it to be seen by my engine's rake task?