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

Path to fixtures has extra "/jasmine" #42

Open
buruzaemon opened this issue Apr 9, 2012 · 4 comments
Open

Path to fixtures has extra "/jasmine" #42

buruzaemon opened this issue Apr 9, 2012 · 4 comments

Comments

@buruzaemon
Copy link

Hello to the jasminerice team!

First off, thanks for creating a great gem! My team are greatly enjoying being able to write unit tests for the Coffeescript in our Rails project using Coffeescript.

I am having an issue running my tests at [localhost]/jasmine, however. Without explicit patching, I see errors like this:

Error: Fixture could not be loaded: jasmine/fixtures/kaiso.html (status: error, message: undefined) in http://localhost:3000/assets/jasmine-jquery-1.3.1.js?body=1 (line 105)
  ([object Object],"error","Not Found ")@http://localhost:3000/assets/jasmine-jquery-1.3.1.js?body=1:105
  ([object Object],[object Array])@http://localhost:3000/assets/jquery.js?body=1:1076
  ([object Object],[object Array])@http://localhost:3000/assets/jquery.js?body=1:1194 done(404,"Not Found "...

Firebug shows that the request URL for the errors were coming from the request to get to my fixtures with No route matches [GET] "/jasmine/jasmine/fixtures/kaiso.html"

I was able to get my tests running by hacking line 34 in jasmine-jquery-1.3.1js to look like this.fixturesPath = 'fixtures';, to remove that extra /jasmine in the URL.

Has anyone ever seen any behavior like this? Are there perhaps some configurations I am missing?


For the record, here are my routes for Jasmine:

jasminerice        /jasmine                                       Jasminerice::Engine
Routes for Jasminerice::Engine:
           GET /spec/:spec_id/fixtures/:filename(.:format) jasminerice/spec#fixtures
spec_index GET /spec(.:format)                             jasminerice/spec#index
               /fixtures/:filename(.:format)               jasminerice/spec#fixtures
      root     /                                           jasminerice/spec#index

And the details of my environment:

  • WinXP
  • jruby 1.6.7 (ruby-1.9.2-p312) (2012-02-22 3e82bc8) (Java HotSpot(TM) Client VM 1.6.0_13) [Windows XP-x86-java]
  • Rails 3.2.3
  • jasmine 0.0.8
@tsmacdonald
Copy link

I'm having the same issue. Here's my directory structure:

$ tree spec/javascripts/
spec/javascripts/
├── dropdown_spec.js.coffee
├── fixtures
│   └── home.html
├── spec.css
└── spec.js.coffee

And here's part of dropdown_spec:

describe "dropdown", ->
  beforeEach ->
    loadFixtures("home.html")

Which results in the following:

Error: Fixture could not be loaded: jasmine/fixtures/home.html (status: error, message: undefined)

I've tried messing around with jasmine.getFixtures().fixturesPath, but have yet to make it work.

@tsmacdonald
Copy link

Update: I added this to spec.js.coffee which solved the problem:

  jasmine.getFixtures().fixturesPath = 'assets/fixtures';

I can submit a pull request to change that in jasmine-jquery-*.js, but since buruzaemon had a similar-but-different fix I'm wondering if the precise path depends on something specific to the project. That is, I'm not familiar enough with the assets pipeline to know if I have a universal solution or not.

@bradgreens
Copy link

👍 thanks @tsmacdonald, your configuration helped me out

@bsimpson
Copy link

Thanks @tsmacdonald this helped me. I've discovered that when using fixtures, I cannot use the manifest require_tree ./ as this causes the fixtures to get concatenated into the spec.js file. I had to explicitly list subdirectories under spec/javascripts/ omitting the fixtures directory. e.g.:

$ tree spec/javascripts
spec/javascripts/
├── core
│   ├── core_data_spec.js
├── fixtures
│   ├── core
│   │   └── web_form.html.haml
├── spec.js
└── views
    └── base_spec.js

# in spec.js
...
require_tree ./core
require_tree ./views

jasmine.getFixtures().fixturesPath = 'assets/fixtures';

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