infinity_test 0.1.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 (83) hide show
  1. data/.gitignore +10 -0
  2. data/.infinity_test +8 -0
  3. data/.rspec +1 -0
  4. data/.rvmrc +1 -0
  5. data/Gemfile +11 -0
  6. data/Rakefile +49 -0
  7. data/Readme.markdown +92 -0
  8. data/Tasks +5 -0
  9. data/VERSION.yml +5 -0
  10. data/bin/infinity_test +7 -0
  11. data/buzz_images/buzz_lightyear.jpg +0 -0
  12. data/buzz_images/buzz_lightyear_continencia.gif +0 -0
  13. data/buzz_images/to_infinity_and_beyond.png +0 -0
  14. data/features/infinity_test.feature +36 -0
  15. data/features/support/env.rb +1 -0
  16. data/images/faces/failure.png +0 -0
  17. data/images/faces/pending.png +0 -0
  18. data/images/faces/sucess.png +0 -0
  19. data/images/hands/failure.png +0 -0
  20. data/images/hands/pending.png +0 -0
  21. data/images/hands/sucess.png +0 -0
  22. data/images/mario_bros/failure.jpg +0 -0
  23. data/images/mario_bros/pending.jpg +0 -0
  24. data/images/mario_bros/sucess.jpg +0 -0
  25. data/images/rails/failure.png +0 -0
  26. data/images/rails/pending.png +0 -0
  27. data/images/rails/sucess.png +0 -0
  28. data/images/rubies/failure.png +0 -0
  29. data/images/rubies/pending.png +0 -0
  30. data/images/rubies/sucess.png +0 -0
  31. data/images/simpson/failure.gif +0 -0
  32. data/images/simpson/pending.jpg +0 -0
  33. data/images/simpson/sucess.jpg +0 -0
  34. data/images/street_fighter/failure.gif +0 -0
  35. data/images/street_fighter/pending.gif +0 -0
  36. data/images/street_fighter/sucess.jpg +0 -0
  37. data/images/toy_story/failure.gif +0 -0
  38. data/images/toy_story/pending.png +0 -0
  39. data/images/toy_story/sucess.png +0 -0
  40. data/infinity_test.gemspec +168 -0
  41. data/lib/infinity_test.rb +31 -0
  42. data/lib/infinity_test/application.rb +168 -0
  43. data/lib/infinity_test/binary_path.rb +21 -0
  44. data/lib/infinity_test/command.rb +57 -0
  45. data/lib/infinity_test/configuration.rb +157 -0
  46. data/lib/infinity_test/continuous_testing.rb +62 -0
  47. data/lib/infinity_test/dependencies.rb +45 -0
  48. data/lib/infinity_test/notifications/growl.rb +15 -0
  49. data/lib/infinity_test/notifications/lib_notify.rb +11 -0
  50. data/lib/infinity_test/options.rb +52 -0
  51. data/lib/infinity_test/rspec.rb +87 -0
  52. data/lib/infinity_test/runner.rb +30 -0
  53. data/lib/infinity_test/test_unit.rb +74 -0
  54. data/lib/infinity_test/test_unit_loader.rb +5 -0
  55. data/spec/factories/buzz/lib/buzz.rb +0 -0
  56. data/spec/factories/buzz/spec/buzz_spec.rb +0 -0
  57. data/spec/factories/company/lib/company.rb +0 -0
  58. data/spec/factories/company/test/company_test.rb +0 -0
  59. data/spec/factories/images/failure.png +0 -0
  60. data/spec/factories/images/pending.png +0 -0
  61. data/spec/factories/images/sucess.png +0 -0
  62. data/spec/factories/infinity_test +5 -0
  63. data/spec/factories/infinity_test_example +7 -0
  64. data/spec/factories/slinky/spec/slinky/slinky_spec.rb +0 -0
  65. data/spec/factories/travel/lib/travel.rb +0 -0
  66. data/spec/factories/travel/test/partner_test.rb +0 -0
  67. data/spec/factories/travel/test/travel_test.rb +0 -0
  68. data/spec/factories/wood/lib/wood.rb +0 -0
  69. data/spec/factories/wood/spec/wood_spec.rb +0 -0
  70. data/spec/infinity_test/application_spec.rb +149 -0
  71. data/spec/infinity_test/command_spec.rb +47 -0
  72. data/spec/infinity_test/configuration_spec.rb +196 -0
  73. data/spec/infinity_test/continuous_testing_spec.rb +7 -0
  74. data/spec/infinity_test/notifications/growl_spec.rb +9 -0
  75. data/spec/infinity_test/notifications/lib_notify_spec.rb +9 -0
  76. data/spec/infinity_test/options_spec.rb +69 -0
  77. data/spec/infinity_test/rspec_spec.rb +189 -0
  78. data/spec/infinity_test/runner_spec.rb +34 -0
  79. data/spec/infinity_test/test_unit_spec.rb +182 -0
  80. data/spec/infinity_test_spec.rb +29 -0
  81. data/spec/spec.opts +1 -0
  82. data/spec/spec_helper.rb +67 -0
  83. metadata +226 -0
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ describe Command do
5
+
6
+ it "should pass the ruby version and set" do
7
+ Command.new(:ruby_version => '1.9.2').ruby_version.should == '1.9.2'
8
+ end
9
+
10
+ it "should pass the ruby version and set" do
11
+ Command.new(:ruby_version => 'JRuby 1.3.5').ruby_version.should == 'JRuby 1.3.5'
12
+ end
13
+
14
+ it "should create and set the command" do
15
+ Command.new(:command => 'rspec spec').command.should == 'rspec spec'
16
+ end
17
+
18
+ it "should create and set the command for ruby version" do
19
+ Command.new(:command => 'spec spec').command.should == 'spec spec'
20
+ end
21
+
22
+ it "should have the results as Array" do
23
+ Command.new.results.should be_instance_of(Array)
24
+ end
25
+
26
+ it "should have the line variable as Array" do
27
+ Command.new.line.should be_instance_of(Array)
28
+ end
29
+
30
+ describe '#push_in_the_results' do
31
+
32
+ before do
33
+ @command = Command.new
34
+ end
35
+
36
+ it "should parse correct the results when have in the ree" do
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)
39
+ @command.push_in_the_results(?\n)
40
+ @command.results.should == ["\e[33m121 examples, 0 failures, 2 pending\e[0m\n"]
41
+ end
42
+
43
+
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,196 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ describe Configuration do
5
+ before { @config = Configuration.new }
6
+ let(:config) { @config }
7
+
8
+ describe '#initialize' do
9
+
10
+ it "should set the test_unit as default test framework" do
11
+ Configuration.new.test_framework.should equal :test_unit
12
+ end
13
+
14
+ end
15
+
16
+ describe '#infinity_test' do
17
+
18
+ it "Infinity test Dsl of config file should yield in the Configuration scope" do
19
+ infinity_test do
20
+ use
21
+ end.class.should equal Configuration
22
+ end
23
+
24
+ end
25
+
26
+ describe '#notifications' do
27
+
28
+ it "should possible to set the growl notification framework" do
29
+ config.notifications :growl
30
+ config.notification_framework.should equal :growl
31
+ end
32
+
33
+ it "should possible to set the lib notify notification framework" do
34
+ config.notifications :lib_notify
35
+ config.notification_framework.should equal :lib_notify
36
+ end
37
+
38
+ it "should not possible to set another notification framework" do
39
+ lambda { config.notifications(:dont_exist) }.should raise_exception(NotificationFrameworkDontSupported, "Notification :dont_exist don't supported. The Frameworks supported are: growl,lib_notify")
40
+ end
41
+
42
+ it "should raise exception for non supported notification framework" do
43
+ lambda { config.notifications(:snarfff) }.should raise_exception(NotificationFrameworkDontSupported, "Notification :snarfff don't supported. The Frameworks supported are: growl,lib_notify")
44
+ end
45
+
46
+ end
47
+
48
+ describe '#use' do
49
+
50
+ it "should set the rvm versions" do
51
+ config.use :rubies => '1.8.7-p249'
52
+ config.rubies.should be == '1.8.7-p249'
53
+ end
54
+
55
+ it "should set many ruby versions" do
56
+ config.use :rubies => ['1.9.1', '1.9.2']
57
+ config.rubies.should be == '1.9.1,1.9.2'
58
+ end
59
+
60
+ it "should set the gemset and change all rubies" do
61
+ config.use :rubies => ['1.9.1', '1.9.2'], :gemset => 'infinity_test'
62
+ config.rubies.should be == '1.9.1@infinity_test,1.9.2@infinity_test'
63
+ end
64
+
65
+ it "should set the gemset and change all rubies" do
66
+ config.use :rubies => ['1.9.1', '1.9.2'], :gemset => 'other_gemset'
67
+ config.rubies.should be == '1.9.1@other_gemset,1.9.2@other_gemset'
68
+ end
69
+
70
+ it "should set the test unit when not set the test framework" do
71
+ config.use
72
+ config.test_framework.should equal :test_unit
73
+ end
74
+
75
+ it "should return the test framework" do
76
+ config.use :test_framework => :rspec
77
+ config.test_framework.should equal :rspec
78
+ end
79
+
80
+ it "should possible to set the test unit for test framework" do
81
+ config.use :test_framework => :test_unit
82
+ config.test_framework.should equal :test_unit
83
+ end
84
+
85
+ it "should set the verbose option" do
86
+ config.use :verbose => true
87
+ config.verbose.should be_true
88
+ end
89
+
90
+ it "should set to false as default" do
91
+ config.verbose.should equal false
92
+ end
93
+
94
+ end
95
+
96
+ describe '#ignore' do
97
+
98
+ it "should be empty when not have dir/files to ignore" do
99
+ config.ignore
100
+ config.exceptions_to_ignore.should be == []
101
+ end
102
+
103
+ it "should set the exception to ignore" do
104
+ config.ignore :exceptions => %w(.svn)
105
+ config.exceptions_to_ignore.should be == %w(.svn)
106
+ end
107
+
108
+ it "should set the exceptions to ignore changes" do
109
+ config.ignore :exceptions => %w(.svn .hg .git vendor tmp config rerun.txt)
110
+ config.exceptions_to_ignore.should be == %w(.svn .hg .git vendor tmp config rerun.txt)
111
+ end
112
+
113
+ end
114
+
115
+ describe '#show_images' do
116
+
117
+ before { @config = Configuration.new }
118
+
119
+ it "should have a default success image" do
120
+ @config.notifications :growl
121
+ @config.show_images :sucess => :default
122
+ @config.sucess_image.should == image('simpson/sucess.jpg')
123
+ end
124
+
125
+ it "should be possible to customize success image" do
126
+ @config.notifications :growl
127
+ @config.show_images :sucess => image('other.png')
128
+ @config.sucess_image.should == image('other.png')
129
+ end
130
+
131
+ it "should have a default failure image" do
132
+ @config.notifications :growl
133
+ @config.show_images :failure => :default
134
+ @config.failure_image.should == image('simpson/failure.gif')
135
+ end
136
+
137
+ it "should be possible to customize failure image" do
138
+ @config.notifications :growl
139
+ @config.show_images :failure => image('failure_picture.png')
140
+ @config.failure_image.should == image('failure_picture.png')
141
+ end
142
+
143
+ it "should have a default failure image" do
144
+ @config.notifications :growl
145
+ @config.show_images :pending => :default
146
+ @config.pending_image.should == image('simpson/pending.jpg')
147
+ end
148
+
149
+ it "should be possible to customize failure image" do
150
+ @config.notifications :growl
151
+ @config.show_images :pending => image('pending_picture.png')
152
+ @config.pending_image.should == image('pending_picture.png')
153
+ end
154
+
155
+ it "should possible to change the dir of images" do
156
+ @config.notifications :growl
157
+ @config.show_images :mode => :street_fighter
158
+ @config.pending_image.should == image('street_fighter/pending.gif')
159
+ end
160
+
161
+ it "should possible to change the dir of the images" do
162
+ @config.notifications :growl
163
+ @config.show_images :mode => :street_fighter
164
+ @config.sucess_image.should == image('street_fighter/sucess.jpg')
165
+ end
166
+
167
+ it "should possible to change the dir of the images" do
168
+ @config.notifications :growl
169
+ @config.show_images :mode => custom_image_dir
170
+ @config.sucess_image.should == custom_image('images/sucess.png')
171
+ end
172
+
173
+ end
174
+
175
+ describe '#before_run' do
176
+
177
+ it "should persist the proc object in the before callback" do
178
+ proc = Proc.new { 'To Infinity and beyond!' }
179
+ config.before_run(&proc)
180
+ config.before_callback.should be == proc
181
+ end
182
+
183
+ end
184
+
185
+ describe '#after_run' do
186
+
187
+ it "should persist the proc object in the after callback" do
188
+ proc = Proc.new { 'To Infinity and beyond!' }
189
+ config.after_run(&proc)
190
+ config.after_callback.should be == proc
191
+ end
192
+
193
+ end
194
+
195
+ end
196
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ describe ContinuousTesting do
5
+
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Notifications
5
+ describe Growl do
6
+
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Notifications
5
+ describe LibNotify do
6
+
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ describe Options do
5
+
6
+ context "when parsing" do
7
+
8
+ it "should parse --rspec and return rspec" do
9
+ parse_options('--rspec')
10
+ @options[:test_framework].should equal :rspec
11
+ end
12
+
13
+ it "should not return rspec as test framework when not parse rspec" do
14
+ parse_options('--test-unit')
15
+ @options[:test_framework].should_not equal :rspec
16
+ end
17
+
18
+ it "should parse --test-unit and return test_unit" do
19
+ parse_options('--test-unit')
20
+ @options[:test_framework].should equal :test_unit
21
+ end
22
+
23
+ it "should not parse --test-unit" do
24
+ parse_options('--rspec')
25
+ @options[:test_framework].should_not equal :test_unit
26
+ end
27
+
28
+ it "should parse --rvm-versions and return an array" do
29
+ parse_options('--rubies=1.8.6,1.8.7')
30
+ @options[:rubies].should eql '1.8.6,1.8.7'
31
+ end
32
+
33
+ it "should parse --rvm-versions with dashes" do
34
+ parse_options('--rubies=1.8.7-p249,1.9.1-p378')
35
+ @options[:rubies].should eql '1.8.7-p249,1.9.1-p378'
36
+ end
37
+
38
+ it "should parse --verbose" do
39
+ parse_options('--verbose')
40
+ @options[:verbose].should be_true
41
+ end
42
+
43
+ end
44
+
45
+ describe "#rspec?" do
46
+
47
+ it "should return true if using rspec" do
48
+ parse_options('--rspec')
49
+ @options.rspec?.should be_true
50
+ end
51
+
52
+ it "should explicity return false if not using rspec" do
53
+ parse_options('--test-unit')
54
+ @options.rspec?.should be_false
55
+ end
56
+
57
+ it "should not return nil when not using rspec" do
58
+ parse_options('--rubies=1.8.6')
59
+ @options.rspec?.should_not be_nil
60
+ end
61
+
62
+ end
63
+
64
+ def parse_options(*arguments)
65
+ @options = InfinityTest::Options.new(arguments)
66
+ end
67
+
68
+ end
69
+ end
@@ -0,0 +1,189 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ describe Rspec do
5
+ before do
6
+ @current_dir = Dir.pwd
7
+ end
8
+
9
+ it "should be possible to set all rubies" do
10
+ Rspec.new(:rubies => '1.9.1').rubies.should be == '1.9.1'
11
+ end
12
+
13
+ it "should set the rubies" do
14
+ Rspec.new(:rubies => 'jruby,ree').rubies.should be == 'jruby,ree'
15
+ end
16
+
17
+ it "rubies should be empty when not have rubies" do
18
+ Rspec.new.rubies.should be_empty
19
+ end
20
+
21
+ it "should have the pattern for spec directory" do
22
+ Rspec.new.test_directory_pattern.should be == "^spec/*/(.*)_spec.rb"
23
+ end
24
+
25
+ it 'should set a default test pattern when have none' do
26
+ Rspec.new.test_pattern.should == 'spec/**/*_spec.rb'
27
+ end
28
+
29
+ it "should possible to set the test pattern" do
30
+ Rspec.new(:test_pattern => 'spec/**/spec_*.rb').test_pattern.should == 'spec/**/spec_*.rb'
31
+ end
32
+
33
+ describe '#spec_files' do
34
+
35
+ let(:rspec) { Rspec.new }
36
+
37
+ it "return should include the spec files" do
38
+ Dir.chdir("#{@current_dir}/spec/factories/buzz") do
39
+ rspec.spec_files.should be == "spec/buzz_spec.rb"
40
+ end
41
+ end
42
+
43
+ it "return should include the spec files to test them" do
44
+ Dir.chdir("#{@current_dir}/spec/factories/wood") do
45
+ rspec.spec_files.should be == "spec/wood_spec.rb"
46
+ end
47
+ end
48
+
49
+ it "return should include the spec files to test them in two level of the spec folder" do
50
+ Dir.chdir("#{@current_dir}/spec/factories/slinky") do
51
+ rspec.spec_files.should be == "spec/slinky/slinky_spec.rb"
52
+ end
53
+ end
54
+
55
+ end
56
+
57
+ describe '#decide_files' do
58
+
59
+ before { @rspec = Rspec.new }
60
+
61
+ it "should not call the spec file when match pattern" do
62
+ @rspec.should_not_receive(:spec_files)
63
+ @rspec.decide_files('application_spec.rb')
64
+ end
65
+
66
+ it "should call the spec files when pattern is nil" do
67
+ @rspec.should_receive(:spec_files)
68
+ @rspec.decide_files(nil)
69
+ end
70
+
71
+ end
72
+
73
+ describe '#handle_results' do
74
+
75
+ before do
76
+ @rspec = Rspec.new
77
+ end
78
+
79
+ it "should handle a example that succeed" do
80
+ results = "........Finished in 0.299817 seconds\n\n105 examples, 0 failures, 0 pending\n"
81
+ @rspec.parse_results(results)
82
+ @rspec.message.should == "105 examples, 0 failures, 0 pending"
83
+ end
84
+
85
+ it "should parse without the terminal ansi color" do
86
+ results = "ork\e[0m\n\e[90m # No reason given\e[0m\n\e[90m # ./spec/infinity_test/configuration_spec.rb:31\e[0m\n\nFinished in 0.10487 seconds\n\e[33m406 examples, 5 failures, 2 pending\e[0m\n"
87
+ @rspec.parse_results(results)
88
+ @rspec.message.should == "406 examples, 5 failures, 2 pending"
89
+ end
90
+
91
+ it "should handle a example that succeed and return false for failure?" do
92
+ results = "........Finished in 0.299817 seconds\n\n105 examples, 0 failures, 0 pending\n"
93
+ @rspec.parse_results(results)
94
+ @rspec.failure?.should equal false
95
+ end
96
+
97
+ it "should parse without the terminal ansi color and grep the failure" do
98
+ results = "ork\e[0m\n\e[90m # No reason given\e[0m\n\e[90m # ./spec/infinity_test/configuration_spec.rb:31\e[0m\n\nFinished in 0.10487 seconds\n\e[33m406 examples, 5 failures, 2 pending\e[0m\n"
99
+ @rspec.parse_results(results)
100
+ @rspec.failure?.should be_true
101
+ end
102
+
103
+ it "should parse without the terminal ansi color and grep the pending" do
104
+ results = "ork\e[0m\n\e[90m # No reason given\e[0m\n\e[90m # ./spec/infinity_test/configuration_spec.rb:31\e[0m\n\nFinished in 0.10487 seconds\n\e[33m406 examples, 0 failures, 2 pending\e[0m\n"
105
+ @rspec.parse_results(results)
106
+ @rspec.pending?.should be_true
107
+ end
108
+
109
+ it "should parse rspec tests errors" do
110
+ results = "/Users/tomas/.rvm/gems/ruby-1.9.2@infinity_test/gems/my_class/bin/klass:2:in `require': no such file to load -- MyClass (LoadError)"
111
+ @rspec.parse_results(results)
112
+ @rspec.message.should == "An exception occurred"
113
+ end
114
+
115
+ it "should parse rspec tests errors" do
116
+ results = "/Users/tomas/.rvm/gems/ruby-1.9.2@infinity_test/gems/my_class/bin/klass:2:in `require': no such file to load -- MyClass (LoadError)"
117
+ @rspec.parse_results(results)
118
+ @rspec.failure?.should be_true
119
+ end
120
+
121
+ it "should parse rspec tests errors" do
122
+ results = "/Users/tomas/.rvm/gems/ruby-1.9.2@infinity_test/gems/my_class/bin/klass:2:in `require': no such file to load -- MyClass (LoadError)"
123
+ @rspec.parse_results(results)
124
+ @rspec.sucess?.should equal false
125
+ end
126
+
127
+ it "should parse rspec tests errors" do
128
+ results = "/Users/tomas/.rvm/gems/ruby-1.9.2@infinity_test/gems/my_class/bin/klass:2:in `require': no such file to load -- MyClass (LoadError)"
129
+ @rspec.parse_results(results)
130
+ @rspec.pending?.should equal false
131
+ end
132
+ end
133
+
134
+ describe '#sucess?' do
135
+ before { @rspec = Rspec.new }
136
+
137
+ it "should return false when have failures" do
138
+ results = "ork\e[0m\n\e[90m # No reason given\e[0m\n\e[90m # ./spec/infinity_test/configuration_spec.rb:31\e[0m\n\nFinished in 0.10487 seconds\n\e[33m406 examples, 5 failures, 2 pending\e[0m\n"
139
+ @rspec.parse_results(results)
140
+ @rspec.sucess?.should equal false
141
+ end
142
+
143
+ it "should return false when have pending" do
144
+ results = "ork\e[0m\n\e[90m # No reason given\e[0m\n\e[90m # ./spec/infinity_test/configuration_spec.rb:31\e[0m\n\nFinished in 0.10487 seconds\n\e[33m806 examples, 0 failures, 2 pending\e[0m\n"
145
+ @rspec.parse_results(results)
146
+ @rspec.sucess?.should be_false
147
+ end
148
+
149
+ it "should return true when have zero failures and zero pending" do
150
+ results = "........Finished in 0.299817 seconds\n\n105 examples, 0 failures, 0 pending\n"
151
+ @rspec.parse_results(results)
152
+ @rspec.sucess?.should be_true
153
+ end
154
+
155
+ end
156
+
157
+ describe '#pending?' do
158
+ let(:rspec) { Rspec.new }
159
+
160
+ it "should return true when have pending" do
161
+ rspec.pending = 1
162
+ rspec.failure = 0
163
+ rspec.pending?.should be_true
164
+ end
165
+
166
+ it "should return false when have pending bu thave failures" do
167
+ rspec.pending = 1
168
+ rspec.failure = 1
169
+ rspec.pending?.should equal false
170
+ end
171
+
172
+ end
173
+
174
+ def redefine_const(name,value)
175
+ if Object.const_defined?(name)
176
+ old_value = Object.const_get(name)
177
+ Object.send(:remove_const, name)
178
+ else
179
+ old_value = value
180
+ end
181
+ Object.const_set(name,value)
182
+ yield
183
+ ensure
184
+ Object.send(:remove_const, name)
185
+ Object.const_set(name, old_value)
186
+ end
187
+
188
+ end
189
+ end