Skip to content

Commit

Permalink
Jasmine gem server doesn't respond to /jasmine path. (Fixes #102)
Browse files Browse the repository at this point in the history
  • Loading branch information
netzpirat committed Jan 22, 2013
1 parent 18a1689 commit d31b0f7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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][])

Expand Down
2 changes: 1 addition & 1 deletion lib/guard/jasmine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/guard/jasmine/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions spec/guard/jasmine/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions spec/guard/jasmine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }) }

Expand Down

0 comments on commit d31b0f7

Please sign in to comment.