rt 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ *.swp
5
+ .rvm
6
+ /.rvmrc
7
+ /tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rt.gemspec
4
+ gemspec
@@ -0,0 +1,59 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rt (0.0.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ activesupport (2.3.10)
10
+ aruba (0.3.2)
11
+ childprocess (~> 0.1.6)
12
+ cucumber (~> 0.10.0)
13
+ rspec (~> 2.3.0)
14
+ builder (3.0.0)
15
+ childprocess (0.1.6)
16
+ ffi (~> 0.6.3)
17
+ columnize (0.3.2)
18
+ cucumber (0.10.0)
19
+ builder (>= 2.1.2)
20
+ diff-lcs (~> 1.1.2)
21
+ gherkin (~> 2.3.2)
22
+ json (~> 1.4.6)
23
+ term-ansicolor (~> 1.0.5)
24
+ diff-lcs (1.1.2)
25
+ ffi (0.6.3)
26
+ rake (>= 0.8.7)
27
+ gherkin (2.3.3)
28
+ json (~> 1.4.6)
29
+ json (1.4.6)
30
+ linecache (0.43)
31
+ rake (0.8.7)
32
+ rr (1.0.2)
33
+ rspec (2.3.0)
34
+ rspec-core (~> 2.3.0)
35
+ rspec-expectations (~> 2.3.0)
36
+ rspec-mocks (~> 2.3.0)
37
+ rspec-core (2.3.1)
38
+ rspec-expectations (2.3.0)
39
+ diff-lcs (~> 1.1.2)
40
+ rspec-mocks (2.3.0)
41
+ ruby-debug (0.10.4)
42
+ columnize (>= 0.1)
43
+ ruby-debug-base (~> 0.10.4.0)
44
+ ruby-debug-base (0.10.4)
45
+ linecache (>= 0.3)
46
+ shoulda (2.11.3)
47
+ term-ansicolor (1.0.5)
48
+
49
+ PLATFORMS
50
+ ruby
51
+
52
+ DEPENDENCIES
53
+ activesupport (~> 2.3.8)
54
+ aruba (~> 0.3.2)
55
+ cucumber (~> 0.10.0)
56
+ rr
57
+ rt!
58
+ ruby-debug
59
+ shoulda
@@ -0,0 +1,45 @@
1
+ rt
2
+ ========
3
+
4
+ A unit test runner
5
+
6
+ Support run by file number
7
+ Support run by file path pattern
8
+ Support run by file line number
9
+
10
+
11
+ Support different format (In development)
12
+
13
+
14
+ Installation
15
+ -------
16
+
17
+ gem install rt
18
+
19
+
20
+ Usage
21
+ -----
22
+
23
+ `rt test_file.rb`
24
+
25
+ `rt test/**/test_*.rb`
26
+
27
+ Support specify line number:
28
+
29
+ `rt test_file.rb:5`
30
+
31
+ Only support "Test::Unit::TestCase", "ActiveSupport::TestCase" and "Shoulda"
32
+
33
+ Load Path
34
+ --------
35
+ automatic add "./test" to load path, so you don't need "-Itest" option
36
+
37
+
38
+ Roadmap
39
+ =========
40
+
41
+ * Support red green
42
+ * Support Formatter
43
+ * Support Rspec compatible Formatter
44
+ * Support growl notify
45
+ * Support tag
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/bin/rt ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.join("./test"))
4
+
5
+ require File.join("rt.rb")
6
+
7
+ ARGV.each do |f|
8
+ if f =~ /\*/
9
+ Dir.glob(f) do |test_file|
10
+ load test_file
11
+ end
12
+ elsif f =~ /(.*):(\d+)$/
13
+ file_name = $1
14
+ line_num = $2
15
+ line = `sed -n "#{line_num}p" #{file_name}`
16
+ test_name = nil
17
+ %w[UnitTest ActiveSupportTestCase Shoulda].each do |matcher|
18
+ klass = eval("Rt::Matchers::#{matcher}")
19
+ break if test_name = klass.test_name(line)
20
+ end
21
+ if test_name
22
+ ARGV << "--name=/#{test_name}/"
23
+ load file_name
24
+ else
25
+ STDERR.puts "Can not find test in file #{file_name} line #{line_num}"
26
+ exit 1
27
+ end
28
+ elsif File.directory?(f)
29
+ Dir.glob("**/*.rb") do |test_file|
30
+ load test_file
31
+ end
32
+ elsif File.exist?(f)
33
+ load f
34
+ end
35
+
36
+ end
37
+
@@ -0,0 +1,3 @@
1
+ default: --require features --strict --format progress --tags ~@wip features
2
+ wip: --require features --tags @wip:3 --wip features
3
+
@@ -0,0 +1,36 @@
1
+ Feature: Runner
2
+
3
+ Background:
4
+ Given a test file "test/test_one.rb" with:
5
+ """
6
+ def test_one
7
+ assert true
8
+ end
9
+ """
10
+ And a test file "test/test_two.rb" with:
11
+ """
12
+ def test_two
13
+ assert true
14
+ end
15
+ """
16
+
17
+ Scenario: Run single file from command-line
18
+ When I run "bundle exec rt test/test_one.rb"
19
+ Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
20
+ And the exit status should be 0
21
+
22
+ Scenario: Run two file from command-line
23
+ When I run "bundle exec rt test/test_one.rb test/test_two.rb"
24
+ Then the stdout should contain "2 tests, 2 assertions, 0 failures, 0 errors"
25
+ And the exit status should be 0
26
+
27
+ Scenario: Run tests in folder
28
+ When I run "bundle exec rt test"
29
+ Then the stdout should contain "2 tests, 2 assertions, 0 failures, 0 errors"
30
+ And the exit status should be 0
31
+
32
+ Scenario: Run tests with regular expression
33
+ When I run "bundle exec rt **/*_one.rb"
34
+ Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
35
+ And the exit status should be 0
36
+
@@ -0,0 +1,88 @@
1
+ Feature: run single test according to line number
2
+
3
+ Scenario: Support ActiveSupport::TestCase
4
+ Given a file named "test_one.rb" with:
5
+ """
6
+ require 'test/unit'
7
+ require 'active_support/test_case'
8
+
9
+ class TestOne < ActiveSupport::TestCase
10
+ test "test one" do
11
+ assert true
12
+ end
13
+
14
+ test 'test two' do
15
+ assert true
16
+ end
17
+ end
18
+ """
19
+ When I successfully run "bundle exec rt test_one.rb:5"
20
+ Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
21
+ When I successfully run "bundle exec rt test_one.rb:9"
22
+ Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
23
+
24
+ Scenario: Support shoulda should method
25
+ Given a file named "test_one.rb" with:
26
+ """
27
+ require 'test/unit'
28
+ require 'active_support/test_case'
29
+ require 'shoulda'
30
+
31
+ class TestOne < ActiveSupport::TestCase
32
+ should "test one" do
33
+ assert true
34
+ end
35
+
36
+ should 'test two' do
37
+ assert true
38
+ end
39
+ end
40
+ """
41
+ When I successfully run "bundle exec rt test_one.rb:6"
42
+ Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
43
+ When I successfully run "bundle exec rt test_one.rb:10"
44
+ Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
45
+
46
+ Scenario: Support shoulda should method
47
+ Given a file named "test_one.rb" with:
48
+ """
49
+ require 'test/unit'
50
+ require 'active_support/test_case'
51
+ require 'shoulda'
52
+
53
+ class TestOne < ActiveSupport::TestCase
54
+ context "a context" do
55
+ should "test one" do
56
+ assert true
57
+ end
58
+ end
59
+
60
+ should 'test two' do
61
+ assert true
62
+ end
63
+ end
64
+ """
65
+ When I successfully run "bundle exec rt test_one.rb:6"
66
+ Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
67
+ When I successfully run "bundle exec rt test_one.rb:12"
68
+ Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
69
+
70
+
71
+
72
+ Scenario: get warning can not find test if can not find test in spacified line
73
+ Given a file named "test_one.rb" with:
74
+ """
75
+ require 'test/unit'
76
+ require 'active_support/test_case'
77
+
78
+ class TestOne < ActiveSupport::TestCase
79
+ test "test one" do
80
+ assert true
81
+ end
82
+ end
83
+ """
84
+ When I run "bundle exec rt test_one.rb:1"
85
+ Then the stderr should contain "Can not find test in file test_one.rb line 1"
86
+ And the exit status should be 1
87
+
88
+
@@ -0,0 +1,19 @@
1
+ Feature: Load path when running test
2
+
3
+ Scenario: default load path is "test" folder
4
+ Given a file named "test/test_helper.rb" with:
5
+ """
6
+ puts 'load test_helper'
7
+ """
8
+ And a test file "test_one.rb" with:
9
+ """
10
+ require 'test_helper'
11
+
12
+ def test_one
13
+ assert true
14
+ end
15
+ """
16
+ When I run "bundle exec rt test_one.rb"
17
+ Then the stdout should contain "load test_helper"
18
+ And the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
19
+ And the exit status should be 0
@@ -0,0 +1,9 @@
1
+ Given /^a test file "(.*)" with:$/ do |filename, content|
2
+ Given "a file named \"#{filename}\" with:", <<-EOF
3
+ require 'test/unit'
4
+
5
+ class #{camelize(File.basename(filename,'.rb'))} < Test::Unit::TestCase
6
+ #{content}
7
+ end
8
+ EOF
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'aruba/cucumber'
2
+
3
+ module Rt::World
4
+ def camelize(str)
5
+ str.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
6
+ end
7
+ end
8
+
9
+ World(Rt::World)
@@ -0,0 +1,11 @@
1
+ require 'rt/matcher'
2
+ require 'rt/matchers/unit_test'
3
+ require 'rt/matchers/active_support_test_case'
4
+ require 'rt/matchers/shoulda'
5
+
6
+
7
+ module Rt
8
+ module Matchers
9
+
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ module Rt
2
+ class Matcher
3
+ def self.match(arg)
4
+ raise "Not implement"
5
+ end
6
+
7
+ def self.test_name(line)
8
+ if match = self.match(line)
9
+ return match.gsub!(/\s+/,"_")
10
+ end
11
+ return nil
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ module Rt
2
+ module Matchers
3
+ class ActiveSupportTestCase < Rt::Matcher
4
+ def self.match(arg)
5
+ return arg[/\s*test\s+["']+(.*)["']+\s+do/,1]
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ module Rt
2
+ module Matchers
3
+ class Shoulda < Rt::Matcher
4
+ def self.match(arg)
5
+ return arg[/\s*[should|context]+\s+["']+(.*)["']+\s+do/,1]
6
+ end
7
+
8
+ def self.test_name(line)
9
+ return self.match(line)
10
+ end
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,11 @@
1
+ module Rt
2
+ module Matchers
3
+ class UnitTest < Rt::Matcher
4
+ def self.match(arg)
5
+ return arg[/\s*def\s+(test\S+)\s*/,1]
6
+ end
7
+ end
8
+ end
9
+ end
10
+
11
+
@@ -0,0 +1,3 @@
1
+ module Rt
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "rt/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "rt"
7
+ s.version = Rt::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Allen Wei"]
10
+ s.email = ["digruby@gmail.com"]
11
+ s.homepage = "https://github.com/allenwei/rt"
12
+ s.summary = %q{unit test runner}
13
+ s.description = %q{unit test runner, support run tests by regular expression, line num and printing test result in different fomatter }
14
+
15
+ s.rubyforge_project = "rt"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+
23
+ s.add_development_dependency 'cucumber', "~> 0.10.0"
24
+ s.add_development_dependency 'aruba', "~> 0.3.2"
25
+ s.add_development_dependency 'activesupport', "~> 2.3.8"
26
+ s.add_development_dependency 'shoulda'
27
+ s.add_development_dependency 'ruby-debug'
28
+ s.add_development_dependency 'rr'
29
+
30
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rt::Matcher do
4
+ context ".test_name" do
5
+ it "should replace blank with '_'" do
6
+ line = "test 'a b c' do"
7
+ Rt::Matcher.should_receive(:match).with(line).and_return("a b c")
8
+ Rt::Matcher.test_name(line).should == "a_b_c"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rt::ActiveSupportTestCase do
4
+
5
+ context ".match" do
6
+ it "should match test with double quote" do
7
+ Rt::ActiveSupportTestCase.match(%Q{test "test_one" do}).should == "test_one"
8
+ end
9
+
10
+ it "should match test with double quote and blank at begining" do
11
+ Rt::ActiveSupportTestCase.match(%Q{ test "test_one" do}).should == "test_one"
12
+ end
13
+
14
+ it "should match test with double quote and blank after 'test'" do
15
+ Rt::ActiveSupportTestCase.match(%Q{ test "test_one" do}).should == "test_one"
16
+ end
17
+
18
+ it "should match test with double quote and blank after 'test' before do " do
19
+ Rt::ActiveSupportTestCase.match(%Q{ test "test_one" do}).should == "test_one"
20
+ end
21
+
22
+ it "should match test with double quote and blank after 'test' after do " do
23
+ Rt::ActiveSupportTestCase.match(%Q{ test "test_one" do}).should == "test_one"
24
+ end
25
+
26
+ it "should not match is not a test" do
27
+ Rt::ActiveSupportTestCase.match(%Q{test1 "test_one" do}).should be_nil
28
+ end
29
+
30
+ it "should match test with single qoute" do
31
+ Rt::ActiveSupportTestCase.match(%Q{test 'test_one' do}).should == "test_one"
32
+ end
33
+ end
34
+ end
35
+
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rt::Matchers::Shoulda do
4
+ context ".match" do
5
+ it "should match line with should in double qoute" do
6
+ Rt::Matchers::Shoulda.match(%q{should "test one" do}).should == "test one"
7
+ end
8
+
9
+ it "should match line with should in single quote" do
10
+ Rt::Matchers::Shoulda.match(%q{should 'test one' do}).should == "test one"
11
+ end
12
+
13
+ it "should match line with context in double qoute" do
14
+ Rt::Matchers::Shoulda.match(%q{context "test one" do}).should == "test one"
15
+ end
16
+
17
+ it "should match line with context in single qoute" do
18
+ Rt::Matchers::Shoulda.match(%q{context 'test one' do}).should == "test one"
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rt::Matchers::UnitTest do
4
+ context ".match" do
5
+ it "should match def" do
6
+ Rt::Matchers::UnitTest.match("def test_a_b_c").should == "test_a_b_c"
7
+ end
8
+
9
+ it "should match def with extra blank" do
10
+ Rt::Matchers::UnitTest.match(" def test_a_b_c ").should == "test_a_b_c"
11
+ end
12
+
13
+ it "should only match method name start with 'test'" do
14
+ Rt::Matchers::UnitTest.match(" def a_b_c ").should be_nil
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rspec'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'..','lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+
8
+ require 'rt'
9
+
10
+ RSpec.configure do |config|
11
+ config.mock_with :rspec
12
+ end
13
+
14
+
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rt
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Allen Wei
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-17 00:00:00 +08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: cucumber
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 55
30
+ segments:
31
+ - 0
32
+ - 10
33
+ - 0
34
+ version: 0.10.0
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: aruba
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 23
46
+ segments:
47
+ - 0
48
+ - 3
49
+ - 2
50
+ version: 0.3.2
51
+ type: :development
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: activesupport
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 19
62
+ segments:
63
+ - 2
64
+ - 3
65
+ - 8
66
+ version: 2.3.8
67
+ type: :development
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: shoulda
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ type: :development
82
+ version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ name: ruby-debug
85
+ prerelease: false
86
+ requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ type: :development
96
+ version_requirements: *id005
97
+ - !ruby/object:Gem::Dependency
98
+ name: rr
99
+ prerelease: false
100
+ requirement: &id006 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ type: :development
110
+ version_requirements: *id006
111
+ description: "unit test runner, support run tests by regular expression, line num and printing test result in different fomatter "
112
+ email:
113
+ - digruby@gmail.com
114
+ executables:
115
+ - rt
116
+ extensions: []
117
+
118
+ extra_rdoc_files: []
119
+
120
+ files:
121
+ - .gitignore
122
+ - Gemfile
123
+ - Gemfile.lock
124
+ - README.md
125
+ - Rakefile
126
+ - bin/rt
127
+ - cucumber.yml
128
+ - features/cli.feature
129
+ - features/cli_line_number.feature
130
+ - features/cli_load_path.feature
131
+ - features/step_definitions/test_file_helper_step.rb
132
+ - features/support/env.rb
133
+ - lib/rt.rb
134
+ - lib/rt/matcher.rb
135
+ - lib/rt/matchers/active_support_test_case.rb
136
+ - lib/rt/matchers/shoulda.rb
137
+ - lib/rt/matchers/unit_test.rb
138
+ - lib/rt/version.rb
139
+ - rt.gemspec
140
+ - spec/rt/matcher_spec.rb
141
+ - spec/rt/matchers/active_support_test_case_spec.rb
142
+ - spec/rt/matchers/shoulda_spec.rb
143
+ - spec/rt/matchers/unit_test_spec.rb
144
+ - spec/spec_helper.rb
145
+ has_rdoc: true
146
+ homepage: https://github.com/allenwei/rt
147
+ licenses: []
148
+
149
+ post_install_message:
150
+ rdoc_options: []
151
+
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ hash: 3
160
+ segments:
161
+ - 0
162
+ version: "0"
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ hash: 3
169
+ segments:
170
+ - 0
171
+ version: "0"
172
+ requirements: []
173
+
174
+ rubyforge_project: rt
175
+ rubygems_version: 1.3.7
176
+ signing_key:
177
+ specification_version: 3
178
+ summary: unit test runner
179
+ test_files:
180
+ - features/cli.feature
181
+ - features/cli_line_number.feature
182
+ - features/cli_load_path.feature
183
+ - features/step_definitions/test_file_helper_step.rb
184
+ - features/support/env.rb
185
+ - spec/rt/matcher_spec.rb
186
+ - spec/rt/matchers/active_support_test_case_spec.rb
187
+ - spec/rt/matchers/shoulda_spec.rb
188
+ - spec/rt/matchers/unit_test_spec.rb
189
+ - spec/spec_helper.rb