Skip to content
Browse files

Run selected unit/test by name. Issue #9

  • Loading branch information...
1 parent 05e104d commit 979854e64d024fb19ca20de1a684b10a5f5e55c0 sacre committed with Paweł Pałucki
Showing with 15 additions and 1 deletion.
  1. +6 −0 README.md
  2. +9 −1 bin/spin
View
6 README.md
@@ -41,6 +41,12 @@ Or push multiple files to be loaded at once:
spin push test/unit/product_test.rb test/unit/shop_test.rb test/unit/cart_test.rb
```
+Or push selected test by name (executed as -n '/test_newproduct/')
+
+``` bash
+spin push test/unit/product_test.rb:test_newproduct
+```
+
Or, when using RSpec, run the whole suite:
``` bash
View
10 bin/spin
@@ -170,7 +170,15 @@ def fork_and_run(files, push_results, test_framework, conn)
ARGV.push files
else
# We require the full path of the file here in the child process.
- files.each { |f| require File.expand_path f }
+ # Run only selected test by name.
+ # Add -n with all given names as Regexp eg. /name1|name2|name3/
+ names = "/#{files.map{|f|f.split(':')[1]}.reject(&:nil?).join('|')}/"
+ unless names == '//'
+ ARGV << '-n'
+ ARGV << names
+ puts "Test names: #{names}"
+ end
+ files.each { |f| require File.expand_path f.split(':')[0] }
end
end

0 comments on commit 979854e

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