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
data/lib/infinity_test.rb CHANGED
@@ -1,51 +1,82 @@
1
- require 'infinity_test/dependencies'
1
+ require 'optparse'
2
+ require 'active_support'
3
+ require 'active_support/core_ext'
4
+ require 'active_support/deprecation'
5
+ require 'hike'
6
+ require 'notifiers'
2
7
 
3
8
  module InfinityTest
4
-
5
- autoload :Application, 'infinity_test/application'
6
- autoload :BinaryPath, 'infinity_test/binary_path'
7
- autoload :Builder, 'infinity_test/builder'
8
- autoload :Command, 'infinity_test/command'
9
- autoload :Configuration, 'infinity_test/configuration'
10
- autoload :ContinuousTesting, 'infinity_test/continuous_testing'
11
- autoload :Environment, 'infinity_test/environment'
12
- autoload :Heuristics, 'infinity_test/heuristics'
13
- autoload :HeuristicsHelper, 'infinity_test/heuristics_helper'
14
- autoload :Options, 'infinity_test/options'
15
- autoload :Runner, 'infinity_test/runner'
16
- autoload :TestFramework, 'infinity_test/test_framework'
17
-
18
- module ApplicationLibrary
19
- autoload :Rails , 'infinity_test/application_library/rails'
20
- autoload :RubyGems, 'infinity_test/application_library/rubygems'
9
+ module Core
10
+ autoload :AutoDiscover, 'infinity_test/core/auto_discover'
11
+ autoload :Base, 'infinity_test/core/base'
12
+ autoload :Callback, 'infinity_test/core/callback'
13
+ autoload :CommandBuilder, 'infinity_test/core/command_builder'
14
+ autoload :CommandRunner, 'infinity_test/core/command_runner'
15
+ autoload :ConfigurationMerge, 'infinity_test/core/configuration_merge'
16
+ autoload :ContinuousTestServer, 'infinity_test/core/continuous_test_server'
17
+ autoload :ChangedFile, 'infinity_test/core/changed_file'
18
+ autoload :LoadConfiguration, 'infinity_test/core/load_configuration'
19
+ autoload :Notifier, 'infinity_test/core/notifier'
20
+ autoload :Options, 'infinity_test/core/options'
21
+ autoload :Runner, 'infinity_test/core/runner'
21
22
  end
22
23
 
23
- module TestLibrary
24
- autoload :Bacon, 'infinity_test/test_library/bacon'
25
- autoload :Cucumber, 'infinity_test/test_library/cucumber'
26
- autoload :Rspec, 'infinity_test/test_library/rspec'
27
- autoload :TestUnit, 'infinity_test/test_library/test_unit'
24
+ # This will be removed in the InfinityTest oficial 2.0.1.
25
+ #
26
+ module OldDSL
27
+ autoload :Configuration, 'infinity_test/old_dsl/configuration'
28
28
  end
29
29
 
30
- def self.application
31
- @application ||= Application.new
30
+ module Framework
31
+ autoload :Base, 'infinity_test/framework/base'
32
+ autoload :Helpers, 'infinity_test/framework/helpers'
33
+ autoload :SharedExample, 'infinity_test/framework/shared_example'
32
34
  end
33
35
 
34
- def self.configuration
35
- @configuration ||= Configuration.new
36
+ module Observer
37
+ autoload :Base, 'infinity_test/observer/base'
38
+ autoload :Listen, 'infinity_test/observer/listen'
39
+ autoload :Filewatcher, 'infinity_test/observer/filewatcher'
40
+ autoload :SharedExample, 'infinity_test/observer/shared_example'
36
41
  end
37
42
 
38
- def self.watchr
39
- @watchr ||= Watchr::Script.new
43
+ module Strategy
44
+ autoload :Base, 'infinity_test/strategy/base'
45
+ autoload :SharedExample, 'infinity_test/strategy/shared_example'
40
46
  end
41
47
 
42
- def self.start!
43
- Runner.new(ARGV).run!
48
+ module TestFramework
49
+ autoload :Base, 'infinity_test/test_framework/base'
50
+ autoload :SharedExample, 'infinity_test/test_framework/shared_example'
44
51
  end
45
-
46
- def self.version
47
- version = YAML.load_file(File.dirname(__FILE__) + '/../VERSION.yml')
48
- [version[:major], version[:minor], version[:patch]].compact.join(".")
52
+
53
+ # See Core::Base.setup to more information.
54
+ #
55
+ def self.setup(&block)
56
+ InfinityTest::Base.setup(&block)
49
57
  end
50
58
 
59
+ include Core
51
60
  end
61
+
62
+ require 'infinity_test/strategy/rbenv'
63
+ require 'infinity_test/strategy/rvm'
64
+ require 'infinity_test/strategy/ruby_default'
65
+ require 'infinity_test/strategy/elixir_default'
66
+ require 'infinity_test/strategy/python_default'
67
+ require 'infinity_test/strategy/rust_default'
68
+ require 'infinity_test/framework/padrino'
69
+ require 'infinity_test/framework/rails'
70
+ require 'infinity_test/framework/rubygems'
71
+ require 'infinity_test/framework/elixir_mix'
72
+ require 'infinity_test/framework/phoenix'
73
+ require 'infinity_test/framework/python_package'
74
+ require 'infinity_test/framework/fast_api'
75
+ require 'infinity_test/framework/django'
76
+ require 'infinity_test/framework/rust_cargo'
77
+ require 'infinity_test/framework/rocket'
78
+ require 'infinity_test/test_framework/test_unit'
79
+ require 'infinity_test/test_framework/rspec'
80
+ require 'infinity_test/test_framework/ex_unit'
81
+ require 'infinity_test/test_framework/pytest'
82
+ require 'infinity_test/test_framework/cargo_test'
@@ -0,0 +1,175 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ module InfinityTest
5
+ describe AutoDiscover do
6
+ let(:base) { BaseFixture.new }
7
+ let(:auto_discover) { AutoDiscover.new(base) }
8
+
9
+ describe '#discover_libraries' do
10
+ it 'discovers strategy, framework and test framework' do
11
+ expect(auto_discover).to receive(:discover_strategy)
12
+ expect(auto_discover).to receive(:discover_framework)
13
+ expect(auto_discover).to receive(:discover_test_framework)
14
+ auto_discover.discover_libraries
15
+ end
16
+ end
17
+
18
+ describe '#discover_strategy' do
19
+ context 'when strategy is auto discover' do
20
+ before do
21
+ base.strategy = :auto_discover
22
+ allow(Strategy::RubyDefault).to receive(:run?).and_return(false)
23
+ allow(Strategy::ElixirDefault).to receive(:run?).and_return(false)
24
+ allow(Strategy::PythonDefault).to receive(:run?).and_return(false)
25
+ allow(Strategy::RustDefault).to receive(:run?).and_return(false)
26
+ expect(Strategy::Rvm).to receive(:run?).and_return(true)
27
+ end
28
+
29
+ it 'changes the base strategy' do
30
+ auto_discover.discover_strategy
31
+ expect(base.strategy).to be :rvm
32
+ end
33
+ end
34
+
35
+ context 'when strategy is different from auto discover' do
36
+ before { base.strategy = :ruby_default }
37
+
38
+ it 'does not change anything' do
39
+ auto_discover.discover_strategy
40
+ expect(base.strategy).to be :ruby_default
41
+ end
42
+ end
43
+
44
+ context 'when do not find any strategy' do
45
+ before do
46
+ base.strategy = :auto_discover
47
+ allow(Strategy::RubyDefault).to receive(:run?).and_return(false)
48
+ expect(Strategy::Rvm).to receive(:run?).and_return(false)
49
+ allow(Strategy::Rbenv).to receive(:run?).and_return(false)
50
+ allow(Strategy::ElixirDefault).to receive(:run?).and_return(false)
51
+ allow(Strategy::PythonDefault).to receive(:run?).and_return(false)
52
+ allow(Strategy::RustDefault).to receive(:run?).and_return(false)
53
+ end
54
+
55
+ it 'raises exception' do
56
+ expect { auto_discover.discover_strategy }.to raise_error(Exception)
57
+ end
58
+ end
59
+ end
60
+
61
+ describe '#discover_framework' do
62
+ context 'when framework is auto discover' do
63
+ before do
64
+ base.framework = :auto_discover
65
+ allow(Framework::Rubygems).to receive(:run?).and_return(false)
66
+ allow(Framework::ElixirMix).to receive(:run?).and_return(false)
67
+ allow(Framework::Phoenix).to receive(:run?).and_return(false)
68
+ allow(Framework::Django).to receive(:run?).and_return(false)
69
+ allow(Framework::FastApi).to receive(:run?).and_return(false)
70
+ allow(Framework::PythonPackage).to receive(:run?).and_return(false)
71
+ allow(Framework::Rocket).to receive(:run?).and_return(false)
72
+ allow(Framework::RustCargo).to receive(:run?).and_return(false)
73
+ expect(Framework::Rails).to receive(:run?).and_return(true)
74
+ end
75
+
76
+ it 'changes the base framework' do
77
+ auto_discover.discover_framework
78
+ expect(base.framework).to be :rails
79
+ end
80
+ end
81
+
82
+ context 'when framework is different from auto discover' do
83
+ before { base.framework = :padrino }
84
+
85
+ it 'does not change anything' do
86
+ auto_discover.discover_framework
87
+ expect(base.framework).to be :padrino
88
+ end
89
+ end
90
+ end
91
+
92
+ describe '#discover_test_framework' do
93
+ context 'when framework is auto discover' do
94
+ before do
95
+ base.test_framework = :auto_discover
96
+ allow(TestFramework::TestUnit).to receive(:run?).and_return(false)
97
+ allow(TestFramework::ExUnit).to receive(:run?).and_return(false)
98
+ allow(TestFramework::Pytest).to receive(:run?).and_return(false)
99
+ allow(TestFramework::CargoTest).to receive(:run?).and_return(false)
100
+ expect(TestFramework::Rspec).to receive(:run?).and_return(true)
101
+ end
102
+
103
+ it 'changes the base framework' do
104
+ auto_discover.discover_test_framework
105
+ expect(base.test_framework).to be :rspec
106
+ end
107
+ end
108
+
109
+ context 'when framework is different from auto discover' do
110
+ before { base.test_framework = :test_unit }
111
+
112
+ it 'does not change anything' do
113
+ auto_discover.discover_test_framework
114
+ expect(base.test_framework).to be :test_unit
115
+ end
116
+ end
117
+ end
118
+
119
+ describe 'PRIORITY' do
120
+ it 'defines priority order for strategies' do
121
+ expect(AutoDiscover::PRIORITY[:strategy]).to eq [:rvm, :rbenv, :elixir_default, :python_default, :rust_default, :ruby_default]
122
+ end
123
+
124
+ it 'defines priority order for frameworks' do
125
+ expect(AutoDiscover::PRIORITY[:framework]).to eq [:rails, :padrino, :phoenix, :elixir_mix, :django, :fast_api, :python_package, :rocket, :rust_cargo, :rubygems]
126
+ end
127
+
128
+ it 'defines priority order for test frameworks' do
129
+ expect(AutoDiscover::PRIORITY[:test_framework]).to eq [:rspec, :test_unit, :ex_unit, :pytest, :cargo_test]
130
+ end
131
+ end
132
+
133
+ describe 'priority ordering' do
134
+ context 'when multiple strategies match' do
135
+ before do
136
+ base.strategy = :auto_discover
137
+ # Both RVM and RubyDefault would match, but RVM has higher priority
138
+ allow(Strategy::Rvm).to receive(:run?).and_return(true)
139
+ allow(Strategy::Rbenv).to receive(:run?).and_return(false)
140
+ allow(Strategy::ElixirDefault).to receive(:run?).and_return(false)
141
+ allow(Strategy::PythonDefault).to receive(:run?).and_return(false)
142
+ allow(Strategy::RustDefault).to receive(:run?).and_return(false)
143
+ allow(Strategy::RubyDefault).to receive(:run?).and_return(true)
144
+ end
145
+
146
+ it 'selects the higher priority strategy (RVM over RubyDefault)' do
147
+ auto_discover.discover_strategy
148
+ expect(base.strategy).to be :rvm
149
+ end
150
+ end
151
+
152
+ context 'when multiple frameworks match' do
153
+ before do
154
+ base.framework = :auto_discover
155
+ # Both Rails and Rubygems would match, but Rails has higher priority
156
+ allow(Framework::Rails).to receive(:run?).and_return(true)
157
+ allow(Framework::Padrino).to receive(:run?).and_return(false)
158
+ allow(Framework::Phoenix).to receive(:run?).and_return(false)
159
+ allow(Framework::ElixirMix).to receive(:run?).and_return(false)
160
+ allow(Framework::Django).to receive(:run?).and_return(false)
161
+ allow(Framework::FastApi).to receive(:run?).and_return(false)
162
+ allow(Framework::PythonPackage).to receive(:run?).and_return(false)
163
+ allow(Framework::Rocket).to receive(:run?).and_return(false)
164
+ allow(Framework::RustCargo).to receive(:run?).and_return(false)
165
+ allow(Framework::Rubygems).to receive(:run?).and_return(true)
166
+ end
167
+
168
+ it 'selects the higher priority framework (Rails over Rubygems)' do
169
+ auto_discover.discover_framework
170
+ expect(base.framework).to be :rails
171
+ end
172
+ end
173
+ end
174
+ end
175
+ end
@@ -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