infinity_test 1.0.3 → 2.0.0.rc2

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 (175) 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.md +84 -0
  8. data/History.markdown +82 -0
  9. data/{.infinity_test → INFINITY_TEST} +18 -15
  10. data/LICENSE.txt +2 -2
  11. data/README.md +867 -0
  12. data/Rakefile +1 -65
  13. data/TODO.markdown +38 -24
  14. data/bin/infinity_test +1 -4
  15. data/images/fuuu/pending.png +0 -0
  16. data/images/fuuu/success.png +0 -0
  17. data/infinity_test.gemspec +41 -189
  18. data/lib/infinity_test/core/auto_discover.rb +67 -0
  19. data/lib/infinity_test/core/base.rb +369 -0
  20. data/lib/infinity_test/core/callback.rb +59 -0
  21. data/lib/infinity_test/core/changed_file.rb +13 -0
  22. data/lib/infinity_test/core/command_builder.rb +48 -0
  23. data/lib/infinity_test/core/command_runner.rb +38 -0
  24. data/lib/infinity_test/core/configuration_merge.rb +37 -0
  25. data/lib/infinity_test/core/continuous_test_server.rb +124 -0
  26. data/lib/infinity_test/core/load_configuration.rb +48 -0
  27. data/lib/infinity_test/core/notifier.rb +59 -0
  28. data/lib/infinity_test/core/options.rb +134 -0
  29. data/lib/infinity_test/core/runner.rb +18 -0
  30. data/lib/infinity_test/core/version.rb +5 -0
  31. data/lib/infinity_test/framework/base.rb +93 -0
  32. data/lib/infinity_test/framework/django.rb +109 -0
  33. data/lib/infinity_test/framework/elixir_mix.rb +47 -0
  34. data/lib/infinity_test/framework/fast_api.rb +104 -0
  35. data/lib/infinity_test/framework/padrino.rb +30 -0
  36. data/lib/infinity_test/framework/phoenix.rb +72 -0
  37. data/lib/infinity_test/framework/python_package.rb +97 -0
  38. data/lib/infinity_test/framework/rails.rb +26 -0
  39. data/lib/infinity_test/framework/rocket.rb +70 -0
  40. data/lib/infinity_test/framework/rubygems.rb +29 -0
  41. data/lib/infinity_test/framework/rust_cargo.rb +69 -0
  42. data/lib/infinity_test/framework/shared_example.rb +47 -0
  43. data/lib/infinity_test/observer/base.rb +40 -0
  44. data/lib/infinity_test/observer/filewatcher.rb +72 -0
  45. data/lib/infinity_test/observer/listen.rb +74 -0
  46. data/lib/infinity_test/observer/shared_example.rb +35 -0
  47. data/lib/infinity_test/old_dsl/configuration.rb +26 -0
  48. data/lib/infinity_test/strategy/base.rb +50 -0
  49. data/lib/infinity_test/strategy/elixir_default.rb +20 -0
  50. data/lib/infinity_test/strategy/python_default.rb +22 -0
  51. data/lib/infinity_test/strategy/rbenv.rb +34 -0
  52. data/lib/infinity_test/strategy/ruby_default.rb +21 -0
  53. data/lib/infinity_test/strategy/rust_default.rb +21 -0
  54. data/lib/infinity_test/strategy/rvm.rb +52 -0
  55. data/lib/infinity_test/strategy/shared_example.rb +32 -0
  56. data/lib/infinity_test/test_framework/base.rb +64 -0
  57. data/lib/infinity_test/test_framework/cargo_test.rb +49 -0
  58. data/lib/infinity_test/test_framework/ex_unit.rb +53 -0
  59. data/lib/infinity_test/test_framework/pytest.rb +65 -0
  60. data/lib/infinity_test/test_framework/rspec.rb +48 -0
  61. data/lib/infinity_test/test_framework/shared_example.rb +56 -0
  62. data/lib/infinity_test/test_framework/test_unit.rb +57 -0
  63. data/lib/infinity_test.rb +66 -35
  64. data/spec/infinity_test/core/auto_discover_spec.rb +175 -0
  65. data/spec/infinity_test/core/base_spec.rb +240 -0
  66. data/spec/infinity_test/core/callback_spec.rb +89 -0
  67. data/spec/infinity_test/core/changed_file_spec.rb +26 -0
  68. data/spec/infinity_test/core/command_builder_spec.rb +38 -0
  69. data/spec/infinity_test/core/configuration_merge_spec.rb +124 -0
  70. data/spec/infinity_test/core/continuous_test_server_spec.rb +116 -0
  71. data/spec/infinity_test/core/load_configuration_spec.rb +43 -0
  72. data/spec/infinity_test/core/notifier_spec.rb +151 -0
  73. data/spec/infinity_test/core/options_spec.rb +168 -0
  74. data/spec/infinity_test/core/runner_spec.rb +17 -0
  75. data/spec/infinity_test/framework/base_spec.rb +55 -0
  76. data/spec/infinity_test/framework/django_spec.rb +95 -0
  77. data/spec/infinity_test/framework/elixir_mix_spec.rb +44 -0
  78. data/spec/infinity_test/framework/fast_api_spec.rb +96 -0
  79. data/spec/infinity_test/framework/padrino_spec.rb +58 -0
  80. data/spec/infinity_test/framework/phoenix_spec.rb +85 -0
  81. data/spec/infinity_test/framework/python_package_spec.rb +95 -0
  82. data/spec/infinity_test/framework/rails_spec.rb +58 -0
  83. data/spec/infinity_test/framework/rocket_spec.rb +69 -0
  84. data/spec/infinity_test/framework/rubygems_spec.rb +34 -0
  85. data/spec/infinity_test/framework/rust_cargo_spec.rb +94 -0
  86. data/spec/infinity_test/observer/base_spec.rb +78 -0
  87. data/spec/infinity_test/observer/filewatcher_spec.rb +51 -0
  88. data/spec/infinity_test/observer/listen_spec.rb +50 -0
  89. data/spec/infinity_test/{builder_spec.rb → strategy/base_spec.rb} +1 -2
  90. data/spec/infinity_test/strategy/elixir_default_spec.rb +46 -0
  91. data/spec/infinity_test/strategy/python_default_spec.rb +56 -0
  92. data/spec/infinity_test/strategy/rbenv_spec.rb +70 -0
  93. data/spec/infinity_test/strategy/ruby_default_spec.rb +49 -0
  94. data/spec/infinity_test/strategy/rust_default_spec.rb +56 -0
  95. data/spec/infinity_test/strategy/rvm_spec.rb +86 -0
  96. data/spec/infinity_test/test_framework/cargo_test_spec.rb +145 -0
  97. data/spec/infinity_test/test_framework/ex_unit_spec.rb +153 -0
  98. data/spec/infinity_test/test_framework/pytest_spec.rb +182 -0
  99. data/spec/infinity_test/test_framework/rspec_spec.rb +119 -0
  100. data/spec/infinity_test/test_framework/test_unit_spec.rb +193 -0
  101. data/spec/spec_helper.rb +34 -119
  102. metadata +315 -177
  103. data/.rvmrc +0 -1
  104. data/Gemfile.lock +0 -62
  105. data/Readme.markdown +0 -147
  106. data/Tasks +0 -4
  107. data/VERSION.yml +0 -5
  108. data/buzz_images/buzz_lightyear.jpg +0 -0
  109. data/buzz_images/buzz_lightyear_continencia.gif +0 -0
  110. data/buzz_images/to_infinity_and_beyond.png +0 -0
  111. data/features/heuristics.feature +0 -23
  112. data/features/support/env.rb +0 -2
  113. data/images/fuuu/sucess.png +0 -0
  114. data/lib/infinity_test/application.rb +0 -362
  115. data/lib/infinity_test/application_library/rails.rb +0 -94
  116. data/lib/infinity_test/application_library/rubygems.rb +0 -43
  117. data/lib/infinity_test/binary_path.rb +0 -43
  118. data/lib/infinity_test/builder.rb +0 -66
  119. data/lib/infinity_test/command.rb +0 -58
  120. data/lib/infinity_test/configuration.rb +0 -277
  121. data/lib/infinity_test/continuous_testing.rb +0 -40
  122. data/lib/infinity_test/dependencies.rb +0 -80
  123. data/lib/infinity_test/environment.rb +0 -15
  124. data/lib/infinity_test/heuristics.rb +0 -36
  125. data/lib/infinity_test/heuristics_helper.rb +0 -9
  126. data/lib/infinity_test/options.rb +0 -96
  127. data/lib/infinity_test/runner.rb +0 -38
  128. data/lib/infinity_test/test_framework.rb +0 -110
  129. data/lib/infinity_test/test_library/bacon.rb +0 -55
  130. data/lib/infinity_test/test_library/cucumber.rb +0 -22
  131. data/lib/infinity_test/test_library/rspec.rb +0 -60
  132. data/lib/infinity_test/test_library/test_unit.rb +0 -52
  133. data/lib/infinity_test/test_unit_loader.rb +0 -5
  134. data/spec/factories/buzz/lib/buzz.rb +0 -0
  135. data/spec/factories/buzz/spec/buzz_spec.rb +0 -0
  136. data/spec/factories/company/Gemfile +0 -0
  137. data/spec/factories/company/lib/company.rb +0 -0
  138. data/spec/factories/company/test/company_test.rb +0 -0
  139. data/spec/factories/images/failure.png +0 -0
  140. data/spec/factories/images/pending.png +0 -0
  141. data/spec/factories/images/sucess.png +0 -0
  142. data/spec/factories/infinity_test +0 -5
  143. data/spec/factories/infinity_test_example +0 -7
  144. data/spec/factories/slinky/spec/slinky/slinky_spec.rb +0 -0
  145. data/spec/factories/travel/lib/travel.rb +0 -0
  146. data/spec/factories/travel/test/partner_test.rb +0 -0
  147. data/spec/factories/travel/test/travel_test.rb +0 -0
  148. data/spec/factories/wood/lib/wood.rb +0 -0
  149. data/spec/factories/wood/spec/wood_spec.rb +0 -0
  150. data/spec/infinity_test/application_library/rails_spec.rb +0 -140
  151. data/spec/infinity_test/application_library/rubygems_spec.rb +0 -52
  152. data/spec/infinity_test/application_spec.rb +0 -434
  153. data/spec/infinity_test/binary_path_spec.rb +0 -72
  154. data/spec/infinity_test/command_spec.rb +0 -53
  155. data/spec/infinity_test/configuration_spec.rb +0 -382
  156. data/spec/infinity_test/continuous_testing_spec.rb +0 -25
  157. data/spec/infinity_test/environment_spec.rb +0 -23
  158. data/spec/infinity_test/heuristics_helper_spec.rb +0 -15
  159. data/spec/infinity_test/heuristics_spec.rb +0 -127
  160. data/spec/infinity_test/options_spec.rb +0 -111
  161. data/spec/infinity_test/runner_spec.rb +0 -42
  162. data/spec/infinity_test/test_framework_spec.rb +0 -127
  163. data/spec/infinity_test/test_library/bacon_spec.rb +0 -150
  164. data/spec/infinity_test/test_library/cucumber_spec.rb +0 -8
  165. data/spec/infinity_test/test_library/rspec_spec.rb +0 -189
  166. data/spec/infinity_test/test_library/test_unit_spec.rb +0 -184
  167. data/spec/infinity_test_spec.rb +0 -40
  168. /data/images/faces/{sucess.png → success.png} +0 -0
  169. /data/images/hands/{sucess.png → success.png} +0 -0
  170. /data/images/mario_bros/{sucess.jpg → success.jpg} +0 -0
  171. /data/images/rails/{sucess.png → success.png} +0 -0
  172. /data/images/rubies/{sucess.png → success.png} +0 -0
  173. /data/images/simpson/{sucess.jpg → success.jpg} +0 -0
  174. /data/images/street_fighter/{sucess.jpg → success.jpg} +0 -0
  175. /data/images/toy_story/{sucess.png → success.png} +0 -0
@@ -0,0 +1,193 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module TestFramework
5
+ describe TestUnit do
6
+ it_should_behave_like 'a infinity test test framework'
7
+
8
+ describe "#test_dir" do
9
+ it "returns test as test dir" do
10
+ expect(subject.test_dir).to eq 'test'
11
+ end
12
+
13
+ it "can be set to a custom directory" do
14
+ subject.test_dir = 'custom_test'
15
+ expect(subject.test_dir).to eq 'custom_test'
16
+ end
17
+ end
18
+
19
+ describe '#test_files' do
20
+ context 'when is empty' do
21
+ it 'returns the test dir' do
22
+ expect(subject.test_files).to eq 'test'
23
+ end
24
+ end
25
+
26
+ context 'when assign the test files' do
27
+ it 'returns the assigned value' do
28
+ subject.test_files = 'test/models/user_test.rb'
29
+ expect(subject.test_files).to eq 'test/models/user_test.rb'
30
+ end
31
+ end
32
+ end
33
+
34
+ describe "#test_helper_file" do
35
+ it "is the test helper" do
36
+ expect(subject.test_helper_file).to eq 'test/test_helper.rb'
37
+ end
38
+ end
39
+
40
+ describe '#binary' do
41
+ it 'returns ruby as binary' do
42
+ expect(subject.binary).to eq 'ruby'
43
+ end
44
+ end
45
+
46
+ describe '#test_message' do
47
+ subject(:test_unit) { TestUnit.new }
48
+
49
+ it 'returns the final test results' do
50
+ test_unit.test_message = "Finished in 0.001s, 1000.0 runs/s.\n10 runs, 15 assertions, 0 failures, 0 errors, 0 skips\n"
51
+ expect(test_unit.test_message).to eq '10 runs, 15 assertions, 0 failures, 0 errors, 0 skips'
52
+ end
53
+ end
54
+
55
+ describe '#success?' do
56
+ subject(:test_unit) { TestUnit.new }
57
+
58
+ context 'when test message has ZERO failures, ZERO errors, and ZERO skips' do
59
+ before do
60
+ test_unit.test_message = "10 runs, 15 assertions, 0 failures, 0 errors, 0 skips"
61
+ end
62
+
63
+ it 'returns true' do
64
+ expect(test_unit).to be_success
65
+ end
66
+ end
67
+
68
+ context 'when test message has ONE failure' do
69
+ before do
70
+ test_unit.test_message = "10 runs, 15 assertions, 1 failures, 0 errors, 0 skips"
71
+ end
72
+
73
+ it 'returns false' do
74
+ expect(test_unit).to_not be_success
75
+ end
76
+ end
77
+
78
+ context 'when test message has ONE error' do
79
+ before do
80
+ test_unit.test_message = "10 runs, 15 assertions, 0 failures, 1 errors, 0 skips"
81
+ end
82
+
83
+ it 'returns false' do
84
+ expect(test_unit).to_not be_success
85
+ end
86
+ end
87
+
88
+ context 'when test message has ONE skip' do
89
+ before do
90
+ test_unit.test_message = "10 runs, 15 assertions, 0 failures, 0 errors, 1 skips"
91
+ end
92
+
93
+ it 'returns false' do
94
+ expect(test_unit).to_not be_success
95
+ end
96
+ end
97
+ end
98
+
99
+ describe '#failure?' do
100
+ subject(:test_unit) { TestUnit.new }
101
+
102
+ context 'when test message has ONE failure' do
103
+ before do
104
+ test_unit.test_message = "10 runs, 15 assertions, 1 failures, 0 errors, 0 skips"
105
+ end
106
+
107
+ it 'returns true' do
108
+ expect(test_unit).to be_failure
109
+ end
110
+ end
111
+
112
+ context 'when test message has ONE error' do
113
+ before do
114
+ test_unit.test_message = "10 runs, 15 assertions, 0 failures, 1 errors, 0 skips"
115
+ end
116
+
117
+ it 'returns true' do
118
+ expect(test_unit).to be_failure
119
+ end
120
+ end
121
+
122
+ context 'when test message has ZERO failures and ZERO errors' do
123
+ before do
124
+ test_unit.test_message = "10 runs, 15 assertions, 0 failures, 0 errors, 0 skips"
125
+ end
126
+
127
+ it 'returns false' do
128
+ expect(test_unit).to_not be_failure
129
+ end
130
+ end
131
+ end
132
+
133
+ describe '#pending?' do
134
+ subject(:test_unit) { TestUnit.new }
135
+
136
+ context 'when test message has ONE skip' do
137
+ before do
138
+ test_unit.test_message = "10 runs, 15 assertions, 0 failures, 0 errors, 1 skips"
139
+ end
140
+
141
+ it 'returns true' do
142
+ expect(test_unit).to be_pending
143
+ end
144
+ end
145
+
146
+ context 'when test message has ZERO skips' do
147
+ before do
148
+ test_unit.test_message = "10 runs, 15 assertions, 0 failures, 0 errors, 0 skips"
149
+ end
150
+
151
+ it 'returns false' do
152
+ expect(test_unit).to_not be_pending
153
+ end
154
+ end
155
+ end
156
+
157
+ describe '.run?' do
158
+ context 'when test directory exists with test files' do
159
+ before do
160
+ allow(File).to receive(:exist?).with('test').and_return(true)
161
+ allow(File).to receive(:exist?).with('test/test_helper.rb').and_return(true)
162
+ end
163
+
164
+ it 'returns true' do
165
+ expect(TestUnit.run?).to be true
166
+ end
167
+ end
168
+
169
+ context 'when test directory exists with *_test.rb files' do
170
+ before do
171
+ allow(File).to receive(:exist?).with('test').and_return(true)
172
+ allow(File).to receive(:exist?).with('test/test_helper.rb').and_return(false)
173
+ allow(Dir).to receive(:[]).with('test/**/*_test.rb').and_return(['test/user_test.rb'])
174
+ end
175
+
176
+ it 'returns true' do
177
+ expect(TestUnit.run?).to be true
178
+ end
179
+ end
180
+
181
+ context 'when test directory does not exist' do
182
+ before do
183
+ allow(File).to receive(:exist?).with('test').and_return(false)
184
+ end
185
+
186
+ it 'returns false' do
187
+ expect(TestUnit.run?).to be false
188
+ end
189
+ end
190
+ end
191
+ end
192
+ end
193
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,132 +1,47 @@
1
+ if ENV['COVERAGE']
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter 'spec'
5
+ add_filter 'shared_example'
6
+ end
7
+ end
1
8
 
2
9
  require 'infinity_test'
3
- require 'watchr'
4
- # require 'simplecov'
5
- # SimpleCov.start do
6
- # add_filter '/spec'
7
- # add_filter './.infinity_test'
8
- # end
10
+ require 'ostruct'
11
+ require 'bundler/setup'
12
+ Bundler.require
9
13
 
10
14
  RSpec.configure do |config|
15
+ config.include InfinityTest::Strategy::SharedExample
16
+ config.include InfinityTest::Observer::SharedExample
17
+ config.include InfinityTest::TestFramework::SharedExample
18
+ config.include InfinityTest::Framework::SharedExample
11
19
 
12
- def stub_application_with_rspec
13
- InfinityTest.stub!(:application).and_return(application_with_rspec)
14
- end
15
-
16
- def stub_application_with_test_unit
17
- InfinityTest.stub!(:application).and_return(application_with_test_unit)
18
- end
19
-
20
- def application_with(options)
21
- application = InfinityTest::Application.new
22
- application.config.use(options)
23
- application
24
- end
25
-
26
- def application_with_rspec
27
- application_with(:test_framework => :rspec)
28
- end
29
-
30
- def application_with_test_unit
31
- application_with(:test_framework => :test_unit)
32
- end
33
-
34
- def application_with_rails
35
- application_with(:app_framework => :rails)
36
- end
37
-
38
- def application_with_rubygems
39
- application_with(:app_framework => :rubygems)
40
- end
41
-
42
- def application_with_growl
43
- application = InfinityTest::Application.new
44
- application.config.notifications :growl
45
- application
46
- end
47
-
48
- def new_application(options)
49
- application = InfinityTest::Application.new
50
- application.config.notifications options[:notifications] if options[:notifications]
51
- application.config.use(options) if options
52
- application
53
- end
54
-
55
- def continuous_testing_with(application)
56
- InfinityTest::ContinuousTesting.new(:application => application)
57
- end
58
-
59
- def image(basename)
60
- File.expand_path(File.join(File.dirname(__FILE__), '..', 'images', basename))
61
- end
62
-
63
- def custom_image(basename)
64
- File.expand_path(File.join(File.dirname(__FILE__), 'factories', basename))
65
- end
66
-
67
- def custom_image_dir
68
- File.expand_path(File.join(File.dirname(__FILE__), 'factories', 'images'))
69
- end
70
-
71
- def run_the_command(app)
72
- command = mock(InfinityTest::Command)
73
- command.should_receive(:results).at_least(:once).and_return('0 examples, 0 failures')
74
- app.should_receive(:say_the_ruby_version_and_run_the_command!).at_least(:once).and_return(command)
75
- app.should_receive(:notify!).and_return(nil)
76
- app.run!(['spec'])
77
- end
20
+ config.filter_run focus: true
21
+ config.run_all_when_everything_filtered = true
78
22
 
79
- def factory_company_gemfile
80
- File.expand_path(File.join(File.dirname(__FILE__), 'factories', 'company', 'Gemfile'))
81
- end
82
-
83
- def factory_buzz_gemfile
84
- File.expand_path(File.join(File.dirname(__FILE__), 'factories', 'buzz', 'Gemfile'))
85
- end
86
-
87
- def current_env
88
- @current_env ||= RVM::Environment.current
89
- end
90
-
91
- def environment_name
92
- @environment_name ||= current_env.environment_name
93
- end
94
-
95
- def application_with_gemfile(application)
96
- application.should_receive(:have_gemfile?).and_return(true)
97
- application.should_receive(:skip_bundler?).and_return(false)
98
- end
99
-
100
- def application_without_gemfile(application)
101
- application.should_receive(:have_gemfile?).and_return(false)
102
- end
103
-
104
- # Factories! Or Fixtures - Whathever
105
-
106
- def buzz_library(&block)
107
- factories_for('buzz', &block)
108
- end
109
-
110
- def wood_library(&block)
111
- factories_for('wood', &block)
112
- end
113
-
114
- def slinky_library(&block)
115
- factories_for('slinky', &block)
23
+ config.expect_with :rspec do |c|
24
+ c.syntax = :expect
116
25
  end
26
+ end
117
27
 
118
- def factories_for(directory, &block)
119
- Dir.chdir("#{infinity_test_root}/spec/factories/#{directory}", &block)
120
- end
28
+ class BaseFixture
29
+ attr_accessor :strategy, :test_framework, :framework
121
30
 
122
- def infinity_test_root
123
- File.expand_path(File.join(File.dirname(__FILE__), '..'))
31
+ def initialize(options={})
32
+ @strategy = options[:strategy]
33
+ @framework = options[:framework]
34
+ @test_framework = options[:test_framework]
124
35
  end
125
-
126
36
  end
127
37
 
128
- RSpec::Matchers.define :have_pattern do |expected|
129
- match do |heuristics|
130
- heuristics.patterns.should have_key(expected)
131
- end
38
+ # Replacement for deprecated silence_stream from ActiveSupport
39
+ def silence_stream(stream)
40
+ old_stream = stream.dup
41
+ stream.reopen(File::NULL)
42
+ stream.sync = true
43
+ yield
44
+ ensure
45
+ stream.reopen(old_stream)
46
+ old_stream.close
132
47
  end