test-subset 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +40 -0
- data/README +25 -0
- data/Rakefile +16 -0
- data/lib/test-subset.rb +66 -0
- data/lib/test-subset/version.rb +3 -0
- data/test-subset.gemspec +22 -0
- data/test/unit/test_subset_test.rb +100 -0
- metadata +72 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
test-subset (0.0.1)
|
5
|
+
rake
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ansi (1.4.2)
|
11
|
+
coderay (1.0.5)
|
12
|
+
metaclass (0.0.1)
|
13
|
+
method_source (0.7.1)
|
14
|
+
minitest (2.11.3)
|
15
|
+
mocha (0.10.5)
|
16
|
+
metaclass (~> 0.0.1)
|
17
|
+
pry (0.9.8.4)
|
18
|
+
coderay (~> 1.0.5)
|
19
|
+
method_source (~> 0.7.1)
|
20
|
+
slop (>= 2.4.4, < 3)
|
21
|
+
rake (0.9.2.2)
|
22
|
+
shoulda (3.0.1)
|
23
|
+
shoulda-context (~> 1.0.0)
|
24
|
+
shoulda-matchers (~> 1.0.0)
|
25
|
+
shoulda-context (1.0.0)
|
26
|
+
shoulda-matchers (1.0.0)
|
27
|
+
slop (2.4.4)
|
28
|
+
turn (0.9.4)
|
29
|
+
ansi
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
ruby
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
minitest
|
36
|
+
mocha
|
37
|
+
pry
|
38
|
+
shoulda
|
39
|
+
test-subset!
|
40
|
+
turn
|
data/README
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Construct subsets of your tests
|
2
|
+
|
3
|
+
TestSubset::Task.new("foo") do |test|
|
4
|
+
test.units "foo/*"
|
5
|
+
test.functionals "foo/*", "bar/*", "*{foo,bar}*"
|
6
|
+
test.integration "foo/*"
|
7
|
+
end
|
8
|
+
|
9
|
+
Execute them like so
|
10
|
+
|
11
|
+
rake test:foo:units # just units
|
12
|
+
rake test:foo:functionals # just functionals
|
13
|
+
rake test:foo:integration # just integration
|
14
|
+
rake test:foo # all
|
15
|
+
|
16
|
+
And some additional tasks
|
17
|
+
|
18
|
+
rake test:foo:units_and_functionals
|
19
|
+
rake test:foo:functionals_and_units
|
20
|
+
|
21
|
+
rake test:foo:units_and_integration
|
22
|
+
rake test:foo:integration_and_units
|
23
|
+
|
24
|
+
rake test:foo:functionals_and_integration
|
25
|
+
rake test:foo:integration_and_functionals
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
task :default => :test
|
5
|
+
|
6
|
+
require 'rake/testtask'
|
7
|
+
Rake::TestTask.new(:test) do |test|
|
8
|
+
test.libs << "lib" << "test"
|
9
|
+
test.test_files = FileList["test/unit/**/*_test.rb"]
|
10
|
+
test.verbose = true
|
11
|
+
# test.warning = true
|
12
|
+
end
|
13
|
+
|
14
|
+
task :console do
|
15
|
+
sh "pry -I lib/test-subset -r test-subset.rb"
|
16
|
+
end
|
data/lib/test-subset.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
|
3
|
+
module TestSubset
|
4
|
+
class Task
|
5
|
+
|
6
|
+
def initialize(name, *expressions, &block)
|
7
|
+
@name = name
|
8
|
+
@list = {}
|
9
|
+
if block_given?
|
10
|
+
yield self
|
11
|
+
combo_test_task("units_and_functionals", "units", "functionals")
|
12
|
+
combo_test_task("functionals_and_integration", "functionals", "integration")
|
13
|
+
combo_test_task("units_and_integration", "units", "integration")
|
14
|
+
combo_test_task("", "units", "functionals", "integration")
|
15
|
+
alias_test_task("functionals_and_units", "units_and_functionals")
|
16
|
+
alias_test_task("integration_and_units", "units_and_integration")
|
17
|
+
alias_test_task("functionals_and_integration", "integration_and_functionals")
|
18
|
+
else
|
19
|
+
test_task("", *expressions)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def integration(*expressions)
|
24
|
+
expressions = expressions.map {|a| "test/integration/#{a}_test.rb" }
|
25
|
+
test_task("integration", *expressions)
|
26
|
+
end
|
27
|
+
|
28
|
+
def functionals(*expressions)
|
29
|
+
expressions = expressions.map {|a| "test/functional/#{a}_test.rb" }
|
30
|
+
test_task("functionals", *expressions)
|
31
|
+
end
|
32
|
+
|
33
|
+
def units(*expressions)
|
34
|
+
expressions = expressions.map {|a| "test/unit/#{a}_test.rb" }
|
35
|
+
test_task("units", *expressions)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def test_task(name, *expressions)
|
40
|
+
@list[name] = expressions
|
41
|
+
Rake::TestTask.new(task_name[name]) do |test|
|
42
|
+
test.libs << 'lib' << 'test'
|
43
|
+
test.test_files = FileList[*@list[name]]
|
44
|
+
test.verbose = true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def combo_test_task(name, *keys)
|
49
|
+
test_tasks = keys.map {|k| task_name[k] }
|
50
|
+
Rake::Task.define_task task_name[name] => test_tasks
|
51
|
+
end
|
52
|
+
|
53
|
+
def alias_test_task(name, real_name)
|
54
|
+
Rake::Task.define_task task_name[name] => task_name[real_name]
|
55
|
+
end
|
56
|
+
|
57
|
+
def task_name
|
58
|
+
@task_name ||= Hash.new do |h,k|
|
59
|
+
h[k] = ["test:#{@name}", k].compact.
|
60
|
+
reject(&:empty?).
|
61
|
+
join(":")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
data/test-subset.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require 'test-subset/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "test-subset"
|
6
|
+
s.version = TestSubset::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Jon Karna"]
|
9
|
+
s.email = ["ipg49vv2@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/jonkarna/test-subset"
|
11
|
+
s.summary = %q{}
|
12
|
+
s.description = %q{}
|
13
|
+
|
14
|
+
s.rubyforge_project = "test-subset"
|
15
|
+
|
16
|
+
s.add_runtime_dependency "rake"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'test-subset'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'shoulda'
|
5
|
+
require 'turn'
|
6
|
+
require 'mocha'
|
7
|
+
|
8
|
+
module TestSubset
|
9
|
+
class TaskTest < Test::Unit::TestCase
|
10
|
+
subject { TestSubset::Task.new("foo") }
|
11
|
+
|
12
|
+
context "#integration" do
|
13
|
+
should "add integration tests" do
|
14
|
+
subject.expects(:test_task).with("integration", "test/integration/foo/*_test.rb")
|
15
|
+
subject.integration "foo/*"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "#functionals" do
|
20
|
+
should "add functional tests" do
|
21
|
+
subject.expects(:test_task).with("functionals", "test/functional/foo/*_test.rb")
|
22
|
+
subject.functionals "foo/*"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "#units" do
|
27
|
+
should "add unit tests" do
|
28
|
+
subject.expects(:test_task).with("units", "test/unit/foo/*_test.rb")
|
29
|
+
subject.units "foo/*"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "helper methods" do
|
34
|
+
setup do
|
35
|
+
@args = ["test_section", "1", "2"]
|
36
|
+
Rake::TestTask.expects(:new).with("test:foo")
|
37
|
+
end
|
38
|
+
|
39
|
+
context "#test_task" do
|
40
|
+
should "create a rake test task with the proper name" do
|
41
|
+
Rake::TestTask.expects(:new).with("test:foo:test_section")
|
42
|
+
subject.send(:test_task, *@args)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "#combo_test_task" do
|
47
|
+
should "create a rake task that requires a group of tasks" do
|
48
|
+
Rake::Task.expects(:define_task).
|
49
|
+
with("test:foo:test_section" => ["test:foo:1",
|
50
|
+
"test:foo:2"])
|
51
|
+
subject.send(:combo_test_task, *@args)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "#alias_test_task" do
|
56
|
+
should "create a rake task that requires one other task" do
|
57
|
+
Rake::Task.expects(:define_task).
|
58
|
+
with("test:foo:another_one" => "test:foo:one")
|
59
|
+
subject.send(:alias_test_task, "another_one", "one")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "#task_name" do
|
64
|
+
should "use the common pattern for all names expect blanks" do
|
65
|
+
task_name = subject.send(:task_name)
|
66
|
+
assert_equal "test:foo:whatever", task_name["whatever"]
|
67
|
+
assert_equal "test:foo", task_name[""]
|
68
|
+
assert_equal "test:foo", task_name[nil]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "TestSubset::Task Class" do
|
74
|
+
subject { TestSubset::Task }
|
75
|
+
|
76
|
+
context "#new" do
|
77
|
+
should "create a tesk task" do
|
78
|
+
subject.any_instance.expects(:test_task).
|
79
|
+
with("", "test/units/foo/*_test.rb")
|
80
|
+
subject.new(:foo, "test/units/foo/*_test.rb")
|
81
|
+
end
|
82
|
+
|
83
|
+
context "with a block" do
|
84
|
+
should "#units" do
|
85
|
+
subject.any_instance.expects(:units).with("foo/*")
|
86
|
+
subject.any_instance.expects(:functionals).with("foo/*")
|
87
|
+
subject.any_instance.expects(:integration).with("foo/*")
|
88
|
+
subject.any_instance.expects(:combo_test_task).times(4)
|
89
|
+
subject.any_instance.expects(:alias_test_task).times(3)
|
90
|
+
subject.new("foo") do |test|
|
91
|
+
test.units "foo/*"
|
92
|
+
test.functionals "foo/*"
|
93
|
+
test.integration "foo/*"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: test-subset
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jon Karna
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-06 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &2162261760 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2162261760
|
25
|
+
description: ''
|
26
|
+
email:
|
27
|
+
- ipg49vv2@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- Gemfile.lock
|
35
|
+
- README
|
36
|
+
- Rakefile
|
37
|
+
- lib/test-subset.rb
|
38
|
+
- lib/test-subset/version.rb
|
39
|
+
- test-subset.gemspec
|
40
|
+
- test/unit/test_subset_test.rb
|
41
|
+
homepage: https://github.com/jonkarna/test-subset
|
42
|
+
licenses: []
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
hash: -4096766038571747085
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
hash: -4096766038571747085
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project: test-subset
|
67
|
+
rubygems_version: 1.8.10
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: ''
|
71
|
+
test_files:
|
72
|
+
- test/unit/test_subset_test.rb
|