-
Notifications
You must be signed in to change notification settings - Fork 275
jasmine_config.rb is not read in Jasmine 1.3.1 #120
Comments
Just hit the same issue. There doesn't appear to be any way currently to set, for example, the selenium browser in jasmine:ci task. |
Support for jasmine_config.rb was removed intentionally because we don't want the gem to look for a 'magic' file on your filesystem (and we also really want to discourage people monkey-patching Jasmine::Config as a way of changing Config behavior -- the hope was with the refactor that config supports everything end users were likely to need). What was unintentional was doing such a bad job of documenting/announcing these changes. After Jasmine has been required, there is a Configuration singleton you can access in the following manner:
What hasn't really been figured out yet is where the best place for this configuration to happen. If you have a Rails app, you may just be able to add an initializer that does this because we should be booting the Rails env (although there might be some dependency order issues here that force you to require 'jasmine' yourself). More than happy to take suggestions here. If there's other needs that the jasmine_config.rb file was fulfilling that you don't think you'll be able to do with the config block or an initializer, please let us know -- perhaps the config needs to also support arbitrary pre-server startup callbacks, although we want to keep responsibilities generic and at a minimum. FWIW, many (although not all) ENV variables have been pulled. We don't want to manage "magic" env variables either, it will be the end users responsibility to use ENV vars over simple strings if they have the need. |
We use vcr/webmock to intercept http connections. It works great except we also use a selenium build grid to run the tests, so that is one http connection that has to be allowed to work. Our jasmine_config.rb file has the VCR configuration necessary to allow that connection. I don't think an initializer will work in this case because we don't want that jasmine-only configuration alongside the rest of the application configuration. I suppose it could go into the environments/test.rb file? |
Looking at the code in
There's no opportunity between the loading of the yaml, the assignment of the config, and the creation of the driver to inject any additional configuration options. The only option I can see is to write my own independent rake task for CI; not a huge burden, but more than seems necessary. It seems like this may be a slightly different problem to the one @ebarendt is experiencing, so apologies if this is turning into a bit of a thread hijack. |
Right; no, i think this is a similar problem and I don't mind keeping the discussion in this thread. This is a tricky problem to solve if we want to avoid require-ing a magic file (which right now, I think we'd like to continue doing). The run_specs file essentially runs in a 'new' environment where you don't really have any hooks to fire off a config block. I'm happy to take suggestions here. In the near future we're hoping to eliminate the need for rspec entirely (we're mostly using it for formatting/exit codes), so this should be less of an issue (since we won't shell out to rspec). |
FWIW, we need to run rspec before jasmine anyway to create our test fixtures. |
I don't feel like jasmine_config.rb is a magic file if it's documented. Right now, it's mentioned, but nothing else about it. The environment variables, yeah - those should probably live in jasmine_config.rb too. Or how about mirroring Rails: |
You could avoid a magic file by having the user modify the It might even make sense for this file to perform the YAML load, as it would the open to door to managing config in alternative manners (e.g. in pure ruby or JSON) where that makes sense. Then you'd have something that looked like:
and within If you don't pull the YAML load out, you'd simply have to make sure that the Jasmine.config method (or a suitably named alternative) stash away the config information supplied in a way it can be picked up again by the |
I may be too harsh on jasmine_config.rb because early on we were suggesting that users configure jasmine by overriding the Jasmine::Config object, which is a Very Bad Idea™. I suppose I might feel less hateful towards it if we called it jasmine_helper.rb or the like, and perhaps that's simpler (and really, more sensible) solution here. I'll have to give it some thought. ctucker, thanks for the suggestion. I'm currently thinking a Rake task dependency might be a good way to permit users to run arbitrary code, but there's a couple issues we face here.
Let me also briefly talk about why eliminating rspec as a dependency is a goal: outside of Rails, one of the biggest pain points in jasmine-gem maintenance is the rspec formatter, because it needs to stay current with rspec changes (and because we're maintaining backwards compatibility with rspec 1 and rails 2, but that's a whole other tangle). The problem isn't really that users don't have rspec installed, rather it's that they do, and they want it to be current -- if Jasmine is broken on a new version of rspec, it's usually an on-fire thing that end-users want a fix for pretty quickly. My current belief is that the jasmine-gem should be agnostic about how results are formatted. I'd like to provide a sensible default that works for most CI systems in place (probably something that dumps plain-text w/ an exit code and then also writes out a jUnit XML file) and then allow end users to add on jasmine formatters as desired, just like rspec. Then someone else who understands rspec a little better than I do can maintain the rspec-jasmine bridge. ;) Lastly, the rspec formatter is also just plain weird -- we've technically already ran a test suite, and then we take the results of that and build up a new one in memory, with bodies that essentially reflect the pass/fail of the current test suite results, and then execute it. We're running two test suites to show you results, when we could just say, hey, here are the results. At the time the jasmine-gem was written, there were some benefits to running the results through rspec, but I'm not sure those are quite as prominent. |
Jasmine HEAD should now load spec/support/jasmine_helper.rb after the jasmine.yml settings are parsed -- this should provide a convenient place to add a Jasmine.configure block. I think this should meet most needs that were formally provided by jasmine_config.rb. You can also configure the path of this file in jasmine.yml if desired. |
I load jasmine_config.rb in a rake task and add it as a dependency of 'jasmine:require': # lib/tasks/jasmine_config.rake
namespace :jasmine do
task :config do
load Rails.root.join('spec/javascripts/support/jasmine_config.rb')
end
end
task "jasmine:require" => ["jasmine:config"] |
A bit late to the game here, but I'm having issues transitioning to this new way of configuring things. I'm still stuck on Rails 2.3.x and I'm using Jammit to package my assets. Before, I was using the (evil?) method of monkey patching Jasmine::Config to do the following...
This loads my JST files, which are necessary for my tests. Sadly with the new jasmine_helper.rb file I get Ruby complaining: 'uninitialized constant Jammit' ...which looks to me like the Rails env isn't loaded - because I have the gem included via bundler. Can anyone give me a pointer to get me on track again here? |
Commit 76b7cde removes the ability to run any code before executing the specs (run_specs.rb). The documentation still refers to this file. What's the replacement for this behavior? Was it removed accidentally.
The text was updated successfully, but these errors were encountered: