Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Enable the `:auto` server to detection unicorn, thin and mongrel. (Fi…

…xes #82)
  • Loading branch information...
commit 9f0f879242c66913dcb75180dd81ff8229ed98e7 1 parent d08632d
@netzpirat netzpirat authored
View
4 CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## Master
+
+- [Issue #82](https://github.com/netzpirat/guard-jasmine/issues/82): Enable the `:auto` server to detection unicorn, thin and mongrel.
+
## 1.8.3 - September 19, 2012
- [Issue #81](https://github.com/netzpirat/guard-jasmine/issues/81): Make the Guardfile template catch `.js.coffee` again.
View
8 lib/guard/jasmine/server.rb
@@ -88,6 +88,14 @@ def start_rake_server(port, task)
#
def detect_server(spec_dir)
if File.exists?('config.ru')
+ %w(unicorn thin mongrel).each do |server|
+ begin
+ require server
+ return server.to_sym
+ rescue LoadError
+ # Ignore missing server and try next
+ end
+ end
:webrick
elsif File.exists?(File.join(spec_dir, 'support', 'jasmine.yml'))
:jasmine_gem
View
54 spec/guard/jasmine/server_spec.rb
@@ -18,15 +18,59 @@
File.should_receive(:exists?).with('config.ru').and_return true
end
- it 'chooses the rack server strategy' do
- server.should_receive(:start_rack_server)
- server.start(:auto, 8888, 'test', 'spec/javascripts')
- end
-
it 'does wait for the server' do
server.should_receive(:wait_for_server)
server.start(:auto, 8888, 'test', 'spec/javascripts')
end
+
+ context 'with unicorn available' do
+ before do
+ Guard::Jasmine::Server.should_receive(:require).with('unicorn').and_return true
+ end
+
+ it 'uses unicorn as server' do
+ server.should_receive(:start_rack_server).with(8888, 'test', :unicorn)
+ server.start(:auto, 8888, 'test', 'spec/javascripts')
+ end
+ end
+
+ context 'with thin available' do
+ before do
+ Guard::Jasmine::Server.should_receive(:require).with('unicorn').and_raise LoadError
+ Guard::Jasmine::Server.should_receive(:require).with('thin').and_return true
+ end
+
+ it 'uses thin as server' do
+ server.should_receive(:start_rack_server).with(8888, 'test', :thin)
+ server.start(:auto, 8888, 'test', 'spec/javascripts')
+ end
+ end
+
+ context 'with mongrel available' do
+ before do
+ Guard::Jasmine::Server.should_receive(:require).with('unicorn').and_raise LoadError
+ Guard::Jasmine::Server.should_receive(:require).with('thin').and_raise LoadError
+ Guard::Jasmine::Server.should_receive(:require).with('mongrel').and_return true
+ end
+
+ it 'uses mongrel as server' do
+ server.should_receive(:start_rack_server).with(8888, 'test', :mongrel)
+ server.start(:auto, 8888, 'test', 'spec/javascripts')
+ end
+ end
+
+ context 'with unicorn, thin or mongrel not being available' do
+ before do
+ Guard::Jasmine::Server.should_receive(:require).with('unicorn').and_raise LoadError
+ Guard::Jasmine::Server.should_receive(:require).with('thin').and_raise LoadError
+ Guard::Jasmine::Server.should_receive(:require).with('mongrel').and_raise LoadError
+ end
+
+ it 'uses webrick as server' do
+ server.should_receive(:start_rack_server).with(8888, 'test', :webrick)
+ server.start(:auto, 8888, 'test', 'spec/javascripts')
+ end
+ end
end
context 'with a jasmine config file' do

0 comments on commit 9f0f879

Please sign in to comment.
Something went wrong with that request. Please try again.