Closed Trevoke closed 10 years ago
Jasmine-gem has had the ability to automatically run coffee script specs under Rails for a while now, but this won't help you too much since you're using Sinatra. See https://github.com/pivotal/jasmine-gem/commit/bfe9ad3d1e032bd39d227787afcd87ba1b864810. It would be interesting to think about how we might make this always work, regardless of which framework you're using. Are there any downsides to always adding a rack middleware for sprockets, other than a speed hit?
In that commit, there's a small bit of code where we add the rack middleware. I think adding that to your config would help, but I haven't been able to test this yet:
In your jasmine_helper.rb:
Jasmine.configure do |config|
config.add_rack_path(config.spec_path, lambda {
sprockets_spec_env = Sprockets::Environment.new
sprockets_spec_env.append_path config.spec_dir
sprockets_spec_env
})
end
@tjarratt I like the idea of not depending on Rails to compile our assets, since it breaks (almost) every time Rails gets an upgrade. That said, we need to 1) keep pace with the rails-sprockets and 2) support the ability to 'break' manifest files out into the files they reference to include into the page (for debugging purposes).
It worked, thanks!
The only thing it didn't do was convert the file from xSpec.coffee to xSpec.js ; of course, that doesn't matter to a browser and jasmine runs the file successfully.
Do you know how to convert the file name?
Ping: @stevennunez
@Trevoke I think the latest version of jasmine supports this with no changes -- if you name your file xSpec.js.coffee I think it will come through as xSpec.js... Re-open if you still have problems.
I am using Sinatra and I have a rack middleware (via https://github.com/bnadlerjr/hoboken ) that compiles my assets via sprockets, as such:
I would like to add this middleware to jasmine so it can compile test files written in coffee-script when I run the tests with
rake jasmine
. I could find no documentation on the topic, though I did findadd_rack_app
, but I couldn't quite figure out how to do it, other than I think it should be inside the jasmine_helper.rb file.If there is documentation, I'd love to be pointed to it. Otherwise, I'd love some help figuring this out.