From d31b0f7b30eaf6f1a0b28bd0fdcdaafb1b4417a6 Mon Sep 17 00:00:00 2001 From: Michael Kessler Date: Tue, 22 Jan 2013 23:02:12 +0100 Subject: [PATCH] Jasmine gem server doesn't respond to `/jasmine` path. (Fixes #102) --- CHANGELOG.md | 1 + lib/guard/jasmine.rb | 2 +- lib/guard/jasmine/cli.rb | 2 +- spec/guard/jasmine/cli_spec.rb | 14 ++++++++++++++ spec/guard/jasmine_spec.rb | 12 ++++++++++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa673d1..bd41630 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Master +- [#102](https://github.com/netzpirat/guard-jasmine/pull/102): Jasmine gem server doesn't respond to `/jasmine` path. - Switch coverage from [jscoverage](http://siliconforks.com/jscoverage/) to [Istanbul](https://github.com/gotwarlost/istanbul). - [#77](https://github.com/netzpirat/guard-jasmine/pull/77): Add coverage support. ([@alexspeller][]) diff --git a/lib/guard/jasmine.rb b/lib/guard/jasmine.rb index 39cb517..4b7676a 100644 --- a/lib/guard/jasmine.rb +++ b/lib/guard/jasmine.rb @@ -85,7 +85,7 @@ class Jasmine < Guard # def initialize(watchers = [], options = { }) options[:port] ||= Jasmine.find_free_server_port - options[:jasmine_url] = "http://localhost:#{ options[:port] }/jasmine" unless options[:jasmine_url] + options[:jasmine_url] = "http://localhost:#{ options[:port] }#{ options[:server] == :jasmine_gem ? '/' : '/jasmine' }" unless options[:jasmine_url] options = DEFAULT_OPTIONS.merge(options) options[:specdoc] = :failure if ![:always, :never, :failure].include? options[:specdoc] options[:server] ||= :auto diff --git a/lib/guard/jasmine/cli.rb b/lib/guard/jasmine/cli.rb index 743fa35..ca448d3 100644 --- a/lib/guard/jasmine/cli.rb +++ b/lib/guard/jasmine/cli.rb @@ -127,7 +127,7 @@ def spec(*paths) runner_options = { } runner_options[:port] = options.port || CLI.find_free_server_port - runner_options[:jasmine_url] = options.url || "http://localhost:#{ runner_options[:port] }/jasmine" + runner_options[:jasmine_url] = options.url || "http://localhost:#{ runner_options[:port] }#{ options.server.to_sym == :jasmine_gem ? '/' : '/jasmine' }" runner_options[:phantomjs_bin] = options.bin || CLI.which('phantomjs') runner_options[:timeout] = options.timeout runner_options[:server] = options.server.to_sym diff --git a/spec/guard/jasmine/cli_spec.rb b/spec/guard/jasmine/cli_spec.rb index bb6d2e4..4838cf0 100644 --- a/spec/guard/jasmine/cli_spec.rb +++ b/spec/guard/jasmine/cli_spec.rb @@ -238,6 +238,20 @@ end end end + + context 'when using the jasmine gem' do + it 'generates the default jasmine url' do + runner.should_receive(:run).with(anything(), hash_including(:jasmine_url => 'http://localhost:9876/')).and_return [true, []] + cli.start(['spec', '--port', '9876', '--server', 'jasmine_gem']) + end + end + + context 'when using the jasminerice gem' do + it 'generates the default jasmine url' do + runner.should_receive(:run).with(anything(), hash_including(:jasmine_url => 'http://localhost:9876/jasmine')).and_return [true, []] + cli.start(['spec', '--port', '9876', '--server', 'thin']) + end + end end context 'for non changeable options' do diff --git a/spec/guard/jasmine_spec.rb b/spec/guard/jasmine_spec.rb index 2f1710a..e1d9dc3 100644 --- a/spec/guard/jasmine_spec.rb +++ b/spec/guard/jasmine_spec.rb @@ -274,6 +274,18 @@ end end + context 'without the jasmine url' do + it 'sets the jasmine gem url' do + guard = Guard::Jasmine.new(nil, { :server => :jasmine_gem, :port => 4321 }) + guard.options[:jasmine_url].should eql 'http://localhost:4321/' + end + + it 'sets the jasminerice url' do + guard = Guard::Jasmine.new(nil, { :server => :thin, :port => 4321 }) + guard.options[:jasmine_url].should eql 'http://localhost:4321/jasmine' + end + end + context 'with run all options' do let(:guard) { Guard::Jasmine.new(nil, { :run_all => { :test => true } }) }