Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fixtures not loading properly? #4

jondkinney opened this Issue · 17 comments

9 participants


I'm trying to get fixtures working, but having issues.

In my gemfile (in the development & test group):

gem 'jasmine-rails'
gem 'jasmine-jquery-rails'

I have the following folder structure:

My fixture: /spec/javascripts/fixtures/order_form.html

Jasmine Spec Helper: /spec/javascripts/helpers/

in my

#=require jquery
#=require jasmine-jquery

Things seem to be loading

screen shot 2013-09-03 at 10 46 55 pm

But the test fails with a 404 fixture file now found.


If I go into the error I am presented with the following error on the 404 itself:

<h1>Routing Error</h1>
<p><pre>No route matches [GET] &quot;/spec/javascripts/fixtures/order_form.html&quot;</pre></p>
  Try running <code>rake routes</code> for more information on available routes.

I've also tried adding this to my (though I'm not sure why this would be required).

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

And while it made the 404 go away, the spec doesn't pass like it should because I still don't think the fixture is being loaded properly. I say this because it's un-modified code from Railscasts that I know should pass. I'm just trying to test to make sure everything is wired up properly!

My spec/javascripts/support/jasmine.yml file is very minimal per the suggestion of

# minimalist jasmine.yml configuration when leveraging asset pipeline
  - "**/*[Ss]pec.{js,coffee}"

Any help would be greatly appreciated!


So I ended up just using jasmine-fixtures instead. However, this is still a problem that probably should be fixed. I'm happy to help so I'll leave this open.


I'm experiencing this problem now. Any assistance would be appreciated.


@wndxlori I never found a solution unfortunately. I just switched to using jasmine-fixtures instead. Hopefully someone will come along that can get this sorted...


Giving a bump to this problem because I'm having exactly the same issue. Rails 3.2.11. I'm using a more expansive jasmine.yml file than the original poster -- mine comes almost exactly from the jasmine documentation -- but I've tried the minimal version too with no luck. Jasmine-fixtures doesn't seem to be a solution for me, because I'm trying to test json server returns.

I read the previous closed issue which involved jasmine-rice. I'm not using jasmine-rice. I'm using the gem 'jasmine-rails' followed by gem 'jasmine-jquery-rails', and gem 'sinon-rails'. (gem 'jquery-rails' is above in my gemfile.) I pulled the sinon rails gem as a test, but it didn't resolve the issue.


Christopher, you might also be interested in

I almost started using that, but in the end, jasmine-fixtures did the job, although I really would have preferred to continue to use jasmine-jquery-rails fixtures.


Hey y'all there was a bug in the pipeline that was fixed in v3.2.13. Upgrade Rails to v3.2.13 and it's fixed. There's no problem with this gem.


@travisjeffery I was running either Rails 3.2.13 or 3.2.14 when I filed this issue.


find the exact rails version. same with ruby.

clone this and see if it works for you:


I'm seeing the same problem... fixture not found. Using Rails4. Error message is:
ActionController::RoutingError (No route matches [GET] "/spec/javascripts/fixtures/home_fixture.html")

How does Rails know that this is not a route to be interpreted but a file to be loaded (like an asset?).

I tried the jasmine-jquery-rails-issue-4 app and it works, but I couldn't get it working under Rails4.

Under Rails4 the 'rake jasmine' task for jasmine-jquery-rails-issue-4 can't be found. I haven't figured out why.


I come with a temporary solution that works well for me. While waiting for a better solution

I am using a standard installation with

  • rails 4.0.1
  • jasmine-rails 0.5.0
  • jasmine-jquery-rails 1.5.9

The idea is to mount the directory spec/javascripts/fixtures through the routes.rb file to give jasmine access to fixture files through the /spec/javascripts/fixtures URI

Create an initializer, ex /initializers/jasmine_fixtures.rb

# Map fixtures directory for Jasmine suite
if defined?(Jasmine::Jquery::Rails::Engine)
  JasmineFixtureServer = do |env|'spec/javascripts/fixtures').call(env)

Part of route.rb

  # Mount Jasmine engine
  mount JasmineRails::Engine => '/specs' if defined?(JasmineRails)

  # mount spec/javascripts/fixtures directory
  mount JasmineFixtureServer => '/spec/javascripts/fixtures' if defined?(Jasmine::Jquery::Rails::Engine)

yes that works, Randoum, thank you very much.

A tiny bit simpler still is to mount the JasmineFixtureServer at "spec/javascripts/fixtures", as this is the default fixture path. Then you don't have to include the "beforeEach" statement.

I can imagine that your approach could be included in the jasmine-jquery-rails engine as a permanent solution but I wasn't able to figure out how to do it.


Yes off course, assign the path at your convenience. I updated my previous comment to make it clearer for the next persons that would be looking for this solution. Can you please verify/confirm it's correct cause I did not test it like this.

I tried as well to mount the path from jasmine-jquery-rails engine, but I know nothing about Rails engines :) Let's wait for a skilled guy to pass-by


Yes, Randoum, you have it correct. Thanks again.

@sgharms sgharms referenced this issue from a commit in pocket-gophers-2014/zombify
Steven G. Harms Egregious hack to get Jasmine-Jquery fixtures working
Carolyn and I worked for a bit on Friday trying to
get the fixtures to be seen per the specification
in jasmine-jquery-rails.  We were unsuccessful.
It appears that the issue is that the fixtures
path is not made available on the web server.

This was listed as a bug here:


The solution, implemented here, is to define a new
Rack middleware in an initializer
(`JasmineFixtureServer`) which serves assets out
of the physical file directory

We then `mount` that engine at the URL path of
`spec/javascripts/fixtures`.  Thus we can "serve"
our fixtures (yay).

This seems like a bug to me on jquery-rails, but
this will keep things going.

So.. Is this how we should set up loading fixtures from now on?

@nathany nathany referenced this issue in searls/jasmine-rails

Unable to run Jasmine tests with fixtures #123


@randoum, thanks a lot! Your approach got me running.

Just want to note that I'm not using jasmine-jquery-rails, but jasmine-jquery. By changing if defined?(Jasmine::Jquery::Rails::Engine) to if defined?(JasmineRails), I made it work for my stack.


We had the same problem. We also wanted to be able to import application styles for particular components into the fixture styles so that if they were changed in a way that broke the component, the tests would fail. We also wanted to be able to use the less css compiler in our fixture styles.

Building on @randoum's idea above, we set up a Sprockets environment and mounted that. The basic result uses the same changes to routes.rb but the initializer looks something like this

# Setup Sprockets environment for serving Jasmine fixtures
JasmineFixtureServer =

JasmineFixtureServer.append_path 'app/assets/stylesheets'
JasmineFixtureServer.append_path 'spec/javascripts/fixtures'

JasmineFixtureServer.logger = Rails.logger

# Copy over the less configuration from the application
JasmineFixtureServer.context_class.class_eval do
  class_attribute :less_config
  self.less_config = Rails.application.config.less
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.