Closed ekryski closed 10 years ago
So, it works for me, and I'll provide you the relevant examples so you can see how I'm using them.. you'll notice in this example that I preload it, because I'm stubbing ajax requests, which impedes the ability to load the fixture. You may need to do the same thing?
Preload the fixture (this is only needed if you plan on stubbing ajax): https://github.com/jejacks0n/mercury/blob/mercury2/spec/mercury/views/modules/form_handler_spec.coffee#L6
Load the fixture: https://github.com/jejacks0n/mercury/blob/mercury2/spec/mercury/views/modules/form_handler_spec.coffee#L107
My fixture: https://github.com/jejacks0n/mercury/blob/mercury2/spec/fixtures/form.html
Where I override the default Teaspoon fixture path: https://github.com/jejacks0n/mercury/blob/mercury2/config.ru#L34
Hope that helps.
Hmm. Yep unfortunately I have pretty much the exact same setup, and it still doesn't work. In fact it seems to be an issue with .js, .css, and .html extensions. If I do .html.erb it works, .json works. I think this is the behaviour of rails that it looks to find your "static" assets inside of public. This may explain why https://github.com/thoughtbot/high_voltage expects you to give your static pages .html.erb extensions.
I'd love to accept that as a reason, but it works for me, so that reasoning doesn't make sense.
https://github.com/jejacks0n/mercury/blob/mercury2/Gemfile.lock#L86
Yep. You are totally right. I found out now that we are using Rack::Zippy in place of Action::Dispatch which forces those files to the public directory. Not your problem :smiley:. I've created an issue over there https://github.com/eliotsykes/rack-zippy/issues/7
Wait.. one sec.. so, you think that they're being loaded via the asset pipeline I think -- this is not true.
Rack::Zippy may be the problem, but I tend to think not. Here's why:
https://github.com/modeset/teaspoon/blob/master/config/routes.rb#L2 https://github.com/modeset/teaspoon/blob/master/app/controllers/teaspoon/spec_controller.rb#L27
You can see that it's not serving them as assets at all -- it's using a controller and route to serve those (the readme explicitly states this so you can use things like haml, erb, etc.). I thought that was clear, but that's ok.. I'd close your issue over on Rack::Zippy potentially, unless you're absolutely sure that it's causing an issue, though I think it may not be the case.
What path are you accessing your fixture at? It should be relative to whatever path you've configured for your fixtures.. since that route is being hit, and no assets are being served this may make more sense to you.
Also worth noting, that teaspoon routes are prepended, but it may be true that Rack::Zippy is doing something odd, since it's middleware. So I don't know. =)
Rack::Zippy doe a weird thing where it takes over all of the asset-looking requests in the application via middleware, so it wouldn't be 100% surprising if that was the issue here. At least, it's bitten me before. See https://github.com/eliotsykes/rack-zippy/blob/master/lib/rack-zippy.rb#L87
Yup, the fixture path is under a path registered as an asset path.. I might change your fixture path to something outside of spec/javascripts ... maybe spec/javascript_fixtures, or spec/fixtures/javascript? That would allow you to get around the issue, because it seems pretty core to Rack::Zippy.
I'm 100% sure rack zippy is the issue. Moving the middleware swap to only our production config allowed me to load the fixtures through teaspoon no problem. @jejacks0n I had already looked into the routes :wink:. Put binding.pry's all over the place.
Thanks again for sorting out the issue. much appreciated. =) Sorry.
@jejacks0n I already tried switching my fixtures_path to spec/fixtures/javascript
when using rack zippy. Didn't change anything. Gonna stick with what works here. Thanks for the attention. Much appreciated!
Rack-zippy dev here, just wanted to drop in and say thanks for the discussion of the issue, it looks like it might be a problem for quite a few people but I expect we can do something about it. Discussion for those interested is at the issue @ekryski kindly opened: https://github.com/eliotsykes/rack-zippy/issues/7
Loving teaspoon but can't get any html fixtures to get loaded. All I end up getting is a
not found
error. I have my fixtures and myfixtures_path
set to "spec/javascripts/fixtures".I used pry to spelunk the teaspoon routes and when requesting an html fixture it doesn't even make it into the fixtures route. I tried it requesting 'foo.json' in my fixtures and it gets served up just fine.
I'm assuming that rails is intercepting .html file requests before they even hit the routes. Not sure how to get around that. If there is any light you could shed on the situation it would be much appreciated!