Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better "failed to load" information #120

Closed
viddo opened this issue Oct 11, 2013 · 13 comments
Closed

Better "failed to load" information #120

viddo opened this issue Oct 11, 2013 · 13 comments

Comments

@viddo
Copy link

viddo commented Oct 11, 2013

I noticed that if one of my spec files (or spec_helper) contains a faulty require, e.g.:

//= require broken_file.js
describe("My great feature", function() {

  it("will change the world", function() {
    expect(true).toBe(true);
    expect(jQuery).toBeDefined();
  });

});

Then teaspoon yields:

$ bundle exec rake teaspoon
Starting the Teaspoon server...
Teaspoon running default suite at http://127.0.0.1:61696/teaspoon/default
Error: Failed to load: http://127.0.0.1:61696/teaspoon/default?reporter=Console
rake aborted!

/Users/viddo/src/project/vendor/ruby/2.0.0/gems/teaspoon-0.7.7/lib/tasks/teaspoon.rake:5:in `block in <top (required)>`
Tasks: TOP => teaspoon
(See full trace by running task with --trace)
$ bundle exec rake teaspoon --trace
** Invoke teaspoon (first_time)
** Invoke environment (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute environment
** Execute teaspoon
Starting the Teaspoon server...
Teaspoon running default suite at http://127.0.0.1:61715/teaspoon/default
Error: Failed to load: http://127.0.0.1:61715/teaspoon/default?reporter=Console
rake aborted!

/Users/viddo/src/project/vendor/ruby/2.0.0/gems/teaspoon-0.7.7/lib/tasks/teaspoon.rake:5:in `block in <top (required)>'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/opt/boxen/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/viddo/src/project/vendor/ruby/2.0.0/bin/rake:23:in `load'
/Users/viddo/src/project/vendor/ruby/2.0.0/bin/rake:23:in `<main>'
Tasks: TOP => teaspoon

Is it be possible for teaspoon to give something more useful to identify this kind of error rather than just saying "Failed to load"? I would not mind to help out to implement this but wanted to see if this is a known issue, and if there are some efforts to solve this before.

@jejacks0n
Copy link
Owner

Yes, there's code in there for that that used to work in rails 3.2.x, so I assume it must've broken with 4?

This was important for that to work:

https://github.com/modeset/teaspoon/blob/master/lib/teaspoon/console.rb#L13


Jeremy Jackson

On Oct 11, 2013, at 4:18 AM, Nicklas Gummesson notifications@github.com wrote:

I noticed that if one of my spec files (or spec_helper) contains a faulty require, e.g.:

//= require broken_file.js
describe("My great feature", function() {

it("will change the world", function() {
expect(true).toBe(true);
expect(jQuery).toBeDefined();
});

});
Then teaspoon yields:

$ bundle exec rake teaspoon
Starting the Teaspoon server...
Teaspoon running default suite at http://127.0.0.1:61696/teaspoon/default
Error: Failed to load: http://127.0.0.1:61696/teaspoon/default?reporter=Console
rake aborted!

/Users/viddo/src/project/vendor/ruby/2.0.0/gems/teaspoon-0.7.7/lib/tasks/teaspoon.rake:5:in block in <top (required)>
Tasks: TOP => teaspoon
(See full trace by running task with --trace)
$ bundle exec rake teaspoon --trace
** Invoke teaspoon (first_time)
** Invoke environment (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute environment
** Execute teaspoon
Starting the Teaspoon server...
Teaspoon running default suite at http://127.0.0.1:61715/teaspoon/default
Error: Failed to load: http://127.0.0.1:61715/teaspoon/default?reporter=Console
rake aborted!

/Users/viddo/src/project/vendor/ruby/2.0.0/gems/teaspoon-0.7.7/lib/tasks/teaspoon.rake:5:in block in <top (required)>' /Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:236:incall'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:236:in block in execute' /Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:231:ineach'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:231:in execute' /Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:175:inblock in invoke_with_call_chain'
/opt/boxen/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in mon_synchronize' /Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:168:ininvoke_with_call_chain'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/task.rb:161:in invoke' /Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:149:ininvoke_task'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in block (2 levels) in top_level' /Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:ineach'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:106:in block in top_level' /Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:115:inrun_with_threads'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:100:in top_level' /Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:78:inblock in run'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in standard_exception_handling' /Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:75:inrun'
/Users/viddo/src/project/vendor/ruby/2.0.0/gems/rake-10.1.0/bin/rake:33:in <top (required)>' /Users/viddo/src/project/vendor/ruby/2.0.0/bin/rake:23:inload'
/Users/viddo/src/project/vendor/ruby/2.0.0/bin/rake:23:in `

'
Tasks: TOP => teaspoon
Is it be possible for teaspoon to give something more useful to identify this kind of error rather than just saying "Failed to load"? I would not mind to help out to implement this but wanted to see if this is a known issue, and if there are some efforts to solve this before.


Reply to this email directly or view it on GitHub.

@viddo
Copy link
Author

viddo commented Oct 11, 2013

Ah ok, I use Rails 4. I'll see if I can fix this.

Thanks for the prompt answer!

@jejacks0n
Copy link
Owner

Basically if an exception is thrown before the tests starts, teaspoon will display that and exit. So if you can figure out how to get sprockets-rails to generate the exception (outside of teaspoon) instead of a serving a 404 it will work how you'd expect.

Same goes for coffeescript that can't compile.


Jeremy Jackson

On Oct 11, 2013, at 9:39 AM, Nicklas Gummesson notifications@github.com wrote:

Ah ok, I use Rails 4. I'll see if I can fix this.

Thanks for the prompt answer!


Reply to this email directly or view it on GitHub.

@alisnic
Copy link

alisnic commented Oct 21, 2013

Also rails 4 complains with an error page if the db migrations were not applied, that causes bundle exec teaspoon to fail. Maybe there should be an option to display the html of the response on fail?

@jejacks0n
Copy link
Owner

@ALL, please check this by pointing your gem at master -- it at least handles migration exceptions, and I assume all others that happen before making it to the specs controller.

If possible, and for bonus point (nothing else really), it would be great to check this in rails 3 as well -- to make sure nothing blows up. If everything works well I'll release it.

@viddo
Copy link
Author

viddo commented Oct 22, 2013

More or less same error message as before, but w/o the rake aborted message:

$ bundle exec teaspoon
Starting the Teaspoon server...
Teaspoon running default suite at http://127.0.0.1:62202/teaspoon/default
Error: Failed to load: http://127.0.0.1:62202/teaspoon/default?reporter=Console

@jejacks0n
Copy link
Owner

Try requiring teaspoon/exception_handling at the bottom of your initializer. This shouldn't make a difference, but I would like to know.


Jeremy Jackson
303-507-6846

On Oct 22, 2013, at 5:07 AM, Nicklas Gummesson notifications@github.com wrote:

More or less same error message as before, but w/o the rake aborted message:

$ bundle exec teaspoon
Starting the Teaspoon server...
Teaspoon running default suite at http://127.0.0.1:62202/teaspoon/default
Error: Failed to load: http://127.0.0.1:62202/teaspoon/default?reporter=Console

Reply to this email directly or view it on GitHub.

@viddo
Copy link
Author

viddo commented Oct 22, 2013

That seemed to do the trick:

$ bundle exec teaspoon
Starting the Teaspoon server...
Teaspoon running default suite at http://127.0.0.1:51554/teaspoon/default
Error: Sprockets::FileNotFound: couldn't find file 'broken_file.js'
  (in /Users/viddo/src/project/app/assets/javascripts/application.js:1)
  # http://127.0.0.1:51554/teaspoon/default?reporter=Console:1

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

@jejacks0n
Copy link
Owner

Hmmm. I don't want you to have to include that file manually. Could you privately email me your application.rb and development.rb files? Assuming you're running teaspoon in the Dev env.


Jeremy Jackson

On Oct 22, 2013, at 10:15 AM, Nicklas Gummesson notifications@github.com wrote:

That seemed to do the trick:

$ bundle exec teaspoon
Starting the Teaspoon server...
Teaspoon running default suite at http://127.0.0.1:51554/teaspoon/default
Error: Sprockets::FileNotFound: couldn't find file 'broken_file.js'
(in /Users/viddo/src/project/app/assets/javascripts/application.js:1)

http://127.0.0.1:51554/teaspoon/default?reporter=Console:1

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

Reply to this email directly or view it on GitHub.

@viddo
Copy link
Author

viddo commented Oct 22, 2013

Running in dev env yes. I managed to narrow down the cause to be related to the better_errors gem and having setting config.eager_load = true.

You should be able to reproduce it by setting up a fresh Rails 4 project and apply this patch: https://gist.github.com/viddo/7104245 (the rest of application.rb and development.rb are the default settings).

@jejacks0n
Copy link
Owner

That would make sense.. the better_errors gem is hooking into the same area teaspoon tries to hook into. I'm hooking into the rails middleware that displays the errors, and if something else is changing that out from under teaspoon then there's not really much to do about it. In your specific case with better_errors, you're going to have to manually require the file, but people not using better_errors should be fine without it.

Thanks much for helping me clarify why it wasn't working for you out of the box.. It may be worth a mention in the wiki or something.

@bradrobertson
Copy link

We're getting the same error, just removed better_errors from our Gemfile and it still happens. The output we get when running bundle exec teaspoon is merely:

Starting the Teaspoon server...
Teaspoon running default suite at http://127.0.0.1:51237/teaspoon/default
cache: [GET /teaspoon/default?reporter=Console] miss
Failed to load: http://127.0.0.1:51237/teaspoon/default?reporter=Console

We're in the process of upgrading to rails 4, and we couldn't get the Konacha runner working on our CI machine so we're attempting a switch over to Teaspoon. Specs pass through the browser, but the runner just doesn't load up a server.

Can you suggest anything that would give us a bit more output about why it's failing?

@bradrobertson
Copy link

nm sorry, we've got some custom middleware that was blocking the runner.

It might be useful to document that the test runner is still mounted inside your normal rails app, so any custom middleware might affect the request to /teaspoon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants