Closed lerarybak closed 7 years ago
Would it be better to be able to set config as parameter, and not just clear it?
The Jasmine gem lets you specify which config file to use with the JASMINE_CONFIG_PATH
environment variable. See https://github.com/jasmine/jasmine-gem#configuration. This should at least allow you to run the rake tasks multiple times each with a different config file (we actually do this ourselves when testing the gem).
@lerarybak what exactly are you needing to clear out and change between runs?
@slackersoft I need to clear at least two things.
1) We run tests consequentially in one process. When it exists from rake jasmine:ci
task first time the port, that was opened here https://github.com/jasmine/jasmine-gem/blob/master/lib/jasmine/server.rb#L16, is still listening. When the configuration from file was reloaded, the port stays the same, so at the second run it fails with port is in use
error. We don't want to configure it via
Jasmine.configure do |config| config.server_port = Jasmine.find_unused_port end
each time.
2) All the configuration, except port that wasn't rewritten by Jasmine.configure do end
stays the same. For example if I added rack path with add_rack_path
it won't be cleared on the second run.
@YurySolovyov Do you mean that the config should be passed as a parameter to rake jasmine:ci
task?
I meant that
def self.config=(value)
@config = value
end
...
Jasmine.config = nil # or some other variable
might be a bit more flexible and still allow resetting.
Actually it might be just exposing attr_accessor
instead of custom method.
I don't think we want to be mucking with the Jasmine config during the run of Jasmine, which is what this would let you do, even if not the intent. If you really need to execute the jasmine:ci
rake task multiple times in a single rake
command, I would rather try to make sure the server gets shut down and releases the port correctly, than require a user doing this to know to clear out and re-set the config. If you don't need to do all this in a single rake
task, allowing the process to exit before starting the next browser up, should solve the issue as well.
Hope this helps. Thanks for using Jasmine!
We haven't heard anything more on this issue in a while, so I'm going to close it. Thanks for using Jasmine!
We need to run jasmine specs multiple times in multiple engines, so it is needed to clear the Jasmine config each time to avoid mixing up engines configs. Now we use
Jasmine.instance_variable_set(:@config, nil)
, but it doesn't feel well.