kicker 2.1.0 → 2.2.0

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.
Files changed (43) hide show
  1. data/.gitignore +10 -0
  2. data/.kick +37 -0
  3. data/README.rdoc +24 -21
  4. data/Rakefile +0 -1
  5. data/TODO.rdoc +4 -34
  6. data/VERSION +1 -0
  7. data/html/images/kikker.jpg +0 -0
  8. data/kicker.gemspec +106 -0
  9. data/lib/kicker.rb +46 -60
  10. data/lib/kicker/callback_chain.rb +4 -4
  11. data/lib/kicker/core_ext.rb +9 -1
  12. data/lib/kicker/growl.rb +54 -19
  13. data/lib/kicker/log_status_helper.rb +38 -0
  14. data/lib/kicker/options.rb +59 -34
  15. data/lib/kicker/recipes.rb +58 -0
  16. data/lib/kicker/recipes/could_not_handle_file.rb +5 -3
  17. data/lib/kicker/recipes/dot_kick.rb +17 -5
  18. data/lib/kicker/recipes/execute_cli_command.rb +1 -1
  19. data/lib/kicker/recipes/ignore.rb +8 -6
  20. data/lib/kicker/recipes/jstest.rb +7 -5
  21. data/lib/kicker/recipes/rails.rb +108 -43
  22. data/lib/kicker/recipes/ruby.rb +155 -0
  23. data/lib/kicker/utils.rb +36 -32
  24. data/test/callback_chain_test.rb +1 -1
  25. data/test/core_ext_test.rb +15 -5
  26. data/test/filesystem_change_test.rb +1 -1
  27. data/test/growl_test.rb +85 -0
  28. data/test/initialization_test.rb +25 -56
  29. data/test/log_status_helper_test.rb +56 -0
  30. data/test/options_test.rb +50 -12
  31. data/test/recipes/could_not_handle_file_test.rb +10 -0
  32. data/test/recipes/dot_kick_test.rb +1 -5
  33. data/test/recipes/execute_cli_command_test.rb +3 -3
  34. data/test/recipes/ignore_test.rb +1 -1
  35. data/test/recipes/jstest_test.rb +1 -1
  36. data/test/recipes/rails_test.rb +118 -18
  37. data/test/recipes/ruby_test.rb +154 -0
  38. data/test/recipes_test.rb +39 -0
  39. data/test/test_helper.rb +1 -1
  40. data/test/utils_test.rb +103 -48
  41. metadata +19 -6
  42. data/VERSION.yml +0 -4
  43. data/lib/kicker/validate.rb +0 -24
@@ -0,0 +1,56 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+
3
+ describe "Kicker::LogStatus" do
4
+ yielded = nil
5
+
6
+ before do
7
+ @status = Kicker::LogStatusHelper.new(proc { |s| yielded = s; 'out' if s.growl? }, 'ls -l')
8
+ end
9
+
10
+ it "should return whether or not it's for a stdout logger" do
11
+ @status.call(:stdout)
12
+ yielded.should.be.stdout
13
+ yielded.should.not.be.growl
14
+ end
15
+
16
+ it "should return whether or not it's for a growl logger" do
17
+ @status.call(:growl)
18
+ yielded.should.not.be.stdout
19
+ yielded.should.be.growl
20
+ end
21
+
22
+ it "should return the command" do
23
+ @status.call(:growl)
24
+ yielded.command.should == 'ls -l'
25
+ end
26
+
27
+ it "should return if it's before executing the command" do
28
+ @status.call(:growl)
29
+ yielded.should.be.before
30
+ yielded.should.be.not.after
31
+ end
32
+
33
+ it "should return if it's after executing the command" do
34
+ @status.result('output', true, 0)
35
+ @status.call(:growl)
36
+ yielded.should.not.be.before
37
+ yielded.should.be.after
38
+ end
39
+
40
+ it "should return the output and status" do
41
+ @status.result('output', true, 123)
42
+ @status.call(:growl)
43
+ yielded.output.should == "output"
44
+ yielded.should.be.success
45
+ yielded.exit_code.should.be 123
46
+ end
47
+
48
+ it "should set the logger type, call the proc with self, and return the output" do
49
+ @status.call(:growl).should == "out"
50
+ end
51
+
52
+ it "should not try to call the block if none was given and return nil" do
53
+ status = Kicker::LogStatusHelper.new(nil, 'ls -l')
54
+ status.call(:growl).should.be nil
55
+ end
56
+ end
@@ -1,30 +1,68 @@
1
1
  require File.expand_path('../test_helper', __FILE__)
2
2
 
3
- describe "Kicker.parse_options" do
3
+ describe "Kicker::Options.parse" do
4
+ after do
5
+ Kicker.latency = 1
6
+ Kicker.paths = %w{ . }
7
+ Kicker.silent = false
8
+ Kicker.quiet = false
9
+ Kicker::Growl.use = true
10
+ Kicker::Growl.command = nil
11
+ end
12
+
4
13
  it "should parse the paths" do
5
- Kicker.parse_options([])[:paths].should.be nil
14
+ Kicker::Options.parse([])
15
+ Kicker.paths.should == %w{ . }
16
+
17
+ Kicker::Options.parse(%w{ /some/file.rb })
18
+ Kicker.paths.should == %w{ /some/file.rb }
6
19
 
7
- Kicker.parse_options(%w{ /some/file.rb })[:paths].should == %w{ /some/file.rb }
8
- Kicker.parse_options(%w{ /some/file.rb /a/dir /and/some/other/file.rb })[:paths].should ==
9
- %w{ /some/file.rb /a/dir /and/some/other/file.rb }
20
+ Kicker::Options.parse(%w{ /some/file.rb /a/dir /and/some/other/file.rb })
21
+ Kicker.paths.should == %w{ /some/file.rb /a/dir /and/some/other/file.rb }
10
22
  end
11
23
 
12
24
  it "should parse if growl shouldn't be used" do
13
- Kicker.parse_options([])[:growl].should == true
14
- Kicker.parse_options(%w{ --no-growl })[:growl].should == false
25
+ Kicker::Options.parse([])
26
+ Kicker::Growl.should.use
27
+
28
+ Kicker::Options.parse(%w{ --no-growl })
29
+ Kicker::Growl.should.not.use
30
+ end
31
+
32
+ it "should parse if we should keep output to a minimum" do
33
+ Kicker::Options.parse([])
34
+ Kicker.should.not.be.silent
35
+
36
+ Kicker::Options.parse(%w{ -s })
37
+ Kicker.should.be.silent
38
+ end
39
+
40
+ it 'should parse whether or not to run in quiet mode and enable silent mode if quiet' do
41
+ Kicker::Options.parse([])
42
+ Kicker.should.not.be.quiet
43
+ Kicker.should.not.be.silent
44
+
45
+ Kicker::Options.parse(%w{ --quiet })
46
+ Kicker.should.be.quiet
47
+ Kicker.should.be.silent
15
48
  end
16
49
 
17
50
  it "should parse the Growl command to use when the user clicks the Growl succeeded message" do
18
- Kicker.parse_options(%w{ --growl-command ls })[:growl_command].should == 'ls'
51
+ Kicker::Options.parse(%w{ --growl-command ls })
52
+ Kicker::Growl.command.should == 'ls'
19
53
  end
20
54
 
21
55
  it "should parse the latency to pass to FSEvents" do
22
- Kicker.parse_options(%w{ -l 2.5 })[:latency].should == 2.5
23
- Kicker.parse_options(%w{ --latency 3.5 })[:latency].should == 3.5
56
+ Kicker::Options.parse(%w{ -l 2.5 })
57
+ Kicker.latency.should == 2.5
58
+
59
+ Kicker::Options.parse(%w{ --latency 3.5 })
60
+ Kicker.latency.should == 3.5
24
61
  end
25
62
 
26
63
  it "should parse recipe requires" do
27
- Kicker.parse_options(%w{ -r rails -r jstest })[:recipes].should == %w{ rails jstest }
28
- Kicker.parse_options(%w{ --recipe rails --recipe jstest })[:recipes].should == %w{ rails jstest }
64
+ Kicker::Recipes.expects(:recipe).with('rails')
65
+ Kicker::Recipes.expects(:recipe).with('jstest')
66
+ Kicker::Options.parse(%w{ -r rails --recipe jstest })
29
67
  end
30
68
  end
@@ -1,6 +1,10 @@
1
1
  require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  describe "Kicker, concerning the default `could not handle file' callback" do
4
+ after do
5
+ Kicker.silent = false
6
+ end
7
+
4
8
  it "should log that it could not handle the given files" do
5
9
  Kicker::Utils.expects(:log).with('')
6
10
  Kicker::Utils.expects(:log).with("Could not handle: /file/1, /file/2")
@@ -8,4 +12,10 @@ describe "Kicker, concerning the default `could not handle file' callback" do
8
12
 
9
13
  Kicker.post_process_chain.last.call(%w{ /file/1 /file/2 })
10
14
  end
15
+
16
+ it "should not log in silent mode" do
17
+ Kicker.silent = true
18
+ Kicker::Utils.expects(:log).never
19
+ Kicker.post_process_chain.last.call(%w{ /file/1 /file/2 })
20
+ end
11
21
  end
@@ -1,9 +1,5 @@
1
1
  require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
- before = Kicker.process_chain.dup
4
- require 'kicker/recipes/dot_kick'
5
- DOT_KICK = (Kicker.process_chain - before).first
6
-
7
3
  describe "The .kick handler" do
8
4
  it "should reset $LOADED_FEATURES and callback chains to state before loading .kick and reload .kick" do
9
5
  ReloadDotKick.save_state
@@ -16,7 +12,7 @@ describe "The .kick handler" do
16
12
  2.times do
17
13
  require File.expand_path('../../fixtures/a_file_thats_reloaded', __FILE__)
18
14
  process {}
19
- DOT_KICK.call(%w{ .kick })
15
+ ReloadDotKick.call(%w{ .kick })
20
16
  end
21
17
 
22
18
  $FROM_RELOADED_FILE.should == 2
@@ -4,15 +4,15 @@ describe "Kicker, concerning the `execute a command-line' callback" do
4
4
  it "should parse the command and add the callback" do
5
5
  before = Kicker.pre_process_chain.length
6
6
 
7
- Kicker.parse_options(%w{ -e ls })
7
+ Kicker::Options.parse(%w{ -e ls })
8
8
  Kicker.pre_process_chain.length.should == before + 1
9
9
 
10
- Kicker.parse_options(%w{ --execute ls })
10
+ Kicker::Options.parse(%w{ --execute ls })
11
11
  Kicker.pre_process_chain.length.should == before + 2
12
12
  end
13
13
 
14
14
  it "should call execute with the given command" do
15
- Kicker.parse_options(%w{ -e ls })
15
+ Kicker::Options.parse(%w{ -e ls })
16
16
 
17
17
  callback = Kicker.pre_process_chain.last
18
18
  callback.should.be.instance_of Proc
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  before = Kicker.pre_process_chain.dup
4
- require 'kicker/recipes/ignore'
4
+ recipe :ignore
5
5
  IGNORE = (Kicker.pre_process_chain - before).first
6
6
 
7
7
  describe "The Ignore handler" do
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  before = Kicker.process_chain.dup
4
- require 'kicker/recipes/jstest'
4
+ recipe :jstest
5
5
  JSTEST = (Kicker.process_chain - before).first
6
6
 
7
7
  describe "The HeadlessSquirrel handler" do
@@ -1,24 +1,62 @@
1
1
  require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  before = Kicker.process_chain.dup
4
- require 'kicker/recipes/rails'
5
- RAILS = (Kicker.process_chain - before).first
4
+ recipe :rails
5
+ RAILS_FILES, RAILS_SCHEMA = (Kicker.process_chain - before).first(2)
6
6
 
7
7
  describe "The Rails helper module" do
8
- it "should return all functional tests" do
8
+ after do
9
+ Ruby.test_type = nil
10
+ Ruby.test_cases_root = nil
11
+ end
12
+
13
+ it "should return all controller tests when test_type is `test'" do
9
14
  Dir.expects(:glob).with("test/functional/**/*_test.rb").returns(%w{ test.rb })
10
- Rails.all_functional_tests.should == %w{ test.rb }
15
+ Rails.all_controller_tests.should == %w{ test.rb }
16
+ end
17
+
18
+ it "should return all controller tests when test_type is `spec'" do
19
+ Ruby.test_type = 'spec'
20
+ Ruby.test_cases_root = nil
21
+
22
+ Dir.expects(:glob).with("spec/controllers/**/*_spec.rb").returns(%w{ spec.rb })
23
+ Rails.all_controller_tests.should == %w{ spec.rb }
11
24
  end
12
25
  end
13
26
 
14
- describe "The rails handler" do
15
- before do
16
- @files = %w{ Rakefile }
27
+ describe "The misc Rails handlers" do
28
+ it "should prepare the test database if db/schema.rb is modified" do
29
+ Kicker::Utils.expects(:execute).with('rake db:test:prepare')
30
+ RAILS_SCHEMA.call(%w{ db/schema.rb })
17
31
  end
18
32
 
19
- it "should match any test case files" do
20
- should_match %w{ test/1_test.rb test/namespace/2_test.rb },
21
- %w{ test/1_test.rb test/namespace/2_test.rb }
33
+ it "should not prepare the test database if another file than db/schema.rb is modified" do
34
+ Kicker::Utils.expects(:execute).never
35
+ RAILS_SCHEMA.call(%w{ Rakefile })
36
+ end
37
+ end
38
+
39
+ module SharedRailsHandlerHelper
40
+ def should_match(files, tests)
41
+ @files += files
42
+
43
+ tests.each do |test|
44
+ File.stubs(:exist?).with(test).returns(true)
45
+ end
46
+
47
+ Rails.expects(:run_tests).with(tests)
48
+ RAILS_FILES.call(@files)
49
+ @files.should == %w{ Rakefile }
50
+ end
51
+ end
52
+
53
+ describe "An instance of the Rails handler, with test type `test'" do
54
+ include SharedRailsHandlerHelper
55
+
56
+ before do
57
+ Ruby.test_type = 'test'
58
+ File.stubs(:exist?).with('spec').returns(false)
59
+ @files = %w{ Rakefile }
22
60
  end
23
61
 
24
62
  it "should map model files to test/unit" do
@@ -48,7 +86,7 @@ describe "The rails handler" do
48
86
 
49
87
  it "should run all functional tests when config/routes.rb is saved" do
50
88
  tests = %w{ test/functional/members_controller_test.rb test/functional/admin/articles_controller_test.rb }
51
- Rails.expects(:all_functional_tests).returns(tests)
89
+ Rails.expects(:all_controller_tests).returns(tests)
52
90
  should_match %w{ config/routes.rb }, tests
53
91
  end
54
92
 
@@ -57,17 +95,79 @@ describe "The rails handler" do
57
95
  %w{ test/lib/money_test.rb test/lib/views/date_test.rb }
58
96
  end
59
97
 
60
- private
61
-
62
- def should_match(files, tests)
63
- @files += files
98
+ it "should map fixtures to their unit, helper and functional tests if they exist" do
99
+ tests = %w{ test/unit/member_test.rb test/unit/helpers/members_helper_test.rb test/functional/members_controller_test.rb }
100
+ File.stubs(:exist?).returns(false)
64
101
 
102
+ expected_tests = []
65
103
  tests.each do |test|
104
+ expected_tests << test
66
105
  File.stubs(:exist?).with(test).returns(true)
106
+ should_match %w{ test/fixtures/members.yml }, expected_tests
67
107
  end
108
+ end
109
+ end
110
+
111
+ describe "An instance of the Rails handler, with test type `spec'" do
112
+ include SharedRailsHandlerHelper
113
+
114
+ before do
115
+ Ruby.test_type = Ruby.runner_bin = Ruby.test_cases_root = nil
116
+ File.stubs(:exist?).with('spec').returns(true)
117
+ @files = %w{ Rakefile }
118
+ end
119
+
120
+ it "should map model files to spec/models" do
121
+ should_match %w{ app/models/member.rb app/models/article.rb },
122
+ %w{ spec/models/member_spec.rb spec/models/article_spec.rb }
123
+ end
124
+
125
+ it "should map concern files to spec/models/concerns" do
126
+ should_match %w{ app/concerns/authenticate.rb app/concerns/nested_resource.rb },
127
+ %w{ spec/models/concerns/authenticate_spec.rb spec/models/concerns/nested_resource_spec.rb }
128
+ end
129
+
130
+ it "should map helper files to spec/helpers" do
131
+ should_match %w{ app/helpers/members_helper.rb app/helpers/articles_helper.rb },
132
+ %w{ spec/helpers/members_helper_spec.rb spec/helpers/articles_helper_spec.rb }
133
+ end
134
+
135
+ it "should map controller files to spec/controllers" do
136
+ should_match %w{ app/controllers/application_controller.rb app/controllers/members_controller.rb },
137
+ %w{ spec/controllers/application_controller_spec.rb spec/controllers/members_controller_spec.rb }
138
+ end
139
+
140
+ it "should map view templates to spec/controllers" do
141
+ should_match %w{ app/views/members/index.html.erb app/views/admin/articles/show.html.erb },
142
+ %w{ spec/controllers/members_controller_spec.rb spec/controllers/admin/articles_controller_spec.rb }
143
+ end
144
+
145
+ it "should run all controller tests when config/routes.rb is saved" do
146
+ specs = %w{ spec/controllers/members_controller_test.rb spec/controllers/admin/articles_controller_test.rb }
147
+ Rails.expects(:all_controller_tests).returns(specs)
148
+ should_match %w{ config/routes.rb }, specs
149
+ end
150
+
151
+ it "should map lib files to spec/lib" do
152
+ should_match %w{ lib/money.rb lib/views/date.rb },
153
+ %w{ spec/lib/money_spec.rb spec/lib/views/date_spec.rb }
154
+ end
155
+
156
+ it "should map fixtures to their model, helper and controller specs" do
157
+ specs = %w{ spec/models/member_spec.rb spec/helpers/members_helper_spec.rb spec/controllers/members_controller_spec.rb }
158
+ should_match %w{ spec/fixtures/members.yml }, specs
159
+ end
160
+
161
+ it "should map fixtures to their model, helper and controller specs if they exist" do
162
+ Ruby.test_type = 'spec'
163
+ specs = %w{ spec/models/member_spec.rb spec/helpers/members_helper_spec.rb spec/controllers/members_controller_spec.rb }
164
+ File.stubs(:exist?).returns(false)
68
165
 
69
- Kicker::Utils.expects(:run_ruby_tests).with(tests)
70
- RAILS.call(@files)
71
- @files.should == %w{ Rakefile }
166
+ expected_specs = []
167
+ specs.each do |spec|
168
+ expected_specs << spec
169
+ File.stubs(:exist?).with(spec).returns(true)
170
+ should_match %w{ spec/fixtures/members.yml }, expected_specs
171
+ end
72
172
  end
73
173
  end
@@ -0,0 +1,154 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ before = Kicker.process_chain.dup
4
+ recipe :ruby
5
+ RUBY_FILES = (Kicker.process_chain - before).first
6
+
7
+ class Ruby
8
+ def self.execute(command, &block)
9
+ @block = block
10
+ end
11
+
12
+ def self.execute_block
13
+ @block
14
+ end
15
+ end
16
+
17
+ describe "The Ruby handler" do
18
+ before do
19
+ Ruby.test_type = nil
20
+ Ruby.runner_bin = nil
21
+ Ruby.test_options = []
22
+ end
23
+
24
+ after do
25
+ Ruby.test_type = 'test'
26
+ Ruby.runner_bin = nil
27
+ Ruby.test_options = []
28
+ end
29
+
30
+ it "should instantiate a Ruby instance" do
31
+ handler = mock('Ruby', :handle! => nil, :tests => %w{ test/1_test.rb test/namespace/2_test.rb })
32
+ Ruby.expects(:new).with(%w{ test/1_test.rb Rakefile test/namespace/2_test.rb }).returns(handler)
33
+ Ruby.expects(:run_tests).with(%w{ test/1_test.rb test/namespace/2_test.rb })
34
+ RUBY_FILES.call(%w{ test/1_test.rb Rakefile test/namespace/2_test.rb })
35
+ end
36
+
37
+ it "should discover whether to use `ruby' or `spec' as the test_type" do
38
+ File.expects(:exist?).with('spec').returns(false)
39
+ Ruby.test_type.should == 'test'
40
+
41
+ Ruby.test_type = nil
42
+ File.expects(:exist?).with('spec').returns(true)
43
+ Ruby.test_type.should == 'spec'
44
+ end
45
+
46
+ it "should run the given tests with a test-unit runner" do
47
+ Ruby.expects(:execute).with("ruby -r test/1_test.rb -r test/namespace/2_test.rb -e ''")
48
+ Ruby.run_tests(%w{ test/1_test.rb test/namespace/2_test.rb })
49
+ end
50
+
51
+ it "should run the given tests with a spec runner" do
52
+ Ruby.stubs(:test_type).returns('spec')
53
+ Ruby.expects(:execute).with("spec spec/1_spec.rb spec/namespace/2_spec.rb")
54
+ Ruby.run_tests(%w{ spec/1_spec.rb spec/namespace/2_spec.rb })
55
+ end
56
+
57
+ it "should not try to run the tests if none were given" do
58
+ Ruby.expects(:execute).never
59
+ Ruby.run_tests([])
60
+ end
61
+
62
+ it "should be possible to override the bin path" do
63
+ Ruby.runner_bin = '/some/other/runner'
64
+ Ruby.expects(:execute).with("/some/other/runner -r test/1_test.rb -r test/namespace/2_test.rb -e ''")
65
+ Ruby.run_tests(%w{ test/1_test.rb test/namespace/2_test.rb })
66
+ end
67
+
68
+ it "should set the alternative ruby bin path" do
69
+ Kicker::Options.parse(%w{ -b /opt/ruby-1.9.2/bin/ruby })
70
+ Ruby.runner_bin.should == '/opt/ruby-1.9.2/bin/ruby'
71
+
72
+ Ruby.runner_bin = nil
73
+ Kicker::Options.parse(%w{ --ruby /opt/ruby-1.9.2/bin/ruby })
74
+ Ruby.runner_bin.should == '/opt/ruby-1.9.2/bin/ruby'
75
+ end
76
+
77
+ it "should be possible to add runner options when test_type is `test'" do
78
+ Ruby.test_type = 'test'
79
+ Ruby.test_options << '-I ./other'
80
+ Ruby.expects(:execute).with("ruby -I ./other -r test/1_test.rb -e ''")
81
+ Ruby.run_tests(%w{ test/1_test.rb })
82
+ end
83
+
84
+ it "should be possible to add runner options when test_type is `spec'" do
85
+ Ruby.test_type = 'spec'
86
+ Ruby.test_options << '-I ./other'
87
+ Ruby.expects(:execute).with("spec -I ./other spec/1_spec.rb")
88
+ Ruby.run_tests(%w{ spec/1_spec.rb })
89
+ end
90
+
91
+ it "should only show the last line of the output when growling when running test_type is `test'" do
92
+ Ruby.run_with_test_runner(%w{ test/1_test.rb test/namespace/2_test.rb })
93
+ result = Ruby.execute_block.call(mock('status', :output => "foo\nall pass", :after? => true, :growl? => true))
94
+ result.should == 'all pass'
95
+ end
96
+
97
+ it "should only show the last line of the output when growling when running test_type is `spec'" do
98
+ Ruby.run_with_spec_runner(%w{ spec/1_spec.rb spec/namespace/2_spec.rb })
99
+ result = Ruby.execute_block.call(mock('status', :output => "foo\nall pass", :after? => true, :growl? => true))
100
+ result.should == 'all pass'
101
+ end
102
+ end
103
+
104
+ %w{ test spec }.each do |type|
105
+ describe "An instance of the Ruby handler, with test type `#{type}'" do
106
+ before do
107
+ Ruby.stubs(:test_type).returns(type)
108
+ Ruby.stubs(:test_cases_root).returns(type)
109
+ File.stubs(:exist?).with("#{type}/1_#{type}.rb").returns(true)
110
+ File.stubs(:exist?).with("#{type}/namespace/2_#{type}.rb").returns(true)
111
+ end
112
+
113
+ it "should match any test case files" do
114
+ files = %W{ Rakefile #{type}/1_#{type}.rb #{type}/namespace/2_#{type}.rb }
115
+ handler = Ruby.new(files)
116
+ handler.handle!
117
+
118
+ handler.tests.should == %W{ #{type}/1_#{type}.rb #{type}/namespace/2_#{type}.rb }
119
+ files.should == %W{ Rakefile }
120
+ end
121
+
122
+ it "should match files in ./lib" do
123
+ files = %W{ Rakefile lib/1.rb lib/namespace/2.rb }
124
+ handler = Ruby.new(files)
125
+ handler.handle!
126
+
127
+ handler.tests.should == %W{ #{type}/1_#{type}.rb #{type}/namespace/2_#{type}.rb }
128
+ files.should == %w{ Rakefile }
129
+ end
130
+
131
+ it "should match lib tests in the test root as well" do
132
+ File.stubs(:exist?).with("#{type}/namespace/2_#{type}.rb").returns(false)
133
+ File.stubs(:exist?).with("#{type}/2_#{type}.rb").returns(true)
134
+
135
+ files = %W{ Rakefile lib/1.rb lib/namespace/2.rb }
136
+ handler = Ruby.new(files)
137
+ handler.handle!
138
+
139
+ handler.tests.should == %W{ #{type}/1_#{type}.rb #{type}/2_#{type}.rb }
140
+ files.should == %W{ Rakefile }
141
+ end
142
+
143
+ it "should check if a different test case root" do
144
+ Ruby.stubs(:test_cases_root).returns('test/cases')
145
+
146
+ files = %W{ Rakefile test/cases/1_#{type}.rb test/cases/namespace/2_#{type}.rb }
147
+ handler = Ruby.new(files)
148
+ handler.handle!
149
+
150
+ handler.tests.should == %W{ test/cases/1_#{type}.rb test/cases/namespace/2_#{type}.rb }
151
+ files.should == %W{ Rakefile }
152
+ end
153
+ end
154
+ end