jejacks0n / teaspoon

Teaspoon: Javascript test runner for Rails. Use Selenium, BrowserStack, or PhantomJS.
1.43k stars 243 forks source link

install_generator not working inside Rails engine #370

Closed richardvenneman closed 9 years ago

richardvenneman commented 9 years ago

I added teaspoon-mocha to my gemspec with:

s.add_development_dependency "teaspoon-mocha", "~> 2.2"

and ran bundle install. While Bundler reported that the teaspoon and teaspoon-mocha gems installed correctly, running bundle exec rails g teaspoon:install raises the following error:

[WARNING] Could not load generator "generators/teaspoon/install/install_generator". Error: uninitialized constant Teaspoon::Framework.
/Users/richard/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/teaspoon-1.0.2/lib/generators/teaspoon/install/install_generator.rb:14:in `<class:InstallGenerator>'
/Users/richard/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/teaspoon-1.0.2/lib/generators/teaspoon/install/install_generator.rb:6:in `<module:Generators>'
/Users/richard/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/teaspoon-1.0.2/lib/generators/teaspoon/install/install_generator.rb:5:in `<module:Teaspoon>'
/Users/richard/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/teaspoon-1.0.2/lib/generators/teaspoon/install/install_generator.rb:4:in `<top (required)>'
/Users/richard/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/generators.rb:334:in `block (2 levels) in lookup'
/Users/richard/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/generators.rb:330:in `each'
/Users/richard/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/generators.rb:330:in `block in lookup'
/Users/richard/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/generators.rb:329:in `each'
/Users/richard/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/generators.rb:329:in `lookup'
/Users/richard/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/generators.rb:138:in `find_by_namespace'
/Users/richard/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/generators.rb:155:in `invoke'
/Users/richard/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/generate.rb:13:in `<top (required)>'
/Users/richard/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/engine/commands.rb:19:in `<top (required)>'
bin/rails:12:in `require'
bin/rails:12:in `<main>'

Is it possible to test the assets in my Rails engine?

mikepack commented 9 years ago

For test dependencies, I'd recommend you put them in your Gemfile. Bundler doesn't have great integration for gemspec dev dependencies. In other words, dev deps aren't loaded when you run bundle exec.

mikepack commented 9 years ago

To answer your question about testing Rails engines, yes. You'll also want to adjust your config.root to point to your engine's root.

jejacks0n commented 9 years ago

Basically what @mikepack says. Development dependencies are not installed and known about via bundler -- and there isn't a way to tell bundler to include them. This is easy to confirm by looking at your Gemfile.lock file and noting that teaspoon-mocha will not be listed -- then shift your gemspec to include it as a add_dependency instead of add_development_dependency -- it will be listed.

The way most people resolve this sort of thing is to put it in your Gemfile under a :development group as well as the gemspec, though I personally don't bother putting it in the gemspec at that point.

There's a wiki about testing engines -- @mikepack is this still accurate? https://github.com/modeset/teaspoon/wiki/Testing-Engine-Assets

mikepack commented 9 years ago

@jejacks0n looks current.

mariohmol commented 8 years ago

Hi there!!

i have teaspoon-mocha inside the lock file, all set.. but when i run generattor get same error.. opened a new issue as this is 1 year old https://github.com/modeset/teaspoon/issues/496