infinity_test 0.2.0 → 1.0.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 (72) hide show
  1. data/.gitignore +3 -0
  2. data/.infinity_test +30 -2
  3. data/.rspec +2 -0
  4. data/.rvmrc +1 -1
  5. data/Gemfile +10 -2
  6. data/Gemfile.lock +52 -12
  7. data/History.markdown +86 -2
  8. data/LICENSE.txt +22 -0
  9. data/Rakefile +25 -9
  10. data/Readme.markdown +47 -23
  11. data/TODO.markdown +12 -0
  12. data/Tasks +2 -3
  13. data/VERSION.yml +2 -2
  14. data/bin/infinity_test +1 -1
  15. data/features/heuristics.feature +23 -0
  16. data/features/support/env.rb +2 -0
  17. data/images/fuuu/failure.png +0 -0
  18. data/images/fuuu/pending.png +0 -0
  19. data/images/fuuu/sucess.png +0 -0
  20. data/infinity_test.gemspec +62 -29
  21. data/lib/infinity_test.rb +29 -9
  22. data/lib/infinity_test/application.rb +222 -68
  23. data/lib/infinity_test/application_library/rails.rb +94 -0
  24. data/lib/infinity_test/application_library/rubygems.rb +43 -0
  25. data/lib/infinity_test/binary_path.rb +30 -8
  26. data/lib/infinity_test/builder.rb +56 -0
  27. data/lib/infinity_test/command.rb +18 -24
  28. data/lib/infinity_test/configuration.rb +96 -44
  29. data/lib/infinity_test/continuous_testing.rb +17 -39
  30. data/lib/infinity_test/dependencies.rb +76 -41
  31. data/lib/infinity_test/environment.rb +15 -0
  32. data/lib/infinity_test/heuristics.rb +36 -0
  33. data/lib/infinity_test/heuristics_helper.rb +9 -0
  34. data/lib/infinity_test/options.rb +56 -19
  35. data/lib/infinity_test/runner.rb +25 -17
  36. data/lib/infinity_test/test_framework.rb +109 -0
  37. data/lib/infinity_test/test_library/bacon.rb +55 -0
  38. data/lib/infinity_test/test_library/cucumber.rb +22 -0
  39. data/lib/infinity_test/test_library/rspec.rb +58 -0
  40. data/lib/infinity_test/test_library/test_unit.rb +46 -0
  41. data/spec/factories/company/Gemfile +0 -0
  42. data/spec/factories/infinity_test_example +2 -2
  43. data/spec/infinity_test/application_library/rails_spec.rb +140 -0
  44. data/spec/infinity_test/application_library/rubygems_spec.rb +52 -0
  45. data/spec/infinity_test/application_spec.rb +274 -50
  46. data/spec/infinity_test/binary_path_spec.rb +72 -0
  47. data/spec/infinity_test/builder_spec.rb +7 -0
  48. data/spec/infinity_test/command_spec.rb +13 -14
  49. data/spec/infinity_test/configuration_spec.rb +183 -57
  50. data/spec/infinity_test/continuous_testing_spec.rb +19 -1
  51. data/spec/infinity_test/environment_spec.rb +23 -0
  52. data/spec/infinity_test/heuristics_helper_spec.rb +15 -0
  53. data/spec/infinity_test/heuristics_spec.rb +127 -0
  54. data/spec/infinity_test/options_spec.rb +48 -26
  55. data/spec/infinity_test/runner_spec.rb +37 -29
  56. data/spec/infinity_test/test_framework_spec.rb +127 -0
  57. data/spec/infinity_test/test_library/bacon_spec.rb +150 -0
  58. data/spec/infinity_test/test_library/cucumber_spec.rb +8 -0
  59. data/spec/infinity_test/test_library/rspec_spec.rb +185 -0
  60. data/spec/infinity_test/test_library/test_unit_spec.rb +184 -0
  61. data/spec/infinity_test_spec.rb +23 -12
  62. data/spec/spec_helper.rb +86 -30
  63. metadata +62 -32
  64. data/lib/infinity_test/notifications/growl.rb +0 -15
  65. data/lib/infinity_test/notifications/lib_notify.rb +0 -11
  66. data/lib/infinity_test/rspec.rb +0 -87
  67. data/lib/infinity_test/test_unit.rb +0 -74
  68. data/spec/infinity_test/notifications/growl_spec.rb +0 -9
  69. data/spec/infinity_test/notifications/lib_notify_spec.rb +0 -9
  70. data/spec/infinity_test/rspec_spec.rb +0 -189
  71. data/spec/infinity_test/test_unit_spec.rb +0 -182
  72. data/spec/spec.opts +0 -1
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ describe BinaryPath do
5
+ include BinaryPath
6
+ before :all do
7
+ @current = RVM::Environment.current
8
+ end
9
+
10
+ class Example
11
+ include BinaryPath
12
+ extend BinaryPath
13
+ binary :bacon
14
+ binary :cucumber
15
+ binary :rspec, :name => :rspec_two
16
+ binary :spec, :name => :rspec_one
17
+ end
18
+
19
+ describe '.binary' do
20
+
21
+ before do
22
+ @example = Example.new
23
+ end
24
+
25
+ it "should create the binary for bacon framework" do
26
+ @current.should_receive(:path_for).with('bacon')
27
+ @example.search_bacon(@current)
28
+ end
29
+
30
+ it "should create the binary for cucumber framework" do
31
+ @current.should_receive(:path_for).with('cucumber')
32
+ @example.search_cucumber(@current)
33
+ end
34
+
35
+ it "should create the binary for rspec two with sufix of rspec_two" do
36
+ @current.should_receive(:path_for).with('rspec')
37
+ @example.search_rspec_two(@current)
38
+ end
39
+
40
+ it "should create the binary for rspec one with sufix of rspec_one" do
41
+ @current.should_receive(:path_for).with('spec')
42
+ @example.search_rspec_one(@current)
43
+ end
44
+
45
+ end
46
+
47
+ describe '#have_binary?' do
48
+
49
+ it "should return true if the binary exists" do
50
+ File.should_receive(:exist?).and_return(true)
51
+ Example.new.have_binary?(:rspec).should be_true
52
+ end
53
+
54
+ it "should return false if the binary exists" do
55
+ File.should_receive(:exist?).and_return(false)
56
+ Example.new.have_binary?(:rspec).should be_false
57
+ end
58
+
59
+ end
60
+
61
+ describe '#print_message' do
62
+
63
+ it "should print the following message" do
64
+ example = Example.new
65
+ example.should_receive(:puts).with("\n Ruby => 1.9.2: I searched the rspec binary path and I don't find nothing. You have the rspec installed in this version?")
66
+ example.print_message(:rspec, '1.9.2')
67
+ end
68
+
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ describe Builder do
5
+
6
+ end
7
+ end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  module InfinityTest
4
4
  describe Command do
5
-
5
+
6
6
  it "should pass the ruby version and set" do
7
7
  Command.new(:ruby_version => '1.9.2').ruby_version.should == '1.9.2'
8
8
  end
@@ -14,41 +14,40 @@ module InfinityTest
14
14
  it "should create and set the command" do
15
15
  Command.new(:command => 'rspec spec').command.should == 'rspec spec'
16
16
  end
17
-
17
+
18
18
  it "should create and set the command for ruby version" do
19
- Command.new(:command => 'spec spec').command.should == 'spec spec'
19
+ Command.new(:command => 'spec spec').command.should == 'spec spec'
20
20
  end
21
-
21
+
22
22
  it "should have the results as Array" do
23
23
  Command.new.results.should be_instance_of(Array)
24
24
  end
25
-
25
+
26
26
  it "should have the line variable as Array" do
27
27
  Command.new.line.should be_instance_of(Array)
28
28
  end
29
29
 
30
30
  describe '#push_in_the_results' do
31
-
31
+
32
32
  before do
33
33
  @command = Command.new
34
34
  end
35
-
35
+
36
36
  it "should parse correct the results when have in the ree" do
37
37
  @command.line = [27, 91, 51, 51, 109, 49, 50, 49, 32, 101, 120, 97, 109, 112, 108, 101, 115, 44, 32, 48, 32, 102, 97, 105, 108, 117, 114, 101, 115, 44, 32, 50, 32, 112, 101, 110, 100, 105, 110, 103, 27, 91, 48, 109, 10]
38
- @command.should_receive(:ree?).and_return(true)
38
+ @command.should_receive(:yarv?).and_return(false)
39
39
  @command.push_in_the_results(?\n)
40
40
  @command.results.should == ["\e[33m121 examples, 0 failures, 2 pending\e[0m\n"]
41
41
  end
42
-
42
+
43
43
  it "should parse correct the results in ruby 1.8" do
44
44
  @command.line = [46, 46, 46, 46, 46, 42, 46, 42]
45
- @command.should_receive(:ree?).and_return(false)
46
- @command.should_receive(:mri?).and_return(true)
45
+ @command.should_receive(:yarv?).and_return(false)
47
46
  @command.push_in_the_results(?\n)
48
47
  @command.results.should == [".....*.*"]
49
48
  end
50
-
49
+
51
50
  end
52
-
51
+
53
52
  end
54
- end
53
+ end
@@ -7,57 +7,81 @@ module InfinityTest
7
7
  let(:block) { Proc.new { 'To Infinity and beyond!' } }
8
8
 
9
9
  describe '#initialize' do
10
-
10
+
11
11
  it "should set the test_unit as default test framework" do
12
12
  Configuration.new.test_framework.should equal :test_unit
13
13
  end
14
-
14
+
15
+ end
16
+
17
+ describe '#heuristics' do
18
+
19
+ it "should return a instance of Heuristics class" do
20
+ config.heuristics do
21
+ end.should be_instance_of(InfinityTest::Heuristics)
22
+ end
23
+
24
+ it "should be possible to add heuristics to the application" do
25
+ heuristics = config.heuristics do
26
+ add("^lib/*/(.*)\.rb") do |file|
27
+ end
28
+ end
29
+ heuristics.should have_pattern("^lib/*/(.*)\.rb")
30
+ end
31
+
32
+ it "should cache the heuristics instance variable" do
33
+ heuristics = config.heuristics do
34
+ end
35
+ same_heuristics = config.heuristics do
36
+ end
37
+ heuristics.should equal same_heuristics
38
+ end
15
39
  end
16
-
17
- describe '#infinity_test' do
18
-
19
- it "Infinity test Dsl of config file should yield in the Configuration scope" do
20
- infinity_test do
21
- use
22
- end.class.should equal Configuration
23
- end
24
-
40
+
41
+ describe '#watch' do
42
+
43
+ it "should evaluate in the watchr script class" do
44
+ config.watch("^lib/*/(.*)\.rb") do |file|
45
+ do_something!
46
+ end.should equal InfinityTest.watchr
47
+ end
48
+
25
49
  end
26
-
50
+
27
51
  describe '#notifications' do
28
-
52
+
29
53
  it "should possible to set the growl notification framework" do
30
54
  config.notifications :growl
31
55
  config.notification_framework.should equal :growl
32
56
  end
33
-
57
+
34
58
  it "should possible to set the lib notify notification framework" do
35
59
  config.notifications :lib_notify
36
60
  config.notification_framework.should equal :lib_notify
37
61
  end
38
-
62
+
39
63
  it "should not possible to set another notification framework" do
40
64
  lambda { config.notifications(:dont_exist) }.should raise_exception(NotificationFrameworkDontSupported, "Notification :dont_exist don't supported. The Frameworks supported are: growl,lib_notify")
41
65
  end
42
-
66
+
43
67
  it "should raise exception for non supported notification framework" do
44
68
  lambda { config.notifications(:snarfff) }.should raise_exception(NotificationFrameworkDontSupported, "Notification :snarfff don't supported. The Frameworks supported are: growl,lib_notify")
45
69
  end
46
-
70
+
47
71
  end
48
72
 
49
73
  describe '#use' do
50
-
74
+
51
75
  it "should set the rvm versions" do
52
76
  config.use :rubies => '1.8.7-p249'
53
77
  config.rubies.should be == '1.8.7-p249'
54
78
  end
55
-
79
+
56
80
  it "should set many ruby versions" do
57
81
  config.use :rubies => ['1.9.1', '1.9.2']
58
82
  config.rubies.should be == '1.9.1,1.9.2'
59
83
  end
60
-
84
+
61
85
  it "should set the gemset and change all rubies" do
62
86
  config.use :rubies => ['1.9.1', '1.9.2'], :gemset => 'infinity_test'
63
87
  config.rubies.should be == '1.9.1@infinity_test,1.9.2@infinity_test'
@@ -67,72 +91,119 @@ module InfinityTest
67
91
  config.use :rubies => ['1.9.1', '1.9.2'], :gemset => 'other_gemset'
68
92
  config.rubies.should be == '1.9.1@other_gemset,1.9.2@other_gemset'
69
93
  end
70
-
94
+
95
+ it "should set many ruby versions with nil gemset key" do
96
+ config.use :rubies => ['1.9.1', '1.9.2'], :gemset => nil
97
+ config.rubies.should be == '1.9.1,1.9.2'
98
+ end
99
+
71
100
  it "should set the test unit when not set the test framework" do
72
101
  config.use
73
102
  config.test_framework.should equal :test_unit
74
103
  end
75
-
104
+
76
105
  it "should return the test framework" do
77
106
  config.use :test_framework => :rspec
78
107
  config.test_framework.should equal :rspec
79
108
  end
80
-
109
+
110
+ it "should return bacon too for the test framework" do
111
+ config.use :test_framework => :bacon
112
+ config.test_framework.should equal :bacon
113
+ end
114
+
81
115
  it "should possible to set the test unit for test framework" do
82
116
  config.use :test_framework => :test_unit
83
117
  config.test_framework.should equal :test_unit
84
118
  end
85
-
119
+
86
120
  it "should set the verbose option" do
87
121
  config.use :verbose => true
88
122
  config.verbose.should be_true
89
123
  end
90
-
124
+
91
125
  it "should set to false as default" do
92
126
  config.verbose.should equal false
93
127
  end
94
-
128
+
129
+ it "should be possible to use Rails framework" do
130
+ config.use :app_framework => :rails
131
+ config.app_framework.should equal :rails
132
+ end
133
+
134
+ it "should set the rubygems as default app framework" do
135
+ config.use
136
+ config.app_framework.should equal :rubygems
137
+ end
138
+
139
+ it "should be possible to set the cucumber option" do
140
+ config.use :cucumber => true
141
+ config.cucumber?.should be_true
142
+ end
143
+
144
+ it "should be false as default" do
145
+ config.cucumber?.should be_false
146
+ end
147
+
148
+ it "should return false if cucumber is nil in #use method" do
149
+ config.use :cucumber => nil
150
+ config.cucumber?.should be_false
151
+ end
152
+
153
+ end
154
+
155
+ describe '#skip_bundler!' do
156
+
157
+ it "should return true if skip bundler" do
158
+ config.skip_bundler!
159
+ config.skip_bundler?.should be_true
160
+ end
161
+
162
+ it "should return false if not skip bundler (default)" do
163
+ config.skip_bundler?.should be_false
164
+ end
165
+
95
166
  end
96
167
 
97
168
  describe '#ignore' do
98
-
169
+
99
170
  it "should be empty when not have dir/files to ignore" do
100
171
  config.ignore
101
172
  config.exceptions_to_ignore.should be == []
102
173
  end
103
-
174
+
104
175
  it "should set the exception to ignore" do
105
176
  config.ignore :exceptions => %w(.svn)
106
177
  config.exceptions_to_ignore.should be == %w(.svn)
107
178
  end
108
-
179
+
109
180
  it "should set the exceptions to ignore changes" do
110
181
  config.ignore :exceptions => %w(.svn .hg .git vendor tmp config rerun.txt)
111
182
  config.exceptions_to_ignore.should be == %w(.svn .hg .git vendor tmp config rerun.txt)
112
183
  end
113
-
184
+
114
185
  end
115
186
 
116
187
  describe '#show_images' do
117
-
188
+
118
189
  before { @config = Configuration.new }
119
-
190
+
120
191
  let(:config) { @config }
121
-
192
+
122
193
  context 'on default images' do
123
194
  before { @config.notifications :growl }
124
-
195
+
125
196
  it { config.sucess_image.should == image('simpson/sucess.jpg') }
126
-
197
+
127
198
  it { config.pending_image.should == image('simpson/pending.jpg') }
128
-
199
+
129
200
  it { config.failure_image.should == image('simpson/failure.gif') }
130
-
201
+
131
202
  end
132
-
203
+
133
204
  context 'on setting my own image' do
134
205
  before { config.notifications :lib_notify }
135
-
206
+
136
207
  it "should be possible to customize success image" do
137
208
  config.show_images :sucess => image('other.png')
138
209
  config.sucess_image.should == image('other.png')
@@ -148,10 +219,10 @@ module InfinityTest
148
219
  config.pending_image.should == image('pending_picture.png')
149
220
  end
150
221
  end
151
-
222
+
152
223
  context 'setting the dirrectory image or modes' do
153
224
  before { config.notifications :growl }
154
-
225
+
155
226
  it "should possible to change the dir of images" do
156
227
  config.show_images :mode => :street_fighter
157
228
  config.pending_image.should == image('street_fighter/pending.gif')
@@ -162,6 +233,13 @@ module InfinityTest
162
233
  config.sucess_image.should == image('toy_story/sucess.png')
163
234
  end
164
235
 
236
+ it "should possible to change the dir of the images" do
237
+ config.show_images :mode => :fuuu
238
+ config.sucess_image.should == image('fuuu/sucess.png')
239
+ config.pending_image.should == image('fuuu/pending.png')
240
+ config.failure_image.should == image('fuuu/failure.png')
241
+ end
242
+
165
243
  it "should possible to change the dir of the images" do
166
244
  config.show_images :mode => custom_image_dir
167
245
  config.sucess_image.should == custom_image('images/sucess.png')
@@ -170,42 +248,42 @@ module InfinityTest
170
248
  end
171
249
 
172
250
  describe '#before_run' do
173
-
251
+
174
252
  it "should persist the proc object in the before callback" do
175
253
  proc = Proc.new { 'To Infinity and beyond!' }
176
254
  config.before_run(&proc)
177
255
  config.before_callback.should be == proc
178
256
  end
179
-
257
+
180
258
  end
181
-
259
+
182
260
  describe '#after_run' do
183
-
261
+
184
262
  it "should persist the proc object in the after callback" do
185
263
  proc = Proc.new { 'To Infinity and beyond!' }
186
264
  config.after_run(&proc)
187
265
  config.after_callback.should be == proc
188
266
  end
189
-
267
+
190
268
  end
191
269
 
192
270
  describe '#before' do
193
-
271
+
194
272
  it "should set the before callback if pass not hook" do
195
273
  config.before(&block)
196
274
  config.before_callback.should == block
197
275
  end
198
-
276
+
199
277
  it "should possible to set the before_run block" do
200
278
  config.before(:all, &block)
201
279
  config.before_callback.should == block
202
280
  end
203
-
281
+
204
282
  it "should possible to set before each ruby block" do
205
283
  config.before(:each_ruby, &block)
206
284
  config.before_each_ruby_callback.should == block
207
285
  end
208
-
286
+
209
287
  it "should not set before_run block in :each_ruby option" do
210
288
  config.before(:each_ruby, &block)
211
289
  config.before_callback.should be_nil
@@ -215,26 +293,26 @@ module InfinityTest
215
293
  config.before(:all, &block)
216
294
  config.before_each_ruby_callback.should be_nil
217
295
  end
218
-
296
+
219
297
  end
220
298
 
221
299
  describe '#after' do
222
-
300
+
223
301
  it "should set the after callback if pass not hook" do
224
302
  config.after(&block)
225
303
  config.after_callback.should == block
226
304
  end
227
-
305
+
228
306
  it "should possible to set the after block" do
229
307
  config.after(:all, &block)
230
308
  config.after_callback.should == block
231
309
  end
232
-
310
+
233
311
  it "should possible to set after each ruby block" do
234
312
  config.after(:each_ruby, &block)
235
313
  config.after_each_ruby_callback.should == block
236
314
  end
237
-
315
+
238
316
  it "should not set after block in :each_ruby option" do
239
317
  config.after(:each_ruby, &block)
240
318
  config.after_callback.should be_nil
@@ -244,8 +322,56 @@ module InfinityTest
244
322
  config.after(:all, &block)
245
323
  config.after_each_ruby_callback.should be_nil
246
324
  end
247
-
325
+
248
326
  end
249
327
 
328
+ describe '#replace_patterns' do
329
+
330
+ it "should evaluate in the context of application framework" do
331
+ config.replace_patterns do |application|
332
+ end.should be_instance_of(InfinityTest::Application)
333
+ end
334
+
335
+ it "should replace patterns to the application framework" do
336
+ config.replace_patterns do |application|
337
+ application.app_framework.lib_pattern = "^my_lib/(.*)\.rb"
338
+ end
339
+ InfinityTest.application.app_framework.lib_pattern.should == "^my_lib/(.*)\.rb"
340
+ end
341
+
342
+ it "should replace patterns and replace the test pattern to test framework lookup" do
343
+ config.replace_patterns do |application|
344
+ application.app_framework.test_pattern = "^my_unusual_spec_directory/unit/(.*)_spec.rb"
345
+ application.test_framework.test_pattern = "my_unusual_spec_directory/unit/*_spec.rb"
346
+ end
347
+ InfinityTest.application.app_framework.test_pattern.should == "^my_unusual_spec_directory/unit/(.*)_spec.rb"
348
+ InfinityTest.application.test_framework.test_pattern.should == "my_unusual_spec_directory/unit/*_spec.rb"
349
+ end
350
+
351
+ end
352
+
353
+ describe '#clear' do
354
+
355
+ it "should call the clear in the system" do
356
+ config.should_receive(:system).with('clear')
357
+ config.clear :terminal
358
+ end
359
+
360
+ end
361
+
362
+ end
363
+ end
364
+
365
+ describe '#infinity_test' do
366
+ it 'should return a instance of Configuration class' do
367
+ infinity_test do
368
+ end.should be_instance_of(InfinityTest::Configuration)
250
369
  end
251
- end
370
+
371
+ it "Infinity test Dsl of config file should yield in the Configuration scope" do
372
+ infinity_test do
373
+ use
374
+ end.class.should equal InfinityTest::Configuration
375
+ end
376
+
377
+ end