jejacks0n / teaspoon

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

"Can't find variable: Teaspoon" because of wrong assets URI after upgrading to 0.8.0 #399

Closed agis closed 9 years ago

agis commented 9 years ago

Hello.

I've performed the following steps to upgrade from 0.7.9 to 0.8.0 (Rails 3.2.22). I've followed the described steps in the CHANGELOG and I get the following error when trying to run the tests:

$ RAILS_ENV=test bundle exec teaspoon --suite=default
ReferenceError: Can't find variable: Teaspoon
  # http://127.0.0.1:52072/teaspoon/default?reporter=Console:11 -- global code

ReferenceError: Can't find variable: Teaspoon
  # http://127.0.0.1:52072/teaspoon/default?reporter=Console:75 -- global code

Failed to load: http://127.0.0.1:52072/teaspoon/default?reporter=Console

The exception is thrown when #execute calls #execute_without_handling. The exception is then rescued a little later.

Grabbing the backtrace of the exception at that point, gives us:

> e.backtrace
=> ["/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/runner.rb:53:in `on_exception'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/runner.rb:34:in `notify_formatters'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/runner.rb:17:in `process'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/drivers/phantomjs_driver.rb:24:in `block in run_specs'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/drivers/phantomjs_driver.rb:31:in `each'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/drivers/phantomjs_driver.rb:31:in `block in run'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/drivers/phantomjs_driver.rb:31:in `popen'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/drivers/phantomjs_driver.rb:31:in `run'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/drivers/phantomjs_driver.rb:23:in `run_specs'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/console.rb:45:in `run_specs'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/console.rb:35:in `block in execute_without_handling'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/console.rb:33:in `each'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/console.rb:33:in `inject'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/console.rb:33:in `execute_without_handling'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/console.rb:21:in `execute'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/console.rb:17:in `failures?'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/lib/teaspoon/command_line.rb:13:in `initialize'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/bin/teaspoon:6:in `new'",
 "/Users/agis/.gem/ruby/2.1.5/gems/teaspoon-0.8.0/bin/teaspoon:6:in `<top (required)>'",
 "/Users/agis/.gem/ruby/2.1.5/bin/teaspoon:23:in `load'",
 "/Users/agis/.gem/ruby/2.1.5/bin/teaspoon:23:in `<main>'"]

I've added my relevant configuration files in this gist (also included the actual location of the files).

Note that before I've made the changes to go to 0.8.0, my spec_helper file was actually namedspec/javascripts/spec_helper.js.coffee (notice the .js part); not sure if this is relevant.

agis commented 9 years ago

I've followed the steps described in https://github.com/modeset/teaspoon/issues/397#issuecomment-127433338 and I get this page (I've slightly changed the paths; but they are correct anyway):

image

agis commented 9 years ago

I think that I've found the issue but not sure why it's happening. The URIs Teaspoon asks the assets from are wrong:

img

Not sure why this happens thought, any ideas?

agis commented 9 years ago

Just tried running teaspoon without the RAILS_ENV=test part and it works!

Are we supposed to run this command on development or test environment? From the README I assume it should be on development but I want to just make sure, since we were running the command in the test environment until 1.7.x and this is about a CI server so..

cc @jejacks0n @mikepack.

jejacks0n commented 9 years ago

Check your test env, it's probably oddly configured. Only thing that makes sense.


Jeremy Jackson

On Aug 7, 2015, at 7:55 AM, Agis Anastasopoulos notifications@github.com wrote:

Just tried running teaspoon without the RAILS_ENV=test part and it works!

Are we supposed to run this command on development or test environment? Note that this was running with RAILS_ENV=test up until 1.7.x and on our CI server.

— Reply to this email directly or view it on GitHub.

agis commented 9 years ago

Yep, just found out that we're doing this in config/environments/test.rb:

config.action_controller.asset_host = "http://assets.test.host"

Which is not wrong in terms of the Rails app but it breaks up with teaspoon.

However, the question is: what is the standard way to run the command (supposing this is about a CI server)? With RAILS_ENV='test' or without it? In other words, should we run it in the development environment or in the test environment?

Thanks @jejacks0n!

jejacks0n commented 9 years ago

Do you have any integration tests? Like cucumber or capybara? Those wouldn't work either, because your asset host does not exist. How is that a correct configuration? Locally, and via the browser it should run using the dev env because you get the shared asset cache. On CI, it should be test. To be honest, I don't see how it ever worked.


Jeremy Jackson

On Aug 7, 2015, at 7:59 AM, Agis Anastasopoulos notifications@github.com wrote:

Yep, just found out that we're doing this in config/environments/test.rb:

config.action_controller.asset_host = "http://assets.test.host" Which is not wrong in terms of the Rails app but it breaks up with teaspoon. However, the question is: what is the standard way to run the command (supposing this is about a CI server)? With RAILS_ENV='test' or without it?

— Reply to this email directly or view it on GitHub.

agis commented 9 years ago

Not sure but since it resolved I'm closing this. I've left the asset host to the default one. Thanks.