Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Make it possible to run within mountable engine within a dummy app (using jasminerice) #83

Merged
merged 2 commits into from

2 participants

Paul Schyska Michael Kessler
Paul Schyska

We have a mountable engine with dummy app located at spec/dummy
Jasminerice serves the specs up correctly @ /jasmine

guard-jasmine fails to rackup the dummy app, because it is running rackup in the engine dir. Therefore, it hangs at

Guard::Jasmine starts webrick test server on port 8888 in development environment.

Using the verbose option, one can clearly see it's looking for engine_dir/config.ru.

This patch adds the ability to provide a rackup_config option to point to the correct file.

guard :jasmine, :server => :webrick, :rackup_config => 'spec/dummy/config.ru' do
  [...]
end
Michael Kessler netzpirat merged commit 462b8f4 into from
Michael Kessler
Owner

Thanks a lot! Released with version 1.9.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 16, 2012
  1. Paul Schyska
  2. Paul Schyska

    Updated README

    pschyska authored
This page is out of date. Refresh to see the latest.
5 README.md
View
@@ -361,6 +361,11 @@ The server options configures the server environment that is needed to run Guard
:timeout => 20000 # The time in ms to wait for the spec runner to finish.
# default: 10000
+
+:rackup_config => 'spec/dummy/config.ru' # Path to rackup config file (i.e. for webrick, mongrel, thin, unicorn).
+ # default: ./config.ru
+ # This option is useful when using guard-jasmine in a mountable engine
+ # and the config.ru is within the dummy app
```
If you're setting the `:server` option to `:none`, you can supply the Jasmine runner url manually:
2  lib/guard/jasmine.rb
View
@@ -88,7 +88,7 @@ def initialize(watchers = [], options = { })
def start
if Jasmine.phantomjs_bin_valid?(options[:phantomjs_bin])
- Server.start(options[:server], options[:port], options[:server_env], options[:spec_dir]) unless options[:server] == :none
+ Server.start(options[:server], options[:port], options[:server_env], options[:spec_dir], options[:rackup_config]) unless options[:server] == :none
if Jasmine.runner_available?(options)
run_all if options[:all_on_start]
14 lib/guard/jasmine/server.rb
View
@@ -19,13 +19,14 @@ class << self
# @param [Number] port the server port
# @param [String] environment the Rails environment
# @param [String] spec_dir the spec directory
+ # @param [String] (optional) custom rackup config to use (i.e. spec/dummy/config.ru for mountable engines)
#
- def start(strategy, port, environment, spec_dir)
+ def start(strategy, port, environment, spec_dir, rackup_config = nil)
strategy = detect_server(spec_dir) if strategy == :auto
case strategy
when :webrick, :mongrel, :thin, :unicorn
- start_rack_server(port, environment, strategy)
+ start_rack_server(port, environment, strategy, rackup_config)
when :jasmine_gem
start_rake_server(port, 'jasmine')
else
@@ -53,11 +54,16 @@ def stop
# @param [Number] port the server port
# @param [String] environment the Rails environment
# @param [Symbol] server the rack server to use
+ # @param [String] (optional) custom rackup config to use (i.e. spec/dummy/config.ru for mountable engines)
#
- def start_rack_server(port, environment, server)
+ def start_rack_server(port, environment, server, rackup_config)
::Guard::UI.info "Guard::Jasmine starts #{ server } test server on port #{ port } in #{ environment } environment."
- self.process = ChildProcess.build('rackup', '-E', environment.to_s, '-p', port.to_s, '-s', server.to_s)
+ if rackup_config
+ self.process = ChildProcess.build('rackup', '-E', environment.to_s, '-p', port.to_s, '-s', server.to_s, rackup_config)
+ else
+ self.process = ChildProcess.build('rackup', '-E', environment.to_s, '-p', port.to_s, '-s', server.to_s)
+ end
self.process.io.inherit! if ::Guard.respond_to?(:options) && ::Guard.options && ::Guard.options[:verbose]
self.process.start
15 spec/guard/jasmine/server_spec.rb
View
@@ -92,7 +92,7 @@
end
it 'starts a :thin rack server' do
- server.should_receive(:start_rack_server).with(8888, 'test', :thin)
+ server.should_receive(:start_rack_server).with(8888, 'test', :thin, nil)
server.start(:thin, 8888, 'test', 'spec/javascripts')
end
end
@@ -109,7 +109,7 @@
end
it 'starts a :mongrel rack server' do
- server.should_receive(:start_rack_server).with(8888, 'test', :mongrel)
+ server.should_receive(:start_rack_server).with(8888, 'test', :mongrel, nil)
server.start(:mongrel, 8888, 'test', 'spec/javascripts')
end
end
@@ -126,7 +126,7 @@
end
it 'starts a :webrick rack server' do
- server.should_receive(:start_rack_server).with(8888, 'test', :webrick)
+ server.should_receive(:start_rack_server).with(8888, 'test', :webrick, nil)
server.start(:webrick, 8888, 'test', 'spec/javascripts')
end
end
@@ -143,11 +143,18 @@
end
it 'starts a :unicorn rack server' do
- server.should_receive(:start_rack_server).with(8888, 'test', :unicorn)
+ server.should_receive(:start_rack_server).with(8888, 'test', :unicorn, nil)
server.start(:unicorn, 8888, 'test', 'spec/javascripts')
end
end
+ context 'with the :webrick strategy and a custom config.ru' do
+ it 'starts a :webrick rack server' do
+ server.should_receive(:start_rack_server).with(8888, 'test', :webrick, 'my/cool.ru')
+ server.start(:webrick, 8888, 'test', 'spec/javascripts', 'my/cool.ru')
+ end
+ end
+
context 'with the :jasmine_gem strategy' do
it 'does not auto detect a server' do
server.should_not_receive(:detect_server)
2  spec/guard/jasmine_spec.rb
View
@@ -272,7 +272,7 @@
end
it 'does start a server' do
- server.should_receive(:start).with(:jasmine_gem, 3333, 'test', 'spec/javascripts')
+ server.should_receive(:start).with(:jasmine_gem, 3333, 'test', 'spec/javascripts', nil)
guard.start
end
end
Something went wrong with that request. Please try again.