testdouble / jasmine-rails

A Jasmine runner for rails projects that's got you covered in both the terminal and the browser
http://rubygems.org/gems/jasmine-rails
MIT License
378 stars 154 forks source link

trouble running tests from CLI #141

Closed mpelzsherman closed 9 years ago

mpelzsherman commented 10 years ago

rails 3.2, ruby-1.9.3-p327, phantomjs 1.9.7, jasmine-rails v0.10.0

Hitting http://localhost:3000/jasmine in a browser works fine, but running from the command line does not find the tests and yields an error.

Here is the output from bundle exec rake spec:javascript. Any suggestions would be greatly appreciated!

WARNING: Nokogiri was built against LibXML version 2.9.1, but has dynamically loaded 2.9.0
Running `"/usr/local/bin/phantomjs" "/Users/mpelzsherman/source/rentals/vendor/ruby/1.9.1/gems/jasmine-rails-0.10.0/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "/Users/mpelzsherman/source/rentals/tmp/jasmine/runner.html?spec="`
Running: /Users/mpelzsherman/source/rentals/tmp/jasmine/runner.html?spec=
Starting...

Finished
-----------------
0 specs, 0 failures in 0s.

ConsoleReporter finished
ERROR: Error: Script error
http://requirejs.org/docs/errors.html#scripterror
TRACE:
 -> file:///Users/mpelzsherman/source/rentals/tmp/jasmine/assets/require.js: 1759
 -> file:///Users/mpelzsherman/source/rentals/tmp/jasmine/assets/require.js: 523 (in function "onError")
 -> file:///Users/mpelzsherman/source/rentals/tmp/jasmine/assets/require.js: 1629
rake aborted!
Error executing command: "/usr/local/bin/phantomjs" "/Users/mpelzsherman/source/rentals/vendor/ruby/1.9.1/gems/jasmine-rails-0.10.0/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "/Users/mpelzsherman/source/rentals/tmp/jasmine/runner.html?spec="
AntiFish03 commented 9 years ago

I have the same issue and I can tell you the problem is that the files being loaded by requirejs have not being copied to the tmp/jasmine folder, and the runner.rb is trying to compile all the JS assets into a single file which won't work without running r.js and doing a custom optimized file. Which could affect the code we are trying to test. So we need the full asset pipeline running or to copy all js assets to the tmp/jasmine.

@searls, Is there a way that we can stop trying to do the optimize to a single file and just copy all app/assets/javascripts and vendor/assets/javascript to the tmp/jasmine or allow asset pipeline to run completely like it does in the browser?

AntiFish03 commented 9 years ago

@mpelzsherman, I made the changes needed to actually use requirejs properly... Check out the pull request.

searls commented 9 years ago

Closing this because I don't intend to support require.js in jasmine-rails going forward. Sorry!

mpelzsherman commented 9 years ago

Thanks anyway @AntiFish03 ! I'll check out your PR - could be useful for me since we are stuck with require.js for now.