Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 598c859
Showing
24 changed files
with
508 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pkg/* | ||
*.gem | ||
.bundle | ||
*.swp | ||
.rvm | ||
/.rvmrc | ||
/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source "http://rubygems.org" | ||
|
||
# Specify your gem's dependencies in rt.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
rt (0.0.1) | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
activesupport (2.3.10) | ||
aruba (0.3.2) | ||
childprocess (~> 0.1.6) | ||
cucumber (~> 0.10.0) | ||
rspec (~> 2.3.0) | ||
builder (3.0.0) | ||
childprocess (0.1.6) | ||
ffi (~> 0.6.3) | ||
columnize (0.3.2) | ||
cucumber (0.10.0) | ||
builder (>= 2.1.2) | ||
diff-lcs (~> 1.1.2) | ||
gherkin (~> 2.3.2) | ||
json (~> 1.4.6) | ||
term-ansicolor (~> 1.0.5) | ||
diff-lcs (1.1.2) | ||
ffi (0.6.3) | ||
rake (>= 0.8.7) | ||
gherkin (2.3.3) | ||
json (~> 1.4.6) | ||
json (1.4.6) | ||
linecache (0.43) | ||
rake (0.8.7) | ||
rr (1.0.2) | ||
rspec (2.3.0) | ||
rspec-core (~> 2.3.0) | ||
rspec-expectations (~> 2.3.0) | ||
rspec-mocks (~> 2.3.0) | ||
rspec-core (2.3.1) | ||
rspec-expectations (2.3.0) | ||
diff-lcs (~> 1.1.2) | ||
rspec-mocks (2.3.0) | ||
ruby-debug (0.10.4) | ||
columnize (>= 0.1) | ||
ruby-debug-base (~> 0.10.4.0) | ||
ruby-debug-base (0.10.4) | ||
linecache (>= 0.3) | ||
shoulda (2.11.3) | ||
term-ansicolor (1.0.5) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
activesupport (~> 2.3.8) | ||
aruba (~> 0.3.2) | ||
cucumber (~> 0.10.0) | ||
rr | ||
rt! | ||
ruby-debug | ||
shoulda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
rt | ||
======== | ||
|
||
A unit test runner | ||
|
||
Support run by file number | ||
Support run by file path pattern | ||
Support run by file line number | ||
|
||
|
||
Support different format (In development) | ||
|
||
|
||
Installation | ||
------- | ||
|
||
gem install rt | ||
|
||
|
||
Usage | ||
----- | ||
|
||
`rt test_file.rb` | ||
|
||
`rt test/**/test_*.rb` | ||
|
||
Support specify line number: | ||
|
||
`rt test_file.rb:5` | ||
|
||
|
||
Load Path | ||
-------- | ||
automatic add "./test" to load path, so you don't need "-Itest" option | ||
|
||
|
||
Roadmap | ||
========= | ||
|
||
* Support red green | ||
* Support Formatter | ||
* Support Rspec compatible Formatter | ||
* Support growl notify | ||
* Support tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require 'bundler' | ||
Bundler::GemHelper.install_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env ruby | ||
|
||
$LOAD_PATH.unshift(File.join("./test")) | ||
|
||
require File.join("rt.rb") | ||
|
||
ARGV.each do |f| | ||
if f =~ /\*/ | ||
Dir.glob(f) do |test_file| | ||
load test_file | ||
end | ||
elsif f =~ /(.*):(\d+)$/ | ||
file_name = $1 | ||
line_num = $2 | ||
line = `sed -n "#{line_num}p" #{file_name}` | ||
test_name = nil | ||
%w[UnitTest ActiveSupportTestCase Shoulda].each do |matcher| | ||
klass = eval("Rt::Matchers::#{matcher}") | ||
break if test_name = klass.test_name(line) | ||
end | ||
if test_name | ||
ARGV << "--name=/#{test_name}/" | ||
load file_name | ||
else | ||
STDERR.puts "Can not find test in file #{file_name} line #{line_num}" | ||
exit 1 | ||
end | ||
elsif File.directory?(f) | ||
Dir.glob("**/*.rb") do |test_file| | ||
load test_file | ||
end | ||
elsif File.exist?(f) | ||
load f | ||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
default: --require features --strict --format progress --tags ~@wip features | ||
wip: --require features --tags @wip:3 --wip features | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Feature: Runner | ||
|
||
Background: | ||
Given a test file "test/test_one.rb" with: | ||
""" | ||
def test_one | ||
assert true | ||
end | ||
""" | ||
And a test file "test/test_two.rb" with: | ||
""" | ||
def test_two | ||
assert true | ||
end | ||
""" | ||
|
||
Scenario: Run single file from command-line | ||
When I run "bundle exec rt test/test_one.rb" | ||
Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors" | ||
And the exit status should be 0 | ||
|
||
Scenario: Run two file from command-line | ||
When I run "bundle exec rt test/test_one.rb test/test_two.rb" | ||
Then the stdout should contain "2 tests, 2 assertions, 0 failures, 0 errors" | ||
And the exit status should be 0 | ||
|
||
Scenario: Run tests in folder | ||
When I run "bundle exec rt test" | ||
Then the stdout should contain "2 tests, 2 assertions, 0 failures, 0 errors" | ||
And the exit status should be 0 | ||
|
||
Scenario: Run tests with regular expression | ||
When I run "bundle exec rt **/*_one.rb" | ||
Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors" | ||
And the exit status should be 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
Feature: run single test according to line number | ||
|
||
Scenario: Support ActiveSupport::TestCase | ||
Given a file named "test_one.rb" with: | ||
""" | ||
require 'test/unit' | ||
require 'active_support/test_case' | ||
class TestOne < ActiveSupport::TestCase | ||
test "test one" do | ||
assert true | ||
end | ||
test 'test two' do | ||
assert true | ||
end | ||
end | ||
""" | ||
When I successfully run "bundle exec rt test_one.rb:5" | ||
Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors" | ||
When I successfully run "bundle exec rt test_one.rb:9" | ||
Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors" | ||
|
||
Scenario: Support shoulda should method | ||
Given a file named "test_one.rb" with: | ||
""" | ||
require 'test/unit' | ||
require 'active_support/test_case' | ||
require 'shoulda' | ||
class TestOne < ActiveSupport::TestCase | ||
should "test one" do | ||
assert true | ||
end | ||
should 'test two' do | ||
assert true | ||
end | ||
end | ||
""" | ||
When I successfully run "bundle exec rt test_one.rb:6" | ||
Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors" | ||
When I successfully run "bundle exec rt test_one.rb:10" | ||
Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors" | ||
|
||
Scenario: Support shoulda should method | ||
Given a file named "test_one.rb" with: | ||
""" | ||
require 'test/unit' | ||
require 'active_support/test_case' | ||
require 'shoulda' | ||
class TestOne < ActiveSupport::TestCase | ||
context "a context" do | ||
should "test one" do | ||
assert true | ||
end | ||
end | ||
should 'test two' do | ||
assert true | ||
end | ||
end | ||
""" | ||
When I successfully run "bundle exec rt test_one.rb:6" | ||
Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors" | ||
When I successfully run "bundle exec rt test_one.rb:12" | ||
Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors" | ||
|
||
|
||
|
||
Scenario: get warning can not find test if can not find test in spacified line | ||
Given a file named "test_one.rb" with: | ||
""" | ||
require 'test/unit' | ||
require 'active_support/test_case' | ||
class TestOne < ActiveSupport::TestCase | ||
test "test one" do | ||
assert true | ||
end | ||
end | ||
""" | ||
When I run "bundle exec rt test_one.rb:1" | ||
Then the stderr should contain "Can not find test in file test_one.rb line 1" | ||
And the exit status should be 1 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Feature: Load path when running test | ||
|
||
Scenario: default load path is "test" folder | ||
Given a file named "test/test_helper.rb" with: | ||
""" | ||
puts 'load test_helper' | ||
""" | ||
And a test file "test_one.rb" with: | ||
""" | ||
require 'test_helper' | ||
def test_one | ||
assert true | ||
end | ||
""" | ||
When I run "bundle exec rt test_one.rb" | ||
Then the stdout should contain "load test_helper" | ||
And the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors" | ||
And the exit status should be 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Given /^a test file "(.*)" with:$/ do |filename, content| | ||
Given "a file named \"#{filename}\" with:", <<-EOF | ||
require 'test/unit' | ||
class #{camelize(File.basename(filename,'.rb'))} < Test::Unit::TestCase | ||
#{content} | ||
end | ||
EOF | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'aruba/cucumber' | ||
|
||
module Rt::World | ||
def camelize(str) | ||
str.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } | ||
end | ||
end | ||
|
||
World(Rt::World) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'rt/matcher' | ||
require 'rt/matchers/unit_test' | ||
require 'rt/matchers/active_support_test_case' | ||
require 'rt/matchers/shoulda' | ||
|
||
|
||
module Rt | ||
module Matchers | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Rt | ||
class Matcher | ||
def self.match(arg) | ||
raise "Not implement" | ||
end | ||
|
||
def self.test_name(line) | ||
if match = self.match(line) | ||
return match.gsub!(/\s+/,"_") | ||
end | ||
return nil | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Rt | ||
module Matchers | ||
class ActiveSupportTestCase < Rt::Matcher | ||
def self.match(arg) | ||
return arg[/\s*test\s+["']+(.*)["']+\s+do/,1] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Rt | ||
module Matchers | ||
class Shoulda < Rt::Matcher | ||
def self.match(arg) | ||
return arg[/\s*[should|context]+\s+["']+(.*)["']+\s+do/,1] | ||
end | ||
|
||
def self.test_name(line) | ||
return self.match(line) | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Rt | ||
module Matchers | ||
class UnitTest < Rt::Matcher | ||
def self.match(arg) | ||
return arg[/\s*def\s+(test\S+)\s*/,1] | ||
end | ||
end | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Rt | ||
VERSION = "0.0.1" | ||
end |
Oops, something went wrong.