Skip to content

Commit

Permalink
adding :server_mount option
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstrickland committed Jun 26, 2013
1 parent bf59cf7 commit ebe5a51
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/guard/jasmine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Jasmine < Guard
server: :auto,
server_env: ENV['RAILS_ENV'] || 'development',
server_timeout: 60,
server_mount: '/jasmine',
port: nil,
rackup_config: nil,
jasmine_url: nil,
Expand Down Expand Up @@ -91,7 +92,7 @@ def initialize(watchers = [], options = { })
options[:port] ||= Jasmine.find_free_server_port
options[:server] ||= :auto
options[:server] = ::Guard::Jasmine::Server.detect_server(options[:spec_dir]) if options[:server] == :auto
options[:jasmine_url] = "http://localhost:#{ options[:port] }#{ options[:server] == :jasmine_gem ? '/' : '/jasmine' }" unless options[:jasmine_url]
options[:jasmine_url] = "http://localhost:#{ options[:port] }#{ options[:server] == :jasmine_gem ? '/' : options[:server_mount] }" unless options[:jasmine_url]
options[:specdoc] = :failure if ![:always, :never, :failure].include? options[:specdoc]
options[:phantomjs_bin] = Jasmine.which('phantomjs') unless options[:phantomjs_bin]

Expand Down
6 changes: 6 additions & 0 deletions lib/guard/jasmine/phantomjs/guard-jasmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

page.onConsoleMessage = function(msg, line, source) {
var result;

if (/^RUNNER_END$/.test(msg)) {
result = page.evaluate(function() {
return window.reporter.runnerResult;
Expand Down Expand Up @@ -62,6 +63,7 @@

page.open(options.url, function(status) {
var done, error, runnerAvailable, text;

page.onLoadFinished = function() {};
if (status !== 'success') {
console.log(JSON.stringify({
Expand All @@ -80,6 +82,7 @@
} else {
text = page.evaluate(function() {
var _ref;

return (_ref = document.getElementsByTagName('body')[0]) != null ? _ref.innerText : void 0;
});
if (text) {
Expand All @@ -105,19 +108,22 @@

waitFor = function(test, ready, timeout) {
var condition, interval, start, wait;

if (timeout == null) {
timeout = 5000;
}
start = new Date().getTime();
condition = false;
wait = function() {
var error, text;

if ((new Date().getTime() - start < timeout) && !condition) {
return condition = test();
} else {
if (!condition) {
text = page.evaluate(function() {
var _ref;

return (_ref = document.getElementsByTagName('body')[0]) != null ? _ref.innerText : void 0;
});
if (text) {
Expand Down
10 changes: 9 additions & 1 deletion lib/guard/jasmine/phantomjs/lib/console.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion lib/guard/jasmine/phantomjs/lib/reporter.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions lib/guard/jasmine/phantomjs/lib/result.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion spec/guard/jasmine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
guard.options[:server_timeout].should eql 60
end

it 'sets a default :server_mount option' do
guard.options[:server_mount].should eql defaults[:server_mount]
end

it 'finds a free port for the :port option' do
Guard::Jasmine.should_receive(:find_free_server_port).and_return 9999
guard = Guard::Jasmine.new
Expand Down Expand Up @@ -166,6 +170,7 @@
server: :jasmine_gem,
server_env: 'test',
server_timeout: 20,
server_mount: '/foo',
port: 4321,
rackup_config: 'spec/dummy/config.ru',
jasmine_url: 'http://192.168.1.5/jasmine',
Expand Down Expand Up @@ -204,6 +209,10 @@
guard.options[:server_timeout].should eql 20
end

it 'sets the :server_mount option' do
guard.options[:server_mount].should eq '/foo'
end

it 'sets the :port option' do
guard.options[:port].should eql 4321
end
Expand Down Expand Up @@ -303,10 +312,15 @@
guard.options[:jasmine_url].should eql 'http://localhost:4321/'
end

it 'sets the jasminerice url' do
it 'sets the jasminerice url by default' do
guard = Guard::Jasmine.new(nil, { server: :thin, port: 4321 })
guard.options[:jasmine_url].should eql 'http://localhost:4321/jasmine'
end

it 'sets the jasmine runner url as configured' do
guard = Guard::Jasmine.new(nil, { server: :thin, port: 4321, server_mount: '/specs' })
guard.options[:jasmine_url].should eql 'http://localhost:4321/specs'
end
end

context 'with run all options' do
Expand Down

0 comments on commit ebe5a51

Please sign in to comment.