Closed almagest closed 7 years ago
You need jasmine-jquery https://github.com/velesin/jasmine-jquery#html-fixtures
gem 'jasmine-jquery-rails'
I haven't gotten much further due to NETWORK_ERR: XMLHttpRequest Exception mentioned in the README: https://github.com/searls/jasmine-rails#ajax--xhrs.
I don't know how to specify --allow-file-access-from-files
or --web-security=no
when running rake spec:javascript
.
It would be nice to get our tests passing again (coming from Teaspoon) before transitioning to something like https://github.com/searls/jasmine-fixture.
The following gets fixtures working the web UI: https://github.com/travisjeffery/jasmine-jquery-rails/issues/4#issuecomment-29684484
If https://github.com/searls/jasmine-rails/blob/master/lib/jasmine_rails/runner.rb#L21 passes the argument "--web-security=no
" to phantomjs, the XMLHttpRequest Exception is solved... but then onto another issue:
Error: Fixture could not be loaded: spec/javascripts/fixtures/name.html (status: error, message: undefined)
I also experimented with https://github.com/searls/jasmine-fixture but had some initial trouble getting it to load from helpers. (or at least, affix wasn't defined)
As pointed out on Stack Overflow, the problem here is that fixtures are being loaded relative to tmp/jasmine
(where the runner is) rather than relative to the Rails.root.
http://stackoverflow.com/questions/21763470/jasmine-jquery-loadfixtures-with-jasmine-2-0-wont-work
It turns out that --web-security=no
was unnecessary.
I added this to spec_helper.js.coffee:
# rake spec:javascript loads specs relative to the tmp/jasmine/runner.html, need to override:
jasmine.getFixtures().fixturesPath="../../spec/javascripts/fixtures"
Thank you @nathany! Helped me a lot! :heart: :grin:
You’re welcome. ;-)
@nathany thank you very much!!!! :+1:
Please have a look to my PR https://github.com/travisjeffery/jasmine-jquery-rails/pull/12. It will add jasmine-jquery fixture support for Rails without special configs necessary and it even supports HAML!
It seems like I can only choose to run the specs on the command line or via http://localhost:3000/specs
using the solution above.
jasmine.getFixtures().fixturesPath = "../../spec/javascripts/fixtures";
It would be nice to conditionally load the fixtures based on whether it was via the browser or the command line. I'll look into that.
Hi, @ccallebs, were you able to figure out how to make it run for both command line and via browser? I am running into the same problem.
@enkanba I never was -- we just settled on the command line. Sorry :(
(Maybe) fixed by #216
Hi,
I'm attempting to use jasmine-rails to process coffeescript (both code & tests), but I keep seeing "ReferenceError: Can't find variable: Regions in [...]/tmp/jasmine/assets/jasmine-specs.js (line 10723)". I check the compiled jasmine-specs.js file and I see Regions defined before line 10723. Can you offer any suggestions on how to get these tests running? Also, let me know if you need to see anything else. Thanks.
Relevant gems in use:
Includes:
Failing test (settings_spec.js.coffee):