Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for spring

This works in exactly the same way as Spork / drb.
  • Loading branch information...
commit 06016d382bd50885ccdf3689f97173c6ef5906a5 1 parent 43a0c49
Adam Spiers authored
View
9 README.md
@@ -87,6 +87,14 @@ guard 'minitest', :drb => true do
end
```
+If you use [spring](https://github.com/jonleighton/spring) you can enable it with (you'll have to load it before):
+
+```ruby
+guard 'minitest', :spring => true do
+ # ...
+end
+```
+
### List of available options:
```ruby
@@ -94,6 +102,7 @@ end
:bundler => false # don't use "bundle exec" to run the minitest command, default: true
:rubygems => true # require rubygems when run the minitest command (only if bundler is disabled), default: false
:drb => true # enable DRb support, default: false
+:spring => true # enable spring support, default: false
:test_folders => ['tests'] # specify an array of paths that contain test files, default: %w[test spec]
:test_file_patterns => true # specify an array of patterns that test files must match in order to be run, default: %w[*_test.rb test_*.rb *_spec.rb]
:all_on_start => false # run all tests in group on startup, default: true
View
10 lib/guard/minitest/runner.rb
@@ -19,6 +19,7 @@ def initialize(options = {})
:rubygems => false,
:drb => false,
:zeus => false,
+ :spring => false,
:test_folders => %w[test spec],
:test_file_patterns => %w[*_test.rb test_*.rb *_spec.rb],
:cli => ''
@@ -40,7 +41,7 @@ def cli_options
end
def bundler?
- @options[:bundler]
+ @options[:bundler] && ! @options[:spring]
end
def rubygems?
@@ -55,6 +56,10 @@ def zeus?
@options[:zeus].is_a?(String) || @options[:zeus]
end
+ def spring?
+ @options[:spring]
+ end
+
def test_folders
@options[:test_folders]
end
@@ -76,6 +81,9 @@ def minitest_command(paths)
command = @options[:zeus].is_a?(String) ? @options[:zeus] : 'test'
cmd_parts << "zeus #{command}"
cmd_parts += paths.map{ |path| "./#{path}" }
+ elsif spring?
+ cmd_parts += %w{spring test}
+ cmd_parts += paths
else
cmd_parts << 'ruby'
cmd_parts += test_folders.map{|f| %[-I"#{f}"] }
View
26 spec/guard/minitest/runner_spec.rb
@@ -47,6 +47,11 @@
Dir.stubs(:pwd).returns(fixtures_path.join('bundler'))
subject.new(:bundler => false).bundler?.must_equal false
end
+
+ it 'should be forced to false if spring is enabled' do
+ Dir.stubs(:pwd).returns(fixtures_path.join('bundler'))
+ subject.new(:spring => true).bundler?.must_equal false
+ end
end
describe 'rubygems' do
@@ -92,6 +97,16 @@
subject.new(:zeus => 'blah').zeus?.must_equal true
end
end
+
+ describe 'spring' do
+ it 'default should be false' do
+ subject.new.spring?.must_equal false
+ end
+
+ it 'should be settable using a boolean' do
+ subject.new(:spring => true).spring?.must_equal true
+ end
+ end
end
describe 'run' do
@@ -196,6 +211,17 @@
end
end
+ describe 'spring' do
+ it 'should run with default spring command' do
+ runner = subject.new(:test_folders => %w[test], :spring => true)
+ Guard::UI.expects(:info)
+ runner.expects(:system).with(
+ "spring test test/test_minitest.rb"
+ )
+ runner.run(['test/test_minitest.rb'], :spring => true)
+ end
+ end
+
describe 'drb' do
it 'should run with drb' do
runner = subject.new(:test_folders => %w[test], :drb => true)
Please sign in to comment.
Something went wrong with that request. Please try again.