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,94 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Framework
5
+ describe RustCargo do
6
+ let(:observer) { double('Observer') }
7
+ let(:test_framework) { double('TestFramework', test_dir: 'tests', test_helper_file: 'Cargo.toml') }
8
+ let(:continuous_test_server) { double('ContinuousTestServer', observer: observer, test_framework: test_framework) }
9
+ subject { RustCargo.new(continuous_test_server) }
10
+
11
+ describe "#heuristics" do
12
+ before do
13
+ allow(File).to receive(:directory?).with('tests').and_return(true)
14
+ end
15
+
16
+ it "adds heuristics for src, tests, and Cargo.toml" do
17
+ expect(observer).to receive(:watch_dir).with(:src, :rs)
18
+ expect(observer).to receive(:watch_dir).with('tests', :rs)
19
+ expect(observer).to receive(:watch).with('Cargo.toml')
20
+ expect { subject.heuristics }.to_not raise_exception
21
+ end
22
+ end
23
+
24
+ describe "#heuristics!" do
25
+ it "appends .rs extension to hike" do
26
+ hike = double('Hike')
27
+ allow(subject).to receive(:hike).and_return(hike)
28
+ allow(File).to receive(:directory?).with('tests').and_return(true)
29
+ expect(hike).to receive(:append_extension).with('.rs')
30
+ expect(hike).to receive(:append_path).with('tests')
31
+ allow(subject).to receive(:heuristics)
32
+ subject.heuristics!
33
+ end
34
+ end
35
+
36
+ describe "#run_module_tests" do
37
+ let(:changed_file) { double('ChangedFile', name: 'src/user.rs', path: 'user') }
38
+
39
+ it "runs tests matching the module name" do
40
+ expect(continuous_test_server).to receive(:rerun_strategy).with('user')
41
+ subject.run_module_tests(changed_file)
42
+ end
43
+
44
+ context "when lib.rs is changed" do
45
+ let(:lib_file) { double('ChangedFile', name: 'src/lib.rs', path: 'lib') }
46
+
47
+ it "runs all tests" do
48
+ expect(subject).to receive(:run_all)
49
+ subject.run_module_tests(lib_file)
50
+ end
51
+ end
52
+
53
+ context "when main.rs is changed" do
54
+ let(:main_file) { double('ChangedFile', name: 'src/main.rs', path: 'main') }
55
+
56
+ it "runs all tests" do
57
+ expect(subject).to receive(:run_all)
58
+ subject.run_module_tests(main_file)
59
+ end
60
+ end
61
+ end
62
+
63
+ describe "#run_integration_test" do
64
+ let(:changed_file) { double('ChangedFile', name: 'tests/integration_test.rs') }
65
+
66
+ it "runs the specific integration test" do
67
+ expect(continuous_test_server).to receive(:rerun_strategy).with('--test integration_test')
68
+ subject.run_integration_test(changed_file)
69
+ end
70
+ end
71
+
72
+ describe ".run?" do
73
+ it "returns true if Cargo.toml exists and is not a Rocket project" do
74
+ expect(File).to receive(:exist?).with('Cargo.toml').and_return(true)
75
+ expect(File).to receive(:exist?).with('Cargo.toml').and_return(true)
76
+ expect(File).to receive(:read).with('Cargo.toml').and_return('[dependencies]')
77
+ expect(RustCargo).to be_run
78
+ end
79
+
80
+ it "returns false if Cargo.toml does not exist" do
81
+ expect(File).to receive(:exist?).with('Cargo.toml').and_return(false)
82
+ expect(RustCargo).not_to be_run
83
+ end
84
+
85
+ it "returns false if it is a Rocket project" do
86
+ expect(File).to receive(:exist?).with('Cargo.toml').and_return(true)
87
+ expect(File).to receive(:exist?).with('Cargo.toml').and_return(true)
88
+ expect(File).to receive(:read).with('Cargo.toml').and_return('rocket = "0.5"')
89
+ expect(RustCargo).not_to be_run
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Observer
5
+ describe Base do
6
+ let(:continuous_server) { double }
7
+ subject { Base.new(continuous_server) }
8
+
9
+ describe "#initialize" do
10
+ it "sets the continuous_test_server" do
11
+ expect(subject.continuous_test_server).to eq(continuous_server)
12
+ end
13
+ end
14
+
15
+ describe "#watch" do
16
+ it "raises NotImplementedError" do
17
+ expect { subject.watch('pattern') {} }.to raise_error(NotImplementedError)
18
+ end
19
+ end
20
+
21
+ describe "#watch_dir" do
22
+ it "raises NotImplementedError" do
23
+ expect { subject.watch_dir(:lib, :rb) {} }.to raise_error(NotImplementedError)
24
+ end
25
+ end
26
+
27
+ describe "#start" do
28
+ it "raises NotImplementedError" do
29
+ expect { subject.start }.to raise_error(NotImplementedError)
30
+ end
31
+ end
32
+
33
+ describe "#start!" do
34
+ it "calls signal and start" do
35
+ expect(subject).to receive(:signal)
36
+ expect(subject).to receive(:start)
37
+ subject.start!
38
+ end
39
+ end
40
+
41
+ describe "#signal" do
42
+ it "traps INT signal" do
43
+ expect(Signal).to receive(:trap).with('INT')
44
+ subject.signal
45
+ end
46
+
47
+ context "interrupt handling logic" do
48
+ let(:handler) do
49
+ handler_block = nil
50
+ allow(Signal).to receive(:trap) { |_, &block| handler_block = block }
51
+ subject.signal
52
+ handler_block
53
+ end
54
+
55
+ it "shows warning on first interrupt" do
56
+ expect(subject).to receive(:puts).with(" Are you sure? :S ... Interrupt a second time to quit!")
57
+ handler.call
58
+ expect(subject.instance_variable_get(:@interrupt_at)).to be_within(1).of(Time.now)
59
+ end
60
+
61
+ it "exits on second interrupt within 2 seconds" do
62
+ subject.instance_variable_set(:@interrupt_at, Time.now)
63
+ expect(subject).to receive(:puts).with(" To Infinity and Beyond!")
64
+ expect(subject).to receive(:exit)
65
+ handler.call
66
+ end
67
+
68
+ it "resets timer if second interrupt is after 2 seconds" do
69
+ subject.instance_variable_set(:@interrupt_at, Time.now - 3)
70
+ expect(subject).to receive(:puts).with(" Are you sure? :S ... Interrupt a second time to quit!")
71
+ handler.call
72
+ expect(subject.instance_variable_get(:@interrupt_at)).to be_within(1).of(Time.now)
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Observer
5
+ describe Filewatcher do
6
+ let(:continuous_server) { double }
7
+ subject { Filewatcher.new(continuous_server) }
8
+
9
+ it_should_behave_like 'an infinity test observer'
10
+
11
+ describe "#patterns" do
12
+ it "starts as an empty hash" do
13
+ expect(subject.patterns).to eq({})
14
+ end
15
+ end
16
+
17
+ describe "#watch_paths" do
18
+ it "starts as an empty array" do
19
+ expect(subject.watch_paths).to eq([])
20
+ end
21
+ end
22
+
23
+ describe "#watch" do
24
+ it "adds a pattern with its block to patterns" do
25
+ block = proc { |file| file }
26
+ subject.watch('lib/(.*)\.rb', &block)
27
+ expect(subject.patterns.keys.first).to be_a(Regexp)
28
+ expect(subject.patterns.values.first).to eq(block)
29
+ end
30
+ end
31
+
32
+ describe "#watch_dir" do
33
+ it "adds a glob pattern to watch_paths" do
34
+ subject.watch_dir(:spec)
35
+ expect(subject.watch_paths).to include('spec/**/*.rb')
36
+ end
37
+
38
+ it "adds a pattern to patterns" do
39
+ subject.watch_dir(:spec)
40
+ expect(subject.patterns.keys.first.source).to eq('^spec/*/(.*).rb')
41
+ end
42
+
43
+ it "accepts a custom extension" do
44
+ subject.watch_dir(:spec, :py)
45
+ expect(subject.watch_paths).to include('spec/**/*.py')
46
+ expect(subject.patterns.keys.first.source).to eq('^spec/*/(.*).py')
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Observer
5
+ describe Listen do
6
+ let(:continuous_server) { double }
7
+ subject { Listen.new(continuous_server) }
8
+
9
+ it_should_behave_like 'an infinity test observer'
10
+
11
+ describe "#patterns" do
12
+ it "starts as an empty hash" do
13
+ expect(subject.patterns).to eq({})
14
+ end
15
+ end
16
+
17
+ describe "#directories" do
18
+ it "starts as an empty array" do
19
+ expect(subject.directories).to eq([])
20
+ end
21
+ end
22
+
23
+ describe "#watch" do
24
+ it "adds a pattern with its block to patterns" do
25
+ block = proc { |file| file }
26
+ subject.watch('lib/(.*)\.rb', &block)
27
+ expect(subject.patterns.keys.first).to be_a(Regexp)
28
+ expect(subject.patterns.values.first).to eq(block)
29
+ end
30
+ end
31
+
32
+ describe "#watch_dir" do
33
+ it "adds a pattern to patterns" do
34
+ subject.watch_dir(:spec)
35
+ expect(subject.patterns.keys.first.source).to eq('^spec/*/(.*).rb')
36
+ end
37
+
38
+ it "adds the directory to directories" do
39
+ subject.watch_dir(:spec)
40
+ expect(subject.directories).to include('spec')
41
+ end
42
+
43
+ it "accepts a custom extension" do
44
+ subject.watch_dir(:spec, :py)
45
+ expect(subject.patterns.keys.first.source).to eq('^spec/*/(.*).py')
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module InfinityTest
4
- describe Builder do
5
-
4
+ describe Base do
6
5
  end
7
6
  end
@@ -0,0 +1,46 @@
1
+ require "spec_helper"
2
+
3
+ module InfinityTest
4
+ module Strategy
5
+ describe ElixirDefault do
6
+ let(:base) { BaseFixture.new }
7
+ let(:continuous_test_server) { Core::ContinuousTestServer.new(base) }
8
+ subject { ElixirDefault.new(continuous_test_server) }
9
+ it_should_behave_like 'a infinity test strategy'
10
+
11
+ describe ".run?" do
12
+ it "returns true when mix.exs exists" do
13
+ allow(File).to receive(:exist?).with('mix.exs').and_return(true)
14
+ expect(ElixirDefault).to be_run
15
+ end
16
+
17
+ it "returns false when mix.exs does not exist" do
18
+ allow(File).to receive(:exist?).with('mix.exs').and_return(false)
19
+ expect(ElixirDefault).not_to be_run
20
+ end
21
+ end
22
+
23
+ describe '#run!' do
24
+ before { base.test_framework = :ex_unit }
25
+
26
+ it 'returns the mix test command' do
27
+ expect(subject.run!).to eq 'mix test test'
28
+ end
29
+
30
+ context 'with specific options' do
31
+ before do
32
+ Core::Base.specific_options = '--trace'
33
+ end
34
+
35
+ after do
36
+ Core::Base.specific_options = ''
37
+ end
38
+
39
+ it 'includes the options' do
40
+ expect(subject.run!).to eq 'mix test test --trace'
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,56 @@
1
+ require "spec_helper"
2
+
3
+ module InfinityTest
4
+ module Strategy
5
+ describe PythonDefault do
6
+ let(:base) { BaseFixture.new }
7
+ let(:continuous_test_server) { Core::ContinuousTestServer.new(base) }
8
+ subject { PythonDefault.new(continuous_test_server) }
9
+ it_should_behave_like 'a infinity test strategy'
10
+
11
+ describe ".run?" do
12
+ it "returns true when pyproject.toml exists" do
13
+ allow(File).to receive(:exist?).with('pyproject.toml').and_return(true)
14
+ expect(PythonDefault).to be_run
15
+ end
16
+
17
+ it "returns true when setup.py exists" do
18
+ allow(File).to receive(:exist?).with('pyproject.toml').and_return(false)
19
+ allow(File).to receive(:exist?).with('setup.py').and_return(true)
20
+ expect(PythonDefault).to be_run
21
+ end
22
+
23
+ it "returns false when no Python package files exist" do
24
+ allow(File).to receive(:exist?).with('pyproject.toml').and_return(false)
25
+ allow(File).to receive(:exist?).with('setup.py').and_return(false)
26
+ allow(File).to receive(:exist?).with('setup.cfg').and_return(false)
27
+ expect(PythonDefault).not_to be_run
28
+ end
29
+ end
30
+
31
+ describe '#run!' do
32
+ before { base.test_framework = :pytest }
33
+
34
+ it 'returns the pytest command' do
35
+ allow(File).to receive(:exist?).with('tests').and_return(true)
36
+ expect(subject.run!).to eq 'pytest tests'
37
+ end
38
+
39
+ context 'with specific options' do
40
+ before do
41
+ Core::Base.specific_options = '-v --tb=short'
42
+ end
43
+
44
+ after do
45
+ Core::Base.specific_options = ''
46
+ end
47
+
48
+ it 'includes the options' do
49
+ allow(File).to receive(:exist?).with('tests').and_return(true)
50
+ expect(subject.run!).to eq 'pytest tests -v --tb=short'
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,70 @@
1
+ require "spec_helper"
2
+
3
+ module InfinityTest
4
+ module Strategy
5
+ describe Rbenv do
6
+ let(:base) { BaseFixture.new(test_framework: :rspec) }
7
+ let(:continuous_test_server) { Core::ContinuousTestServer.new(base) }
8
+ subject { Rbenv.new(continuous_test_server) }
9
+
10
+ it_should_behave_like 'a infinity test strategy'
11
+
12
+ describe ".run?" do
13
+ let(:rbenv_dir) { File.expand_path('~/.rbenv') }
14
+
15
+ context "when rubies are specified" do
16
+ before do
17
+ allow(Core::Base).to receive(:rubies).and_return(['2.7.0', '3.0.0'])
18
+ end
19
+
20
+ it "returns true if the user has rbenv installed" do
21
+ expect(File).to receive(:exist?).with(rbenv_dir).and_return(true)
22
+ expect(Rbenv).to be_run
23
+ end
24
+
25
+ it "returns false if the user does not have rbenv installed" do
26
+ expect(File).to receive(:exist?).with(rbenv_dir).and_return(false)
27
+ expect(Rbenv).not_to be_run
28
+ end
29
+ end
30
+
31
+ context "when no rubies are specified" do
32
+ before do
33
+ allow(Core::Base).to receive(:rubies).and_return([])
34
+ end
35
+
36
+ it "returns false even if rbenv is installed" do
37
+ expect(Rbenv).not_to be_run
38
+ end
39
+ end
40
+ end
41
+
42
+ describe '#run!' do
43
+ before do
44
+ allow(Core::Base).to receive(:rubies).and_return(['2.7.0', '3.0.0'])
45
+ end
46
+
47
+ context 'with bundler' do
48
+ before do
49
+ allow(Core::Base).to receive(:using_bundler?).and_return(true)
50
+ allow(File).to receive(:exist?).with('Gemfile').and_return(true)
51
+ end
52
+
53
+ it 'returns the command for multiple ruby versions with bundle exec' do
54
+ expect(subject.run!).to eq 'RBENV_VERSION=2.7.0 bundle exec rspec spec && RBENV_VERSION=3.0.0 bundle exec rspec spec'
55
+ end
56
+ end
57
+
58
+ context 'without bundler' do
59
+ before do
60
+ allow(Core::Base).to receive(:using_bundler?).and_return(false)
61
+ end
62
+
63
+ it 'returns the command for multiple ruby versions without bundle exec' do
64
+ expect(subject.run!).to eq 'RBENV_VERSION=2.7.0 rspec spec && RBENV_VERSION=3.0.0 rspec spec'
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,49 @@
1
+ require "spec_helper"
2
+
3
+ module InfinityTest
4
+ module Strategy
5
+ describe RubyDefault do
6
+ let(:base) { BaseFixture.new }
7
+ let(:continuous_test_server) { Core::ContinuousTestServer.new(base) }
8
+ subject { RubyDefault.new(continuous_test_server) }
9
+ it_should_behave_like 'a infinity test strategy'
10
+
11
+ describe ".run?" do
12
+ it "returns true when no ruby versions are passed to run tests" do
13
+ allow(Core::Base).to receive(:rubies).and_return([])
14
+ expect(RubyDefault).to be_run
15
+ end
16
+
17
+ it "returns false when some ruby version is passed to run tests" do
18
+ allow(Core::Base).to receive(:rubies).and_return(['ree', 'jruby'])
19
+ expect(RubyDefault).not_to be_run
20
+ end
21
+ end
22
+
23
+ describe '#run!' do
24
+ before { base.test_framework = :rspec }
25
+
26
+ context 'with bundler' do
27
+ before do
28
+ allow(Core::Base).to receive(:using_bundler?).and_return(true)
29
+ allow(File).to receive(:exist?).with('Gemfile').and_return(true)
30
+ end
31
+
32
+ it 'returns the command with bundle exec' do
33
+ expect(subject.run!).to eq 'bundle exec rspec spec'
34
+ end
35
+ end
36
+
37
+ context 'without bundler' do
38
+ before do
39
+ allow(Core::Base).to receive(:using_bundler?).and_return(false)
40
+ end
41
+
42
+ it 'returns the command without bundle exec' do
43
+ expect(subject.run!).to eq 'rspec spec'
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,56 @@
1
+ require "spec_helper"
2
+
3
+ module InfinityTest
4
+ module Strategy
5
+ describe RustDefault do
6
+ let(:base) { BaseFixture.new }
7
+ let(:continuous_test_server) { Core::ContinuousTestServer.new(base) }
8
+ subject { RustDefault.new(continuous_test_server) }
9
+ it_should_behave_like 'a infinity test strategy'
10
+
11
+ describe ".run?" do
12
+ it "returns true when Cargo.toml exists" do
13
+ allow(File).to receive(:exist?).with('Cargo.toml').and_return(true)
14
+ expect(RustDefault).to be_run
15
+ end
16
+
17
+ it "returns false when Cargo.toml does not exist" do
18
+ allow(File).to receive(:exist?).with('Cargo.toml').and_return(false)
19
+ expect(RustDefault).not_to be_run
20
+ end
21
+ end
22
+
23
+ describe '#run!' do
24
+ before { base.test_framework = :cargo_test }
25
+
26
+ it 'returns the cargo test command' do
27
+ expect(subject.run!).to eq 'cargo test'
28
+ end
29
+
30
+ context 'with test files specified' do
31
+ before do
32
+ allow(continuous_test_server).to receive(:test_files).and_return('user')
33
+ end
34
+
35
+ it 'includes the test name' do
36
+ expect(subject.run!).to eq 'cargo test user'
37
+ end
38
+ end
39
+
40
+ context 'with specific options' do
41
+ before do
42
+ Core::Base.specific_options = '-- --nocapture'
43
+ end
44
+
45
+ after do
46
+ Core::Base.specific_options = ''
47
+ end
48
+
49
+ it 'includes the options' do
50
+ expect(subject.run!).to eq 'cargo test -- --nocapture'
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,86 @@
1
+ require "spec_helper"
2
+
3
+ module InfinityTest
4
+ module Strategy
5
+ describe Rvm do
6
+ let(:base) { BaseFixture.new(test_framework: :rspec) }
7
+ let(:continuous_test_server) { Core::ContinuousTestServer.new(base) }
8
+ subject { Rvm.new(continuous_test_server) }
9
+
10
+ it_should_behave_like 'a infinity test strategy'
11
+
12
+ describe ".run?" do
13
+ context "when rubies are specified" do
14
+ before do
15
+ allow(Core::Base).to receive(:rubies).and_return(['2.7.0', '3.0.0'])
16
+ end
17
+
18
+ it "returns true if the user has RVM installed in users home" do
19
+ expect(Rvm).to receive(:installed_users_home?).and_return(true)
20
+ expect(Rvm).to be_run
21
+ end
22
+
23
+ it "returns true if the user has RVM installed system wide" do
24
+ expect(Rvm).to receive(:installed_users_home?).and_return(false)
25
+ expect(Rvm).to receive(:installed_system_wide?).and_return(true)
26
+ expect(Rvm).to be_run
27
+ end
28
+
29
+ it "returns false if the user does not have RVM installed" do
30
+ expect(Rvm).to receive(:installed_users_home?).and_return(false)
31
+ expect(Rvm).to receive(:installed_system_wide?).and_return(false)
32
+ expect(Rvm).not_to be_run
33
+ end
34
+ end
35
+
36
+ context "when no rubies are specified" do
37
+ before do
38
+ allow(Core::Base).to receive(:rubies).and_return([])
39
+ end
40
+
41
+ it "returns false even if RVM is installed" do
42
+ expect(Rvm).not_to be_run
43
+ end
44
+ end
45
+ end
46
+
47
+ describe '#run!' do
48
+ before do
49
+ allow(Core::Base).to receive(:rubies).and_return(['2.7.0', '3.0.0'])
50
+ allow(Core::Base).to receive(:gemset).and_return(nil)
51
+ end
52
+
53
+ context 'with bundler' do
54
+ before do
55
+ allow(Core::Base).to receive(:using_bundler?).and_return(true)
56
+ allow(File).to receive(:exist?).with('Gemfile').and_return(true)
57
+ end
58
+
59
+ it 'returns the command for multiple ruby versions with bundle exec' do
60
+ expect(subject.run!).to eq 'rvm 2.7.0 do bundle exec rspec spec && rvm 3.0.0 do bundle exec rspec spec'
61
+ end
62
+
63
+ context 'with gemset' do
64
+ before do
65
+ allow(Core::Base).to receive(:gemset).and_return('infinity_test')
66
+ end
67
+
68
+ it 'includes gemset in the command' do
69
+ expect(subject.run!).to eq 'rvm 2.7.0@infinity_test do bundle exec rspec spec && rvm 3.0.0@infinity_test do bundle exec rspec spec'
70
+ end
71
+ end
72
+ end
73
+
74
+ context 'without bundler' do
75
+ before do
76
+ allow(Core::Base).to receive(:using_bundler?).and_return(false)
77
+ end
78
+
79
+ it 'returns the command for multiple ruby versions without bundle exec' do
80
+ expect(subject.run!).to eq 'rvm 2.7.0 do rspec spec && rvm 3.0.0 do rspec spec'
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end