infinity_test 1.0.2 → 2.0.0.rc1

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 (149) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yml +31 -0
  3. data/.gitignore +3 -0
  4. data/.rspec +2 -2
  5. data/AI_INTEGRATION_IDEAS.md +203 -0
  6. data/Gemfile +3 -15
  7. data/History.markdown +82 -0
  8. data/INFINITY_TEST +48 -0
  9. data/LICENSE.txt +2 -2
  10. data/README.md +627 -0
  11. data/Rakefile +1 -65
  12. data/TODO.markdown +26 -9
  13. data/bin/infinity_test +1 -4
  14. data/images/fuuu/pending.png +0 -0
  15. data/images/fuuu/success.png +0 -0
  16. data/infinity_test.gemspec +41 -191
  17. data/lib/infinity_test/core/auto_discover.rb +67 -0
  18. data/lib/infinity_test/core/base.rb +369 -0
  19. data/lib/infinity_test/core/callback.rb +59 -0
  20. data/lib/infinity_test/core/changed_file.rb +13 -0
  21. data/lib/infinity_test/core/command_builder.rb +48 -0
  22. data/lib/infinity_test/core/command_runner.rb +62 -0
  23. data/lib/infinity_test/core/configuration_merge.rb +37 -0
  24. data/lib/infinity_test/core/continuous_test_server.rb +106 -0
  25. data/lib/infinity_test/core/load_configuration.rb +48 -0
  26. data/lib/infinity_test/core/notifier.rb +59 -0
  27. data/lib/infinity_test/core/options.rb +134 -0
  28. data/lib/infinity_test/core/runner.rb +18 -0
  29. data/lib/infinity_test/core/version.rb +5 -0
  30. data/lib/infinity_test/framework/base.rb +57 -0
  31. data/lib/infinity_test/framework/padrino.rb +33 -0
  32. data/lib/infinity_test/framework/rails.rb +35 -0
  33. data/lib/infinity_test/framework/rubygems.rb +29 -0
  34. data/lib/infinity_test/framework/shared_example.rb +47 -0
  35. data/lib/infinity_test/observer/base.rb +40 -0
  36. data/lib/infinity_test/observer/filewatcher.rb +72 -0
  37. data/lib/infinity_test/observer/listen.rb +74 -0
  38. data/lib/infinity_test/observer/shared_example.rb +35 -0
  39. data/lib/infinity_test/old_dsl/configuration.rb +26 -0
  40. data/lib/infinity_test/strategy/base.rb +34 -0
  41. data/lib/infinity_test/strategy/rbenv.rb +32 -0
  42. data/lib/infinity_test/strategy/ruby_default.rb +20 -0
  43. data/lib/infinity_test/strategy/rvm.rb +50 -0
  44. data/lib/infinity_test/strategy/shared_example.rb +32 -0
  45. data/lib/infinity_test/test_framework/base.rb +64 -0
  46. data/lib/infinity_test/test_framework/rspec.rb +48 -0
  47. data/lib/infinity_test/test_framework/shared_example.rb +56 -0
  48. data/lib/infinity_test/test_framework/test_unit.rb +57 -0
  49. data/lib/infinity_test.rb +53 -35
  50. data/spec/infinity_test/core/auto_discover_spec.rb +149 -0
  51. data/spec/infinity_test/core/base_spec.rb +240 -0
  52. data/spec/infinity_test/core/callback_spec.rb +89 -0
  53. data/spec/infinity_test/core/changed_file_spec.rb +26 -0
  54. data/spec/infinity_test/core/command_builder_spec.rb +38 -0
  55. data/spec/infinity_test/core/configuration_merge_spec.rb +124 -0
  56. data/spec/infinity_test/core/continuous_test_server_spec.rb +116 -0
  57. data/spec/infinity_test/core/load_configuration_spec.rb +43 -0
  58. data/spec/infinity_test/core/notifier_spec.rb +151 -0
  59. data/spec/infinity_test/core/options_spec.rb +168 -0
  60. data/spec/infinity_test/core/runner_spec.rb +17 -0
  61. data/spec/infinity_test/framework/base_spec.rb +55 -0
  62. data/spec/infinity_test/framework/padrino_spec.rb +36 -0
  63. data/spec/infinity_test/framework/rails_spec.rb +36 -0
  64. data/spec/infinity_test/framework/rubygems_spec.rb +34 -0
  65. data/spec/infinity_test/observer/base_spec.rb +78 -0
  66. data/spec/infinity_test/observer/filewatcher_spec.rb +51 -0
  67. data/spec/infinity_test/observer/listen_spec.rb +50 -0
  68. data/spec/infinity_test/{builder_spec.rb → strategy/base_spec.rb} +1 -2
  69. data/spec/infinity_test/strategy/rbenv_spec.rb +53 -0
  70. data/spec/infinity_test/strategy/ruby_default_spec.rb +32 -0
  71. data/spec/infinity_test/strategy/rvm_spec.rb +69 -0
  72. data/spec/infinity_test/test_framework/rspec_spec.rb +119 -0
  73. data/spec/infinity_test/test_framework/test_unit_spec.rb +193 -0
  74. data/spec/spec_helper.rb +34 -119
  75. metadata +276 -205
  76. data/.infinity_test +0 -36
  77. data/.rvmrc +0 -1
  78. data/Gemfile.lock +0 -62
  79. data/Readme.markdown +0 -122
  80. data/Tasks +0 -4
  81. data/VERSION.yml +0 -5
  82. data/buzz_images/buzz_lightyear.jpg +0 -0
  83. data/buzz_images/buzz_lightyear_continencia.gif +0 -0
  84. data/buzz_images/to_infinity_and_beyond.png +0 -0
  85. data/features/heuristics.feature +0 -23
  86. data/features/support/env.rb +0 -2
  87. data/images/fuuu/sucess.png +0 -0
  88. data/lib/infinity_test/application.rb +0 -355
  89. data/lib/infinity_test/application_library/rails.rb +0 -94
  90. data/lib/infinity_test/application_library/rubygems.rb +0 -43
  91. data/lib/infinity_test/binary_path.rb +0 -43
  92. data/lib/infinity_test/builder.rb +0 -67
  93. data/lib/infinity_test/command.rb +0 -58
  94. data/lib/infinity_test/configuration.rb +0 -273
  95. data/lib/infinity_test/continuous_testing.rb +0 -40
  96. data/lib/infinity_test/dependencies.rb +0 -80
  97. data/lib/infinity_test/environment.rb +0 -15
  98. data/lib/infinity_test/heuristics.rb +0 -36
  99. data/lib/infinity_test/heuristics_helper.rb +0 -9
  100. data/lib/infinity_test/options.rb +0 -89
  101. data/lib/infinity_test/runner.rb +0 -38
  102. data/lib/infinity_test/test_framework.rb +0 -109
  103. data/lib/infinity_test/test_library/bacon.rb +0 -55
  104. data/lib/infinity_test/test_library/cucumber.rb +0 -22
  105. data/lib/infinity_test/test_library/rspec.rb +0 -58
  106. data/lib/infinity_test/test_library/test_unit.rb +0 -52
  107. data/lib/infinity_test/test_unit_loader.rb +0 -5
  108. data/spec/factories/buzz/lib/buzz.rb +0 -0
  109. data/spec/factories/buzz/spec/buzz_spec.rb +0 -0
  110. data/spec/factories/company/Gemfile +0 -0
  111. data/spec/factories/company/lib/company.rb +0 -0
  112. data/spec/factories/company/test/company_test.rb +0 -0
  113. data/spec/factories/images/failure.png +0 -0
  114. data/spec/factories/images/pending.png +0 -0
  115. data/spec/factories/images/sucess.png +0 -0
  116. data/spec/factories/infinity_test +0 -5
  117. data/spec/factories/infinity_test_example +0 -7
  118. data/spec/factories/slinky/spec/slinky/slinky_spec.rb +0 -0
  119. data/spec/factories/travel/lib/travel.rb +0 -0
  120. data/spec/factories/travel/test/partner_test.rb +0 -0
  121. data/spec/factories/travel/test/travel_test.rb +0 -0
  122. data/spec/factories/wood/lib/wood.rb +0 -0
  123. data/spec/factories/wood/spec/wood_spec.rb +0 -0
  124. data/spec/infinity_test/application_library/rails_spec.rb +0 -140
  125. data/spec/infinity_test/application_library/rubygems_spec.rb +0 -52
  126. data/spec/infinity_test/application_spec.rb +0 -424
  127. data/spec/infinity_test/binary_path_spec.rb +0 -72
  128. data/spec/infinity_test/command_spec.rb +0 -53
  129. data/spec/infinity_test/configuration_spec.rb +0 -377
  130. data/spec/infinity_test/continuous_testing_spec.rb +0 -25
  131. data/spec/infinity_test/environment_spec.rb +0 -23
  132. data/spec/infinity_test/heuristics_helper_spec.rb +0 -15
  133. data/spec/infinity_test/heuristics_spec.rb +0 -127
  134. data/spec/infinity_test/options_spec.rb +0 -91
  135. data/spec/infinity_test/runner_spec.rb +0 -42
  136. data/spec/infinity_test/test_framework_spec.rb +0 -127
  137. data/spec/infinity_test/test_library/bacon_spec.rb +0 -150
  138. data/spec/infinity_test/test_library/cucumber_spec.rb +0 -8
  139. data/spec/infinity_test/test_library/rspec_spec.rb +0 -185
  140. data/spec/infinity_test/test_library/test_unit_spec.rb +0 -184
  141. data/spec/infinity_test_spec.rb +0 -40
  142. /data/images/faces/{sucess.png → success.png} +0 -0
  143. /data/images/hands/{sucess.png → success.png} +0 -0
  144. /data/images/mario_bros/{sucess.jpg → success.jpg} +0 -0
  145. /data/images/rails/{sucess.png → success.png} +0 -0
  146. /data/images/rubies/{sucess.png → success.png} +0 -0
  147. /data/images/simpson/{sucess.jpg → success.jpg} +0 -0
  148. /data/images/street_fighter/{sucess.jpg → success.jpg} +0 -0
  149. /data/images/toy_story/{sucess.png → success.png} +0 -0
@@ -0,0 +1,240 @@
1
+ require "spec_helper"
2
+
3
+ module InfinityTest
4
+ describe Base do
5
+ describe ".setup" do
6
+ it "yields self" do
7
+ Base.setup do |config|
8
+ expect(config).to be InfinityTest::Base
9
+ end
10
+ end
11
+ end
12
+
13
+ describe ".using_bundler?" do
14
+ it "returns the same bundler accessor" do
15
+ expect(Base.using_bundler?).to equal Base.bundler
16
+ end
17
+ end
18
+
19
+ describe "#verbose?" do
20
+ it "returns the same verbose accessor" do
21
+ expect(Base.verbose?).to equal Base.verbose
22
+ end
23
+ end
24
+
25
+ describe ".observer" do
26
+ it "has listen as default observer" do
27
+ expect(Base.observer).to equal :listen
28
+ end
29
+ end
30
+
31
+ describe ".ignore_test_files" do
32
+ it "does not have test files to ignore as default" do
33
+ expect(Base.ignore_test_files).to eql []
34
+ end
35
+ end
36
+
37
+ describe "#ignore_test_folders" do
38
+ it "does not ignore test folders as default" do
39
+ expect(Base.ignore_test_folders).to eql []
40
+ end
41
+ end
42
+
43
+ describe ".before" do
44
+ after { Base.clear_callbacks! }
45
+
46
+ it "creates before callback instance and pushes to the callback accessor" do
47
+ before_callback = Base.before(:all) { 'To Infinity and beyond!' }
48
+ expect(before_callback).to be_a Core::Callback
49
+ expect(before_callback.type).to eq :before
50
+ expect(before_callback.scope).to eq :all
51
+ expect(Base.callbacks).to include before_callback
52
+ end
53
+
54
+ it "defaults scope to :all" do
55
+ before_callback = Base.before { 'test' }
56
+ expect(before_callback.scope).to eq :all
57
+ end
58
+ end
59
+
60
+ describe ".after" do
61
+ after { Base.clear_callbacks! }
62
+
63
+ it "creates after callback instance and pushes to the callback accessor" do
64
+ after_callback = Base.after(:each_ruby) { 'done' }
65
+ expect(after_callback).to be_a Core::Callback
66
+ expect(after_callback.type).to eq :after
67
+ expect(after_callback.scope).to eq :each_ruby
68
+ expect(Base.callbacks).to include after_callback
69
+ end
70
+ end
71
+
72
+ describe ".run_before_callbacks" do
73
+ after { Base.clear_callbacks! }
74
+
75
+ it "runs all before callbacks for the given scope" do
76
+ results = []
77
+ Base.before(:all) { results << 'first' }
78
+ Base.before(:all) { results << 'second' }
79
+ Base.before(:each_ruby) { results << 'each_ruby' }
80
+
81
+ Base.run_before_callbacks(:all)
82
+ expect(results).to eq ['first', 'second']
83
+ end
84
+ end
85
+
86
+ describe ".run_after_callbacks" do
87
+ after { Base.clear_callbacks! }
88
+
89
+ it "runs all after callbacks for the given scope" do
90
+ results = []
91
+ Base.after(:all) { results << 'first' }
92
+ Base.after(:all) { results << 'second' }
93
+
94
+ Base.run_after_callbacks(:all)
95
+ expect(results).to eq ['first', 'second']
96
+ end
97
+ end
98
+
99
+ describe ".just_watch" do
100
+ it "defaults to false" do
101
+ expect(Base.just_watch).to eq false
102
+ end
103
+ end
104
+
105
+ describe ".notifications" do
106
+ it "sets the notification class accessor" do
107
+ silence_stream(STDOUT) do
108
+ Base.notifications(:osascript)
109
+ expect(Base.notifications).to be :osascript
110
+ end
111
+ end
112
+
113
+ it "sets the images" do
114
+ silence_stream(STDOUT) do
115
+ Base.notifications(:osascript) do
116
+ show_images :success_image => 'foo', :failure_image => 'bar', :pending_image => 'baz'
117
+ end
118
+ end
119
+ expect(Base.success_image).to eql 'foo'
120
+ expect(Base.failure_image).to eql 'bar'
121
+ expect(Base.pending_image).to eql 'baz'
122
+ Base.success_image = nil
123
+ Base.failure_image = nil
124
+ Base.pending_image = nil
125
+ end
126
+
127
+ it "sets the mode" do
128
+ silence_stream(STDOUT) do
129
+ Base.notifications(:osascript) do
130
+ show_images :mode => :mortal_kombat
131
+ end
132
+ end
133
+ expect(Base.mode).to be :mortal_kombat
134
+ end
135
+ end
136
+
137
+ describe ".use" do
138
+ before do
139
+ @old_rubies = Base.rubies
140
+ @old_specific_options = Base.specific_options
141
+ @test_framework = Base.test_framework
142
+ @framework = Base.framework
143
+ @verbose = Base.verbose
144
+ @gemset = Base.gemset
145
+ end
146
+
147
+ after do
148
+ Base.rubies = @old_rubies
149
+ Base.specific_options = @old_specific_options
150
+ Base.test_framework = @test_framework
151
+ Base.framework = @framework
152
+ Base.verbose = @verbose
153
+ Base.gemset = @gemset
154
+ end
155
+
156
+ it "sets the rubies" do
157
+ silence_stream(STDOUT) do
158
+ Base.use :rubies => %w(foo bar)
159
+ end
160
+ expect(Base.rubies).to eql %w(foo bar)
161
+ end
162
+
163
+ it "sets the specific options" do
164
+ silence_stream(STDOUT) do
165
+ Base.use :specific_options => '-J -Ilib -Itest'
166
+ end
167
+ expect(Base.specific_options).to eql '-J -Ilib -Itest'
168
+ end
169
+
170
+ it "sets the test framework" do
171
+ silence_stream(STDOUT) do
172
+ Base.use :test_framework => :rspec
173
+ end
174
+ expect(Base.test_framework).to be :rspec
175
+ end
176
+
177
+ it "sets the app framework" do
178
+ silence_stream(STDOUT) do
179
+ Base.use :app_framework => :rails
180
+ end
181
+ expect(Base.framework).to be :rails
182
+ end
183
+
184
+ it "sets the verbose mode" do
185
+ silence_stream(STDOUT) do
186
+ Base.use :verbose => false
187
+ end
188
+ expect(Base.verbose).to equal false
189
+ end
190
+
191
+ it "sets the gemset" do
192
+ silence_stream(STDOUT) do
193
+ Base.use :gemset => 'infinity_test'
194
+ end
195
+ expect(Base.gemset).to eql 'infinity_test'
196
+ end
197
+ end
198
+
199
+ describe ".heuristics" do
200
+ it "accepts a block" do
201
+ expect { Base.heuristics {} }.to_not raise_exception
202
+ end
203
+ end
204
+
205
+ describe ".replace_patterns" do
206
+ it "accepts a block" do
207
+ expect { Base.replace_patterns {} }.to_not raise_exception
208
+ end
209
+ end
210
+
211
+ describe ".merge!" do
212
+ let(:options) { Object.new }
213
+ let(:configuration_merge) { Object.new }
214
+
215
+ it "calls merge on the configuration merge object" do
216
+ expect(ConfigurationMerge).to receive(:new).with(Core::Base, options).and_return(configuration_merge)
217
+ expect(configuration_merge).to receive(:merge!)
218
+ Core::Base.merge!(options)
219
+ end
220
+ end
221
+
222
+ describe ".clear" do
223
+ it "calls clear_terminal method" do
224
+ silence_stream(STDOUT) do
225
+ expect(Base).to receive(:clear_terminal).and_return(true)
226
+ Base.clear(:terminal)
227
+ end
228
+ end
229
+ end
230
+
231
+ describe ".clear_terminal" do
232
+ it "calls system clear" do
233
+ silence_stream(STDOUT) do
234
+ expect(Base).to receive(:system).with('clear').and_return(true)
235
+ Base.clear_terminal
236
+ end
237
+ end
238
+ end
239
+ end
240
+ end
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Core
5
+ describe Callback do
6
+ describe '#initialize' do
7
+ it 'creates a before callback with default scope' do
8
+ callback = Callback.new(:before) { 'test' }
9
+ expect(callback.type).to eq :before
10
+ expect(callback.scope).to eq :all
11
+ end
12
+
13
+ it 'creates an after callback with custom scope' do
14
+ callback = Callback.new(:after, :each_ruby) { 'test' }
15
+ expect(callback.type).to eq :after
16
+ expect(callback.scope).to eq :each_ruby
17
+ end
18
+
19
+ it 'raises error for invalid scope' do
20
+ expect { Callback.new(:before, :invalid) { 'test' } }.to raise_error(ArgumentError)
21
+ end
22
+ end
23
+
24
+ describe '#call' do
25
+ it 'executes the block without arguments' do
26
+ result = nil
27
+ callback = Callback.new(:before) { result = 'executed' }
28
+ callback.call
29
+ expect(result).to eq 'executed'
30
+ end
31
+
32
+ it 'executes the block with environment argument' do
33
+ result = nil
34
+ callback = Callback.new(:before, :each_ruby) { |env| result = env[:ruby_version] }
35
+ callback.call(ruby_version: '3.0.0')
36
+ expect(result).to eq '3.0.0'
37
+ end
38
+ end
39
+
40
+ describe '#before?' do
41
+ it 'returns true for before callbacks' do
42
+ callback = Callback.new(:before) { 'test' }
43
+ expect(callback).to be_before
44
+ end
45
+
46
+ it 'returns false for after callbacks' do
47
+ callback = Callback.new(:after) { 'test' }
48
+ expect(callback).not_to be_before
49
+ end
50
+ end
51
+
52
+ describe '#after?' do
53
+ it 'returns true for after callbacks' do
54
+ callback = Callback.new(:after) { 'test' }
55
+ expect(callback).to be_after
56
+ end
57
+
58
+ it 'returns false for before callbacks' do
59
+ callback = Callback.new(:before) { 'test' }
60
+ expect(callback).not_to be_after
61
+ end
62
+ end
63
+
64
+ describe '#all?' do
65
+ it 'returns true for all scope' do
66
+ callback = Callback.new(:before, :all) { 'test' }
67
+ expect(callback).to be_all
68
+ end
69
+
70
+ it 'returns false for each_ruby scope' do
71
+ callback = Callback.new(:before, :each_ruby) { 'test' }
72
+ expect(callback).not_to be_all
73
+ end
74
+ end
75
+
76
+ describe '#each_ruby?' do
77
+ it 'returns true for each_ruby scope' do
78
+ callback = Callback.new(:before, :each_ruby) { 'test' }
79
+ expect(callback).to be_each_ruby
80
+ end
81
+
82
+ it 'returns false for all scope' do
83
+ callback = Callback.new(:before, :all) { 'test' }
84
+ expect(callback).not_to be_each_ruby
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ describe ChangedFile do
5
+ let(:match_data) { /(.)(.)(\d+)(\d)/.match("THX1138.") }
6
+ let(:changed_file) { ChangedFile.new(match_data) }
7
+
8
+ describe '#name' do
9
+ subject { changed_file.name }
10
+
11
+ it { should eq 'HX1138' }
12
+ end
13
+
14
+ describe '#path' do
15
+ subject { changed_file.path }
16
+
17
+ it { should eq 'H' }
18
+ end
19
+
20
+ describe '#match_data' do
21
+ subject { changed_file.match_data }
22
+
23
+ it { should be match_data }
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Core
5
+ describe CommandBuilder do
6
+ describe "#add" do
7
+ it "adds the argument in the command" do
8
+ expect(subject.ruby.option(:S).add(:rspec).add(:spec)).to eq 'ruby -S rspec spec'
9
+ end
10
+ end
11
+
12
+ describe "#option" do
13
+ it "puts options with one dash and allows adding more keywords" do
14
+ expect(subject.bundle.exec.ruby.option(:S).rspec).to eq 'bundle exec ruby -S rspec'
15
+ end
16
+ end
17
+
18
+ describe "#opt" do
19
+ it "puts double dash options and allows adding keywords" do
20
+ expect(subject.ruby.opt(:copyright)).to eq 'ruby --copyright'
21
+ end
22
+ end
23
+
24
+ describe '#method_missing' do
25
+ it "puts space after every keyword" do
26
+ expect(subject.bundle.exec.ruby.some_file).to eq 'bundle exec ruby some_file'
27
+ end
28
+ end
29
+
30
+ describe "#respond_to?" do
31
+ it "responds to anything because missing methods will build the command" do
32
+ expect(subject.respond_to?(:foo)).to be true
33
+ expect(subject.respond_to?(:bar)).to be true
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,124 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Core
5
+ describe ConfigurationMerge do
6
+ let(:base) do
7
+ OpenStruct.new(
8
+ :bundler => true,
9
+ :verbose => true,
10
+ :strategy => :auto_discover,
11
+ :observer => :watchr,
12
+ :rubies => [],
13
+ :specific_options => '',
14
+ :framework => :auto_discover,
15
+ :test_framework => :auto_discover,
16
+ :infinity_and_beyond => true
17
+ )
18
+ end
19
+
20
+ let(:options) { Options.new([]) }
21
+ subject { ConfigurationMerge.new(base, options) }
22
+
23
+ describe "#merge!" do
24
+ it "keeps the strategy when options strategy is blank" do
25
+ subject.merge!
26
+ expect(base.strategy).to be :auto_discover
27
+ end
28
+
29
+ it "merges the strategies" do
30
+ expect(options).to receive(:strategy).twice.and_return(:rbenv)
31
+ subject.merge!
32
+ expect(base.strategy).to be :rbenv
33
+ end
34
+
35
+ it "keeps the rubies when options rubies is nil" do
36
+ base.rubies = %w(jruby ree)
37
+ expect(options).to receive(:rubies).and_return(nil)
38
+ subject.merge!
39
+ expect(base.rubies).to eq %w(jruby ree)
40
+ end
41
+
42
+ it "overwrites the rubies when options rubies is empty" do
43
+ base.rubies = %w(jruby ree)
44
+ expect(options).to receive(:rubies).twice.and_return([])
45
+ subject.merge!
46
+ expect(base.rubies).to be_blank
47
+ end
48
+
49
+ it "merges the rubies" do
50
+ expect(options).to receive(:rubies).twice.and_return(%w(ree jruby))
51
+ subject.merge!
52
+ expect(base.rubies).to eql %w(ree jruby)
53
+ end
54
+
55
+ it "keeps the test framework when options test framework is blank" do
56
+ subject.merge!
57
+ expect(base.test_framework).to be :auto_discover
58
+ end
59
+
60
+ it "merges the test library" do
61
+ expect(options).to receive(:test_framework).twice.and_return(:rspec)
62
+ subject.merge!
63
+ expect(base.test_framework).to be :rspec
64
+ end
65
+
66
+ it "keeps the framework when options framework is blank" do
67
+ subject.merge!
68
+ expect(base.framework).to be :auto_discover
69
+ end
70
+
71
+ it "merges the framework" do
72
+ expect(options).to receive(:framework).twice.and_return(:rails)
73
+ subject.merge!
74
+ expect(base.framework).to be :rails
75
+ end
76
+
77
+ it "keeps the specific option when options specific is blank" do
78
+ subject.merge!
79
+ expect(base.specific_options).to eql ''
80
+ end
81
+
82
+ it "merges the specific options" do
83
+ expect(options).to receive(:specific_options).twice.and_return('-J -Ilib -Itest')
84
+ subject.merge!
85
+ expect(base.specific_options).to eql '-J -Ilib -Itest'
86
+ end
87
+
88
+ it "merges with the infinity test and beyond" do
89
+ expect(options).to receive(:infinity_and_beyond).twice.and_return(false)
90
+ subject.merge!
91
+ expect(base.infinity_and_beyond).to be false
92
+ end
93
+
94
+ it "keeps the base default if option infinity test and beyond is nil" do
95
+ expect(options).to receive(:infinity_and_beyond).and_return(nil)
96
+ subject.merge!
97
+ expect(base.infinity_and_beyond).to be true
98
+ end
99
+
100
+ it "keeps the verbose mode when verbose mode is blank" do
101
+ subject.merge!
102
+ expect(base.verbose).to be true
103
+ end
104
+
105
+ it "merges the verbose mode" do
106
+ expect(options).to receive(:verbose).twice.and_return(false)
107
+ subject.merge!
108
+ expect(base.verbose).to be false
109
+ end
110
+
111
+ it "keeps the bundler default when bundler is blank" do
112
+ subject.merge!
113
+ expect(base.bundler).to be true
114
+ end
115
+
116
+ it "merges the bundler mode" do
117
+ expect(options).to receive(:bundler).twice.and_return(false)
118
+ subject.merge!
119
+ expect(base.bundler).to be false
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,116 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Core
5
+ describe ContinuousTestServer do
6
+ let(:base) { Core::Base }
7
+ let(:continuous_test_server) { ContinuousTestServer.new(base) }
8
+
9
+ describe '#start!' do
10
+ it 'runs strategy and starts observer' do
11
+ expect(continuous_test_server).to receive(:run_strategy)
12
+ expect(continuous_test_server).to receive(:start_observer)
13
+ continuous_test_server.start
14
+ end
15
+ end
16
+
17
+ describe '#start_observer' do
18
+ context 'when base configuration as infinity and beyond' do
19
+ before do
20
+ expect(base).to receive(:infinity_and_beyond).and_return(true)
21
+ allow(base).to receive(:framework).and_return(:rails)
22
+ allow(base).to receive(:observer).and_return(:listen)
23
+ end
24
+
25
+ it 'adds framework heuristics and starts the observer' do
26
+ expect(continuous_test_server.framework).to receive(:heuristics!)
27
+ expect(continuous_test_server.observer).to receive(:start!)
28
+ continuous_test_server.start_observer
29
+ end
30
+ end
31
+
32
+ context 'when base configuration is not infinity and beyond' do
33
+ before do
34
+ expect(base).to receive(:infinity_and_beyond).and_return(false)
35
+ allow(base).to receive(:framework).and_return(:rails)
36
+ end
37
+
38
+ it 'does not start the observer' do
39
+ expect(continuous_test_server.framework).to_not receive(:heuristics!)
40
+ expect(continuous_test_server.observer).to_not receive(:start!)
41
+ continuous_test_server.start_observer
42
+ end
43
+ end
44
+ end
45
+
46
+ describe '#notify' do
47
+ let(:continuous_test_server) { ContinuousTestServer.new(base) }
48
+ let(:test_message) { '200 examples, 0 failures, 0 pending' }
49
+
50
+ context 'when have notification library' do
51
+ let(:test_framework) { double }
52
+ let(:base) { double(notifications: :auto_discover) }
53
+
54
+ before do
55
+ expect(continuous_test_server).to receive(:test_framework).exactly(:twice).and_return(test_framework)
56
+ expect(test_framework).to receive(:test_message=).with(test_message)
57
+ end
58
+
59
+ it 'instantiates a notifier passing the strategy result and the continuous server' do
60
+ expect(Core::Notifier).to receive(:new).and_return(double(notify: true))
61
+ continuous_test_server.notify(test_message)
62
+ end
63
+ end
64
+
65
+ context 'when do not have notification library' do
66
+ let(:base) { double(notifications: nil) }
67
+
68
+ it 'does not instantiate a notifier' do
69
+ expect(Core::Notifier).to_not receive(:new)
70
+ continuous_test_server.notify(test_message)
71
+ end
72
+ end
73
+ end
74
+
75
+ describe '#rerun_strategy' do
76
+ let(:test_framework) { double }
77
+
78
+ before do
79
+ expect(continuous_test_server).to receive(:test_framework).twice.and_return(test_framework)
80
+ end
81
+
82
+ it 'runs strategy again and ensures the test files is nil after' do
83
+ expect(test_framework).to receive(:test_files=).twice
84
+ expect(continuous_test_server).to receive(:run_strategy)
85
+ continuous_test_server.rerun_strategy('base_test.py')
86
+ end
87
+ end
88
+
89
+ describe '#strategy' do
90
+ subject { continuous_test_server.strategy }
91
+ before { expect(base).to receive(:strategy).and_return(:ruby_default) }
92
+
93
+ it { should be_instance_of InfinityTest::Strategy::RubyDefault }
94
+ end
95
+
96
+ describe '#test_framework' do
97
+ subject { continuous_test_server.test_framework }
98
+ before { expect(base).to receive(:test_framework).and_return(:rspec) }
99
+
100
+ it { should be_instance_of InfinityTest::TestFramework::Rspec }
101
+ end
102
+
103
+ describe '#binary' do
104
+ subject { continuous_test_server }
105
+
106
+ it { should respond_to :binary }
107
+ end
108
+
109
+ describe '#test_files' do
110
+ subject { continuous_test_server }
111
+
112
+ it { should respond_to :test_files }
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,43 @@
1
+ require "spec_helper"
2
+
3
+ module InfinityTest
4
+ describe LoadConfiguration do
5
+ describe "#load!" do
6
+ it "loads global file and project file" do
7
+ expect(subject).to receive(:load_global_file!).and_return(true)
8
+ expect(subject).to receive(:load_project_file!).and_return(true)
9
+ subject.load!
10
+ end
11
+ end
12
+
13
+ describe "#load_global_file!" do
14
+ it "loads the global file" do
15
+ subject.global_file = 'foo'
16
+ expect(subject).to receive(:load_file).with('foo').and_return(true)
17
+ subject.load_global_file!
18
+ end
19
+ end
20
+
21
+ describe "#load_project_file!" do
22
+ it "loads the project file" do
23
+ subject.project_file = 'bar'
24
+ expect(subject).to receive(:load_file).with('bar').and_return(true)
25
+ subject.load_project_file!
26
+ end
27
+ end
28
+
29
+ describe "#load_file" do
30
+ it "loads if file exists" do
31
+ expect(File).to receive(:exist?).with('bar').and_return(true)
32
+ expect(subject).to receive(:load).with('bar').and_return(true)
33
+ expect(subject.load_file('bar')).to be true
34
+ end
35
+
36
+ it "does not load if file does not exist" do
37
+ expect(File).to receive(:exist?).with('baz').and_return(false)
38
+ expect(subject).to_not receive(:load)
39
+ subject.load_file('baz')
40
+ end
41
+ end
42
+ end
43
+ end