rt 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -1
- data/bin/rt +15 -11
- data/features/cli.feature +4 -4
- data/features/cli_load_path.feature +3 -5
- data/lib/rt/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -4,9 +4,10 @@ rt
|
|
4
4
|
A unit test runner
|
5
5
|
|
6
6
|
Support run by file number
|
7
|
+
|
7
8
|
Support run by file path pattern
|
8
|
-
Support run by file line number
|
9
9
|
|
10
|
+
Support run by file line number
|
10
11
|
|
11
12
|
Support different format (In development)
|
12
13
|
|
@@ -24,6 +25,8 @@ Usage
|
|
24
25
|
|
25
26
|
`rt test/**/test_*.rb`
|
26
27
|
|
28
|
+
`rt test/unit/`
|
29
|
+
|
27
30
|
Support specify line number:
|
28
31
|
|
29
32
|
`rt test_file.rb:5`
|
data/bin/rt
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
$LOAD_PATH.unshift(File.join("./test"))
|
4
|
-
|
5
3
|
require File.join("rt.rb")
|
6
4
|
|
7
|
-
|
5
|
+
test_files = []
|
6
|
+
|
7
|
+
options = []
|
8
|
+
$: << File.join(".","test")
|
9
|
+
|
10
|
+
while f = ARGV.pop do
|
8
11
|
if f =~ /\*/
|
9
12
|
Dir.glob(f) do |test_file|
|
10
|
-
|
13
|
+
test_files << test_file
|
11
14
|
end
|
12
15
|
elsif f =~ /(.*):(\d+)$/
|
13
16
|
file_name = $1
|
@@ -16,22 +19,23 @@ ARGV.each do |f|
|
|
16
19
|
test_name = nil
|
17
20
|
%w[UnitTest ActiveSupportTestCase Shoulda].each do |matcher|
|
18
21
|
klass = eval("Rt::Matchers::#{matcher}")
|
19
|
-
break if test_name = klass.test_name(line)
|
22
|
+
break if test_name = klass.test_name(line)
|
20
23
|
end
|
21
|
-
if test_name
|
22
|
-
|
23
|
-
|
24
|
+
if !test_name.nil?
|
25
|
+
options << "--name=/#{test_name.strip}/"
|
26
|
+
test_files << file_name
|
24
27
|
else
|
25
28
|
STDERR.puts "Can not find test in file #{file_name} line #{line_num}"
|
26
29
|
exit 1
|
27
30
|
end
|
28
31
|
elsif File.directory?(f)
|
29
32
|
Dir.glob("**/*.rb") do |test_file|
|
30
|
-
|
33
|
+
test_files << test_file
|
31
34
|
end
|
32
35
|
elsif File.exist?(f)
|
33
|
-
|
36
|
+
test_files << f
|
34
37
|
end
|
35
|
-
|
36
38
|
end
|
39
|
+
options.each {|o| ARGV << o }
|
40
|
+
test_files.each {|f| load f}
|
37
41
|
|
data/features/cli.feature
CHANGED
@@ -15,22 +15,22 @@ Feature: Runner
|
|
15
15
|
"""
|
16
16
|
|
17
17
|
Scenario: Run single file from command-line
|
18
|
-
When I run "bundle exec rt test/test_one.rb"
|
18
|
+
When I successfully run "bundle exec rt test/test_one.rb"
|
19
19
|
Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
|
20
20
|
And the exit status should be 0
|
21
21
|
|
22
22
|
Scenario: Run two file from command-line
|
23
|
-
When I run "bundle exec rt test/test_one.rb test/test_two.rb"
|
23
|
+
When I successfully run "bundle exec rt test/test_one.rb test/test_two.rb"
|
24
24
|
Then the stdout should contain "2 tests, 2 assertions, 0 failures, 0 errors"
|
25
25
|
And the exit status should be 0
|
26
26
|
|
27
27
|
Scenario: Run tests in folder
|
28
|
-
When I run "bundle exec rt test"
|
28
|
+
When I successfully run "bundle exec rt test"
|
29
29
|
Then the stdout should contain "2 tests, 2 assertions, 0 failures, 0 errors"
|
30
30
|
And the exit status should be 0
|
31
31
|
|
32
32
|
Scenario: Run tests with regular expression
|
33
|
-
When I run "bundle exec rt **/*_one.rb"
|
33
|
+
When I successfully run "bundle exec rt **/*_one.rb"
|
34
34
|
Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
|
35
35
|
And the exit status should be 0
|
36
36
|
|
@@ -3,7 +3,7 @@ Feature: Load path when running test
|
|
3
3
|
Scenario: default load path is "test" folder
|
4
4
|
Given a file named "test/test_helper.rb" with:
|
5
5
|
"""
|
6
|
-
|
6
|
+
#no thing
|
7
7
|
"""
|
8
8
|
And a test file "test_one.rb" with:
|
9
9
|
"""
|
@@ -13,7 +13,5 @@ Feature: Load path when running test
|
|
13
13
|
assert true
|
14
14
|
end
|
15
15
|
"""
|
16
|
-
When I run "bundle exec rt test_one.rb"
|
17
|
-
Then the stdout should contain "
|
18
|
-
And the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
|
19
|
-
And the exit status should be 0
|
16
|
+
When I successfully run "bundle exec rt test_one.rb"
|
17
|
+
Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
|
data/lib/rt/version.rb
CHANGED
metadata
CHANGED