Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specifying URL query parameters in the jasmine_url option #174

Closed
kbullaughey opened this issue Sep 11, 2014 · 6 comments
Closed

specifying URL query parameters in the jasmine_url option #174

kbullaughey opened this issue Sep 11, 2014 · 6 comments

Comments

@kbullaughey
Copy link

I use jasminerice with guard-jasmine and the jasmine docs suggest that my specs will load much faster if I set debug=true in a query parameter:

http://localhost:3000/jasmine?debug=false

Wanting to do this when running the specs with guard-jasmine I tried adding the following options:

port: 55998, jasmine_url: 'https://localhost:55998/jasmine?debug=false'

However, this didn't work because when running individual specs it ended up like this:

https://localhost:55998/jasmine?debug=false?spec=SomeSpecs

And the whole set run.

It would be helpful if Guard::Jasmine::Runner.query_string_for_suite checked for whether the url already contains any query parameters and begins the encoded_url with either ? or & accordingly.

I resorted to the following hack, that I placed in the end of my Guardfile:

module ::Guard::Jasmine::Runner
  class << self
    unless method_defined? :query_string_for_suite
      alias_method :orig_query_string_for_suite, :query_string_for_suite
    end
    def query_string_for_suite(*args)
      encoded_url = orig_query_string_for_suite *args
      if encoded_url =~ /^\?/
        encoded_url = encoded_url.sub /^\?/, "?debug=false&"
      else
        encoded_url = "?debug=false"
      end
      encoded_url
    end
  end
end

Is there a less hacky way to accomplish this? Or does it require a change to guard-jasmine? I'm not familiar with the spectrum of typical configurations and runner combinations to know whether this is the right place for such a change.

Thanks!

@nathanstitt
Copy link
Member

That's a great idea. Let me see what I can work up. My current focus is on the jasmine-2 branch, but it's stalled temporarily while I wait for an upstream fix on Jasmine.

I'll update here once I have something implemented so you can test it.

Do you have a reference for the debug=false running faster? I'm not opposed to setting query parameters, I just hadn't heard of that before.

Thanks for the suggestion

@kbullaughey
Copy link
Author

It's mentioned in the section Asset Debugging in the Jasminerice readme.

I have hundreds of javascript files in my project and running a single spec file with a single spec using ?spec=SomeSpec takes 15-20 seconds without debug=false and only 5 seconds with it. Jasmine says the spec itself only too a second to run, but it's the whole turnaround that matters during development.

I wasn't able to enable set config.assets.debug = false in my rails environment because it messed up the JSON fixture requests of jasmine-jquery, which I think was related to cross-site scripting security protections of phantomjs.

nathanstitt added a commit that referenced this issue Nov 18, 2014
As suggested in #174, allow specifying query_parameters for passing
options to the specs.

Adds a new option `:query_params`, which can be set to a hash that is url
encoded and passed to the PhantomJS runner
@nathanstitt
Copy link
Member

@kbullaughey Took me a bit, but I've just implemented this. Please give it a whirl and let me know how it works for you.

@kbullaughey
Copy link
Author

Hm...Seems I won't be able to test it yet because I haven't upgraded my specs to jasmine 2. Thanks for making this change! Just looking at the patch it looks like it should do the trick. Hopefully I'll get around to updating to jasmine 2 soon. I tried once before, but the new async strategy was causing problems with Ember.

@nathanstitt
Copy link
Member

I'm pruning old issues I hope the new version worked for you, please open a new issue if you're still having problems

@kbullaughey
Copy link
Author

Ah. No worries. I switched away from using Jasmine because QUnit was better supported for Ember at the time. Appologies for the dangling issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants