kicker 2.4.0 → 2.5.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.
@@ -1,21 +0,0 @@
1
- require File.expand_path('../../test_helper', __FILE__)
2
-
3
- describe "Kicker, concerning the default `could not handle file' callback" do
4
- after do
5
- Kicker.silent = false
6
- end
7
-
8
- it "should log that it could not handle the given files" do
9
- Kicker::Utils.expects(:log).with('')
10
- Kicker::Utils.expects(:log).with("Could not handle: /file/1, /file/2")
11
- Kicker::Utils.expects(:log).with('')
12
-
13
- Kicker.post_process_chain.last.call(%w{ /file/1 /file/2 })
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
21
- end
@@ -1,22 +0,0 @@
1
- require File.expand_path('../../test_helper', __FILE__)
2
-
3
- describe "The .kick handler" do
4
- it "should reset $LOADED_FEATURES and callback chains to state before loading .kick and reload .kick" do
5
- ReloadDotKick.save_state
6
-
7
- features_before_dot_kick = $LOADED_FEATURES.dup
8
- chains_before_dot_kick = Kicker.full_chain.map { |c| c.dup }
9
-
10
- ReloadDotKick.expects(:load).with('.kick').twice
11
-
12
- 2.times do
13
- require File.expand_path('../../fixtures/a_file_thats_reloaded', __FILE__)
14
- process {}
15
- ReloadDotKick.call(%w{ .kick })
16
- end
17
-
18
- $FROM_RELOADED_FILE.should == 2
19
- $LOADED_FEATURES.should == features_before_dot_kick
20
- Kicker.full_chain.should == chains_before_dot_kick
21
- end
22
- end
@@ -1,37 +0,0 @@
1
- require File.expand_path('../../test_helper', __FILE__)
2
-
3
- describe "Kicker, concerning the `execute a command-line' callback" do
4
- it "should parse the command and add the callback" do
5
- before = Kicker.pre_process_chain.length
6
-
7
- Kicker::Options.parse(%w{ -e ls })
8
- Kicker.pre_process_chain.length.should == before + 1
9
-
10
- Kicker::Options.parse(%w{ --execute ls })
11
- Kicker.pre_process_chain.length.should == before + 2
12
- end
13
-
14
- it "should call execute with the given command" do
15
- Kicker::Options.parse(%w{ -e ls })
16
-
17
- callback = Kicker.pre_process_chain.last
18
- callback.should.be.instance_of Proc
19
-
20
- Kicker::Utils.expects(:execute).with('sh -c "ls"')
21
-
22
- callback.call(%w{ /file/1 /file/2 }).should.not.be.instance_of Array
23
- end
24
-
25
- it "should clear the files array to halt the chain" do
26
- Kicker::Utils.stubs(:execute)
27
-
28
- files = %w{ /file/1 /file/2 }
29
- Kicker.pre_process_chain.last.call(files)
30
- files.should.be.empty
31
- end
32
-
33
- it "should run the command directly once Kicker is done loading" do
34
- callback = Kicker.pre_process_chain.last
35
- Kicker.startup_chain.should.include callback
36
- end
37
- end
@@ -1,29 +0,0 @@
1
- require File.expand_path('../../test_helper', __FILE__)
2
-
3
- before = Kicker.pre_process_chain.dup
4
- recipe :ignore
5
- IGNORE = (Kicker.pre_process_chain - before).first
6
-
7
- describe "The Ignore handler" do
8
- it "should remove files that match the given regexp" do
9
- ignore(/^fo{2}bar/)
10
-
11
- files = %w{ Rakefile foobar foobarbaz }
12
- IGNORE.call(files)
13
- files.should == %w{ Rakefile }
14
- end
15
-
16
- it "should remove files that match the given string" do
17
- ignore('bazbla')
18
-
19
- files = %w{ Rakefile bazbla bazblabla }
20
- IGNORE.call(files)
21
- files.should == %w{ Rakefile bazblabla }
22
- end
23
-
24
- it "should ignore a few file types by default" do
25
- files = %w{ Rakefile foo/bar/dev.log .svn/foo svn-commit.tmp .git/foo tmp }
26
- IGNORE.call(files)
27
- files.should == %w{ Rakefile }
28
- end
29
- end
@@ -1,31 +0,0 @@
1
- require File.expand_path('../../test_helper', __FILE__)
2
-
3
- before = Kicker.process_chain.dup
4
- recipe :jstest
5
- JSTEST = (Kicker.process_chain - before).first
6
-
7
- describe "The HeadlessSquirrel handler" do
8
- before do
9
- @files = %w{ Rakefile }
10
- end
11
-
12
- it "should match any test case files" do
13
- @files += %w{ test/javascripts/ui_test.html test/javascripts/admin_test.js }
14
-
15
- Kicker::Utils.expects(:execute).
16
- with("jstest test/javascripts/ui_test.html test/javascripts/admin_test.html")
17
-
18
- JSTEST.call(@files)
19
- @files.should == %w{ Rakefile }
20
- end
21
-
22
- it "should map public/javascripts libs to test/javascripts" do
23
- @files += %w{ public/javascripts/ui.js public/javascripts/admin.js }
24
-
25
- Kicker::Utils.expects(:execute).
26
- with("jstest test/javascripts/ui_test.html test/javascripts/admin_test.html")
27
-
28
- JSTEST.call(@files)
29
- @files.should == %w{ Rakefile }
30
- end
31
- end
@@ -1,186 +0,0 @@
1
- require File.expand_path('../../test_helper', __FILE__)
2
- recipe :rails
3
-
4
- class Kicker::Recipes::Rails
5
- class << self
6
- attr_accessor :tests_ran
7
- def run_tests(tests)
8
- self.tests_ran ||= []
9
- self.tests_ran << tests
10
- end
11
- end
12
- end
13
-
14
- describe "The Rails handler" do
15
- it "should return all controller tests when test_type is `test'" do
16
- tests = %w{ test.rb }
17
-
18
- File.use_original_exist = false
19
- File.existing_files = tests
20
-
21
- Dir.expects(:glob).with("test/functional/**/*_test.rb").returns(tests)
22
- Kicker::Recipes::Rails.all_controller_tests.should == tests
23
- end
24
-
25
- it "should return all controller tests when test_type is `spec'" do
26
- specs = %w{ spec.rb }
27
-
28
- File.use_original_exist = false
29
- File.existing_files = specs
30
-
31
- Kicker::Recipes::Ruby.test_type = 'spec'
32
- Kicker::Recipes::Ruby.test_cases_root = nil
33
-
34
- Dir.expects(:glob).with("spec/controllers/**/*_spec.rb").returns(specs)
35
- Kicker::Recipes::Rails.all_controller_tests.should == specs
36
- end
37
- end
38
-
39
- describe "The Rails schema handler" do
40
- before do
41
- # We assume the Rails schema handler is in the chain after the Rails handler
42
- # because it's defined in the same recipe
43
- @handler = Kicker.process_chain[Kicker.process_chain.index(Kicker::Recipes::Rails) + 1]
44
- end
45
-
46
- it "should prepare the test database if db/schema.rb is modified" do
47
- Kicker::Utils.expects(:execute).with('rake db:test:prepare')
48
- @handler.call(%w{ db/schema.rb })
49
- end
50
-
51
- it "should not prepare the test database if another file than db/schema.rb is modified" do
52
- Kicker::Utils.expects(:execute).never
53
- @handler.call(%w{ Rakefile })
54
- end
55
- end
56
-
57
- module SharedRailsHandlerHelper
58
- def should_match(files, tests, existing_files=nil)
59
- File.use_original_exist = false
60
- File.existing_files = existing_files || tests
61
- @files += files
62
- Kicker::Recipes::Rails.call(@files)
63
- @files.should == %w{ Rakefile }
64
- end
65
- end
66
-
67
- describe "An instance of the Rails handler, with test type `test'" do
68
- include SharedRailsHandlerHelper
69
-
70
- before do
71
- Kicker::Recipes::Ruby.reset!
72
- @files = %w{ Rakefile }
73
- end
74
-
75
- after do
76
- File.use_original_exist = true
77
- end
78
-
79
- it "should map model files to test/unit" do
80
- should_match %w{ app/models/member.rb app/models/article.rb },
81
- %w{ test/unit/member_test.rb test/unit/article_test.rb }
82
- end
83
-
84
- it "should map concern files to test/unit/concerns" do
85
- should_match %w{ app/concerns/authenticate.rb app/concerns/nested_resource.rb },
86
- %w{ test/unit/concerns/authenticate_test.rb test/unit/concerns/nested_resource_test.rb }
87
- end
88
-
89
- it "should map helper files to test/unit/helpers" do
90
- should_match %w{ app/helpers/members_helper.rb app/helpers/articles_helper.rb },
91
- %w{ test/unit/helpers/members_helper_test.rb test/unit/helpers/articles_helper_test.rb }
92
- end
93
-
94
- it "should map controller files to test/functional" do
95
- should_match %w{ app/controllers/application_controller.rb app/controllers/members_controller.rb },
96
- %w{ test/functional/application_controller_test.rb test/functional/members_controller_test.rb }
97
- end
98
-
99
- it "should map view templates to test/functional" do
100
- should_match %w{ app/views/members/index.html.erb app/views/admin/articles/show.html.erb },
101
- %w{ test/functional/members_controller_test.rb test/functional/admin/articles_controller_test.rb }
102
- end
103
-
104
- it "should run all functional tests when config/routes.rb is saved" do
105
- tests = %w{ test/functional/members_controller_test.rb test/functional/admin/articles_controller_test.rb }
106
- Kicker::Recipes::Rails.expects(:all_controller_tests).returns(tests)
107
- should_match %w{ config/routes.rb }, tests
108
- end
109
-
110
- it "should map lib files to test/lib" do
111
- should_match %w{ lib/money.rb lib/views/date.rb },
112
- %w{ test/lib/money_test.rb test/lib/views/date_test.rb }
113
- end
114
-
115
- it "should map fixtures to their unit, helper and functional tests if they exist" do
116
- tests = %w{ test/unit/member_test.rb test/unit/helpers/members_helper_test.rb test/functional/members_controller_test.rb }
117
- should_match %w{ test/fixtures/members.yml }, tests, []
118
- Kicker::Recipes::Rails.tests_ran.last.should == []
119
- end
120
-
121
- it "should map fixtures to their unit, helper and functional tests if they exist" do
122
- tests = %w{ test/unit/member_test.rb test/unit/helpers/members_helper_test.rb test/functional/members_controller_test.rb }
123
- should_match %w{ test/fixtures/members.yml }, tests
124
- Kicker::Recipes::Rails.tests_ran.last.should == tests
125
- end
126
- end
127
-
128
- describe "An instance of the Rails handler, with test type `spec'" do
129
- include SharedRailsHandlerHelper
130
-
131
- before do
132
- Kicker::Recipes::Ruby.reset!
133
- Kicker::Recipes::Ruby.test_type = 'spec'
134
- @files = %w{ Rakefile }
135
- end
136
-
137
- after do
138
- File.use_original_exist = true
139
- end
140
-
141
- it "should map model files to spec/models" do
142
- should_match %w{ app/models/member.rb app/models/article.rb },
143
- %w{ spec/models/member_spec.rb spec/models/article_spec.rb }
144
- end
145
-
146
- it "should map concern files to spec/models/concerns" do
147
- should_match %w{ app/concerns/authenticate.rb app/concerns/nested_resource.rb },
148
- %w{ spec/models/concerns/authenticate_spec.rb spec/models/concerns/nested_resource_spec.rb }
149
- end
150
-
151
- it "should map helper files to spec/helpers" do
152
- should_match %w{ app/helpers/members_helper.rb app/helpers/articles_helper.rb },
153
- %w{ spec/helpers/members_helper_spec.rb spec/helpers/articles_helper_spec.rb }
154
- end
155
-
156
- it "should map controller files to spec/controllers" do
157
- should_match %w{ app/controllers/application_controller.rb app/controllers/members_controller.rb },
158
- %w{ spec/controllers/application_controller_spec.rb spec/controllers/members_controller_spec.rb }
159
- end
160
-
161
- it "should map view templates to spec/controllers" do
162
- should_match %w{ app/views/members/index.html.erb app/views/admin/articles/show.html.erb },
163
- %w{ spec/controllers/members_controller_spec.rb spec/controllers/admin/articles_controller_spec.rb }
164
- end
165
-
166
- it "should run all controller tests when config/routes.rb is saved" do
167
- specs = %w{ spec/controllers/members_controller_test.rb spec/controllers/admin/articles_controller_test.rb }
168
- Kicker::Recipes::Rails.expects(:all_controller_tests).returns(specs)
169
- should_match %w{ config/routes.rb }, specs
170
- end
171
-
172
- it "should map lib files to spec/lib" do
173
- should_match %w{ lib/money.rb lib/views/date.rb },
174
- %w{ spec/lib/money_spec.rb spec/lib/views/date_spec.rb }
175
- end
176
-
177
- it "should map fixtures to their model, helper and controller specs" do
178
- specs = %w{ spec/models/member_spec.rb spec/helpers/members_helper_spec.rb spec/controllers/members_controller_spec.rb }
179
- should_match %w{ spec/fixtures/members.yml }, specs
180
- end
181
-
182
- it "should map fixtures to their model, helper and controller specs if they exist" do
183
- specs = %w{ spec/models/member_spec.rb spec/helpers/members_helper_spec.rb spec/controllers/members_controller_spec.rb }
184
- should_match %w{ spec/fixtures/members.yml }, specs
185
- end
186
- end
@@ -1,162 +0,0 @@
1
- require File.expand_path('../../test_helper', __FILE__)
2
- recipe :ruby
3
-
4
- class Kicker::Recipes::Ruby
5
- class << self
6
- attr_accessor :executed
7
- attr_accessor :blocks
8
- def execute(command, &block)
9
- self.executed ||= []
10
- self.blocks ||= []
11
-
12
- self.executed << command
13
- self.blocks << block
14
- end
15
- end
16
- end
17
-
18
- describe "The Ruby handler" do
19
- before do
20
- @handler = Kicker::Recipes::Ruby
21
- @handler.reset!
22
- end
23
-
24
- after do
25
- File.use_original_exist = true
26
- end
27
-
28
- it "should instantiate a handler instance when called" do
29
- tests = %w{ test/1_test.rb Rakefile test/namespace/2_test.rb }
30
- instance = @handler.new(tests)
31
- @handler.expects(:new).with(tests).returns(instance)
32
- @handler.call(tests)
33
- end
34
-
35
- it "should discover whether to use `ruby' or `spec' as the test_type" do
36
- File.use_original_exist = false
37
-
38
- File.existing_files = []
39
- @handler.test_type.should == 'test'
40
-
41
- @handler.reset!
42
-
43
- File.existing_files = ['spec']
44
- @handler.test_type.should == 'spec'
45
- end
46
-
47
- it "should run the given tests with a test-unit runner" do
48
- @handler.run_tests(%w{ test/1_test.rb test/namespace/2_test.rb })
49
- @handler.executed.last.should == "ruby -r test/1_test.rb -r test/namespace/2_test.rb -e ''"
50
- end
51
-
52
- it "should run the given tests with a spec runner" do
53
- @handler.test_type = 'spec'
54
- @handler.run_tests(%w{ test/1_test.rb test/namespace/2_test.rb })
55
- @handler.executed.last.should == "spec test/1_test.rb test/namespace/2_test.rb"
56
- end
57
-
58
- it "should not try to run the tests if none were given" do
59
- @handler.executed = []
60
- @handler.run_tests([])
61
- @handler.executed.should.be.empty
62
- end
63
-
64
- it "should be possible to override the bin path" do
65
- @handler.runner_bin = '/some/other/runner'
66
- @handler.run_tests(%w{ test/1_test.rb test/namespace/2_test.rb })
67
- @handler.executed.last.should == "/some/other/runner -r test/1_test.rb -r test/namespace/2_test.rb -e ''"
68
- end
69
-
70
- it "should set the alternative ruby bin path" do
71
- Kicker::Options.parse(%w{ -b /opt/ruby-1.9.2/bin/ruby })
72
- @handler.runner_bin.should == '/opt/ruby-1.9.2/bin/ruby'
73
-
74
- @handler.reset!
75
-
76
- Kicker::Options.parse(%w{ --ruby /opt/ruby-1.9.2/bin/ruby })
77
- @handler.runner_bin.should == '/opt/ruby-1.9.2/bin/ruby'
78
- end
79
-
80
- it "should be possible to add runner options when test_type is `test'" do
81
- @handler.test_type = 'test'
82
- @handler.test_options << '-I ./other'
83
- @handler.run_tests(%w{ test/1_test.rb })
84
- @handler.executed.last.should == "ruby -I ./other -r test/1_test.rb -e ''"
85
- end
86
-
87
- it "should be possible to add runner options when test_type is `spec'" do
88
- @handler.test_type = 'spec'
89
- @handler.test_options << '-I ./other'
90
- @handler.run_tests(%w{ spec/1_spec.rb })
91
- @handler.executed.last.should == "spec -I ./other spec/1_spec.rb"
92
- end
93
-
94
- it "should only show the last line of the output when growling when running test_type is `test'" do
95
- @handler.run_with_test_runner(%w{ test/1_test.rb test/namespace/2_test.rb })
96
- result = @handler.blocks.last.call(mock('status', :output => "foo\nall pass", :after? => true, :growl? => true))
97
- result.should == 'all pass'
98
- end
99
-
100
- it "should only show the last line of the output when growling when running test_type is `spec'" do
101
- @handler.run_with_spec_runner(%w{ spec/1_spec.rb spec/namespace/2_spec.rb })
102
- result = @handler.blocks.last.call(mock('status', :output => "foo\nall pass", :after? => true, :growl? => true))
103
- result.should == 'all pass'
104
- end
105
- end
106
-
107
- %w{ test spec }.each do |type|
108
- describe "An instance of the Ruby handler, with test type `#{type}'" do
109
- before do
110
- @handler = Kicker::Recipes::Ruby
111
- @handler.test_type = type
112
- @handler.test_cases_root = type
113
-
114
- File.use_original_exist = false
115
- File.existing_files = %W(#{type}/1_#{type}.rb #{type}/namespace/2_#{type}.rb)
116
- end
117
-
118
- after do
119
- File.use_original_exist = true
120
- end
121
-
122
- it "should match any test case files" do
123
- files = %w(Rakefile) + File.existing_files
124
- handler = @handler.new(files)
125
- handler.handle!
126
-
127
- handler.tests.should == File.existing_files
128
- files.should == %W{ Rakefile }
129
- end
130
-
131
- it "should match files in ./lib" do
132
- files = %w(Rakefile) + File.existing_files
133
- handler = @handler.new(files)
134
- handler.handle!
135
-
136
- handler.tests.should == File.existing_files
137
- files.should == %w{ Rakefile }
138
- end
139
-
140
- it "should match lib tests in the test root as well" do
141
- File.existing_files = %W(#{type}/1_#{type}.rb #{type}/2_#{type}.rb)
142
-
143
- files = %W{ Rakefile lib/1.rb lib/namespace/2.rb }
144
- handler = @handler.new(files)
145
- handler.handle!
146
-
147
- handler.tests.should == %W{ #{type}/1_#{type}.rb #{type}/2_#{type}.rb }
148
- files.should == %W{ Rakefile }
149
- end
150
-
151
- it "should check if a different test case root" do
152
- @handler.test_cases_root = 'test/cases'
153
-
154
- files = %W{ Rakefile test/cases/1_#{type}.rb test/cases/namespace/2_#{type}.rb }
155
- handler = @handler.new(files)
156
- handler.handle!
157
-
158
- handler.tests.should == %W{ test/cases/1_#{type}.rb test/cases/namespace/2_#{type}.rb }
159
- files.should == %W{ Rakefile }
160
- end
161
- end
162
- end