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,95 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Framework
5
+ describe Django do
6
+ let(:observer) { double('Observer') }
7
+ let(:test_framework) { double('TestFramework', test_dir: 'tests', test_helper_file: 'tests/conftest.py') }
8
+ let(:continuous_test_server) { double('ContinuousTestServer', observer: observer, test_framework: test_framework) }
9
+ subject { Django.new(continuous_test_server) }
10
+
11
+ describe "#heuristics" do
12
+ before do
13
+ allow(subject).to receive(:watch_django_apps)
14
+ allow(File).to receive(:directory?).with('tests').and_return(true)
15
+ allow(File).to receive(:exist?).with('tests/conftest.py').and_return(true)
16
+ end
17
+
18
+ it "adds heuristics for django apps, test, and conftest" do
19
+ expect(subject).to receive(:watch_django_apps)
20
+ expect(observer).to receive(:watch_dir).with('tests', :py)
21
+ expect(observer).to receive(:watch).with('tests/conftest.py')
22
+ expect { subject.heuristics }.to_not raise_exception
23
+ end
24
+ end
25
+
26
+ describe "#heuristics!" do
27
+ it "appends .py extension to hike" do
28
+ hike = double('Hike')
29
+ allow(subject).to receive(:hike).and_return(hike)
30
+ expect(hike).to receive(:append_extension).with('.py')
31
+ expect(hike).to receive(:append_path).with('tests')
32
+ allow(subject).to receive(:heuristics)
33
+ subject.heuristics!
34
+ end
35
+ end
36
+
37
+ describe "#watch_django_apps" do
38
+ context "when Django apps exist" do
39
+ before do
40
+ allow(Dir).to receive(:glob).with('*').and_return(['myapp', 'accounts', 'tests'])
41
+ allow(File).to receive(:directory?).with('myapp').and_return(true)
42
+ allow(File).to receive(:directory?).with('accounts').and_return(true)
43
+ allow(File).to receive(:directory?).with('tests').and_return(true)
44
+ allow(File).to receive(:exist?).with('myapp/models.py').and_return(true)
45
+ allow(File).to receive(:exist?).with('myapp/views.py').and_return(false)
46
+ allow(File).to receive(:exist?).with('myapp/apps.py').and_return(false)
47
+ allow(File).to receive(:exist?).with('accounts/models.py').and_return(false)
48
+ allow(File).to receive(:exist?).with('accounts/views.py').and_return(true)
49
+ allow(File).to receive(:exist?).with('accounts/apps.py').and_return(false)
50
+ end
51
+
52
+ it "watches Django app directories" do
53
+ expect(observer).to receive(:watch_dir).with('myapp', :py)
54
+ expect(observer).to receive(:watch_dir).with('accounts', :py)
55
+ subject.watch_django_apps
56
+ end
57
+ end
58
+ end
59
+
60
+ describe ".run?" do
61
+ context "when manage.py exists with Django" do
62
+ before do
63
+ allow(File).to receive(:exist?).with('manage.py').and_return(true)
64
+ allow(File).to receive(:read).with('manage.py').and_return("os.environ.setdefault('DJANGO_SETTINGS_MODULE'")
65
+ end
66
+
67
+ it "returns true" do
68
+ expect(Django).to be_run
69
+ end
70
+ end
71
+
72
+ context "when manage.py does not exist" do
73
+ before do
74
+ allow(File).to receive(:exist?).with('manage.py').and_return(false)
75
+ end
76
+
77
+ it "returns false" do
78
+ expect(Django).not_to be_run
79
+ end
80
+ end
81
+
82
+ context "when manage.py exists but is not Django" do
83
+ before do
84
+ allow(File).to receive(:exist?).with('manage.py').and_return(true)
85
+ allow(File).to receive(:read).with('manage.py').and_return("print('hello')")
86
+ end
87
+
88
+ it "returns false" do
89
+ expect(Django).not_to be_run
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Framework
5
+ describe ElixirMix do
6
+ let(:observer) { double('Observer') }
7
+ let(:test_framework) { double('TestFramework', test_dir: 'test', test_helper_file: 'test/test_helper.exs') }
8
+ let(:continuous_test_server) { double('ContinuousTestServer', observer: observer, test_framework: test_framework) }
9
+ subject { ElixirMix.new(continuous_test_server) }
10
+
11
+ describe "#heuristics" do
12
+ it "adds heuristics for lib, test, and test_helper" do
13
+ expect(observer).to receive(:watch_dir).with(:lib, :ex)
14
+ expect(observer).to receive(:watch_dir).with('test', :exs)
15
+ expect(observer).to receive(:watch).with('test/test_helper.exs')
16
+ expect { subject.heuristics }.to_not raise_exception
17
+ end
18
+ end
19
+
20
+ describe "#heuristics!" do
21
+ it "appends .exs extension to hike" do
22
+ hike = double('Hike')
23
+ allow(subject).to receive(:hike).and_return(hike)
24
+ expect(hike).to receive(:append_extension).with('.exs')
25
+ expect(hike).to receive(:append_path).with('test')
26
+ allow(subject).to receive(:heuristics)
27
+ subject.heuristics!
28
+ end
29
+ end
30
+
31
+ describe ".run?" do
32
+ it "returns true if there is a mix.exs in the user current dir" do
33
+ expect(File).to receive(:exist?).with('mix.exs').and_return(true)
34
+ expect(ElixirMix).to be_run
35
+ end
36
+
37
+ it "returns false if there is no mix.exs in the user current dir" do
38
+ expect(File).to receive(:exist?).with('mix.exs').and_return(false)
39
+ expect(ElixirMix).not_to be_run
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,96 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Framework
5
+ describe FastApi do
6
+ let(:observer) { double('Observer') }
7
+ let(:test_framework) { double('TestFramework', test_dir: 'tests', test_helper_file: 'tests/conftest.py') }
8
+ let(:continuous_test_server) { double('ContinuousTestServer', observer: observer, test_framework: test_framework) }
9
+ subject { FastApi.new(continuous_test_server) }
10
+
11
+ describe "#heuristics" do
12
+ before do
13
+ allow(subject).to receive(:watch_fastapi_dirs)
14
+ allow(File).to receive(:exist?).with('tests/conftest.py').and_return(true)
15
+ end
16
+
17
+ it "adds heuristics for fastapi dirs, test, and conftest" do
18
+ expect(subject).to receive(:watch_fastapi_dirs)
19
+ expect(observer).to receive(:watch_dir).with('tests', :py)
20
+ expect(observer).to receive(:watch).with('tests/conftest.py')
21
+ expect { subject.heuristics }.to_not raise_exception
22
+ end
23
+ end
24
+
25
+ describe "#heuristics!" do
26
+ it "appends .py extension to hike" do
27
+ hike = double('Hike')
28
+ allow(subject).to receive(:hike).and_return(hike)
29
+ expect(hike).to receive(:append_extension).with('.py')
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 "#watch_fastapi_dirs" do
37
+ context "when app directory exists" do
38
+ before do
39
+ allow(File).to receive(:directory?).with('app').and_return(true)
40
+ allow(File).to receive(:directory?).with('src').and_return(false)
41
+ allow(File).to receive(:directory?).with('routers').and_return(false)
42
+ allow(File).to receive(:directory?).with('api').and_return(false)
43
+ allow(File).to receive(:directory?).with('endpoints').and_return(false)
44
+ allow(File).to receive(:directory?).with('.').and_return(true)
45
+ allow(Dir).to receive(:glob).with('*.py').and_return(['main.py'])
46
+ allow(Dir).to receive(:glob).with('app/**/*.py').and_return(['app/main.py'])
47
+ allow(Dir).to receive(:glob).with('./**/*.py').and_return(['main.py'])
48
+ end
49
+
50
+ it "watches the app directory" do
51
+ expect(observer).to receive(:watch_dir).with('app', :py)
52
+ expect(observer).to receive(:watch_dir).with('.', :py)
53
+ subject.watch_fastapi_dirs
54
+ end
55
+ end
56
+ end
57
+
58
+ describe ".run?" do
59
+ context "when app/main.py exists with FastAPI" do
60
+ before do
61
+ allow(File).to receive(:exist?).with('app/main.py').and_return(true)
62
+ allow(File).to receive(:read).with('app/main.py').and_return('from fastapi import FastAPI')
63
+ end
64
+
65
+ it "returns true" do
66
+ expect(FastApi).to be_run
67
+ end
68
+ end
69
+
70
+ context "when main.py exists with FastAPI" do
71
+ before do
72
+ allow(File).to receive(:exist?).with('app/main.py').and_return(false)
73
+ allow(File).to receive(:exist?).with('main.py').and_return(true)
74
+ allow(File).to receive(:read).with('main.py').and_return('app = FastAPI()')
75
+ end
76
+
77
+ it "returns true" do
78
+ expect(FastApi).to be_run
79
+ end
80
+ end
81
+
82
+ context "when no FastAPI project" do
83
+ before do
84
+ allow(File).to receive(:exist?).with('app/main.py').and_return(false)
85
+ allow(File).to receive(:exist?).with('main.py').and_return(false)
86
+ allow(File).to receive(:exist?).with('src/main.py').and_return(false)
87
+ end
88
+
89
+ it "returns false" do
90
+ expect(FastApi).not_to be_run
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Framework
5
+ describe Padrino do
6
+ let(:observer) { double('Observer') }
7
+ let(:test_framework) { double('TestFramework', test_dir: 'spec') }
8
+ let(:continuous_test_server) { double('ContinuousTestServer', observer: observer, test_framework: test_framework) }
9
+ subject { Padrino.new(continuous_test_server) }
10
+
11
+ describe "#heuristics" do
12
+ it "watches lib, test_dir, and test_helper_file" do
13
+ allow(File).to receive(:directory?).with('app').and_return(false)
14
+
15
+ expect(observer).to receive(:watch_dir).with(:lib)
16
+ expect(observer).to receive(:watch_dir).with('spec')
17
+ expect(observer).to receive(:watch)
18
+ expect(test_framework).to receive(:test_helper_file)
19
+
20
+ expect { subject.heuristics }.to_not raise_exception
21
+ end
22
+
23
+ it "auto-discovers app directories containing ruby files" do
24
+ allow(File).to receive(:directory?).with('app').and_return(true)
25
+ allow(Dir).to receive(:glob).with('app/*').and_return(['app/models', 'app/views', 'app/components'])
26
+ allow(File).to receive(:directory?).with('app/models').and_return(true)
27
+ allow(File).to receive(:directory?).with('app/views').and_return(true)
28
+ allow(File).to receive(:directory?).with('app/components').and_return(true)
29
+ allow(Dir).to receive(:glob).with('app/models/**/*.rb').and_return(['app/models/user.rb'])
30
+ allow(Dir).to receive(:glob).with('app/views/**/*.rb').and_return([])
31
+ allow(Dir).to receive(:glob).with('app/components/**/*.rb').and_return(['app/components/button.rb'])
32
+
33
+ # Should watch models and components (have .rb files), skip views (no .rb files)
34
+ expect(observer).to receive(:watch_dir).with('app/models')
35
+ expect(observer).to receive(:watch_dir).with('app/components')
36
+ expect(observer).to receive(:watch_dir).with(:lib)
37
+ expect(observer).to receive(:watch_dir).with('spec')
38
+ expect(observer).to receive(:watch)
39
+ expect(test_framework).to receive(:test_helper_file)
40
+
41
+ expect { subject.heuristics }.to_not raise_exception
42
+ end
43
+ end
44
+
45
+ describe ".run?" do
46
+ it "returns true if config/apps.rb exists" do
47
+ expect(File).to receive(:exist?).with(File.expand_path('./config/apps.rb')).and_return(true)
48
+ expect(Padrino).to be_run
49
+ end
50
+
51
+ it "returns false if config/apps.rb does not exist" do
52
+ expect(File).to receive(:exist?).with(File.expand_path('./config/apps.rb')).and_return(false)
53
+ expect(Padrino).not_to be_run
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Framework
5
+ describe Phoenix do
6
+ let(:observer) { double('Observer') }
7
+ let(:test_framework) { double('TestFramework', test_dir: 'test', test_helper_file: 'test/test_helper.exs') }
8
+ let(:continuous_test_server) { double('ContinuousTestServer', observer: observer, test_framework: test_framework) }
9
+ subject { Phoenix.new(continuous_test_server) }
10
+
11
+ describe "#heuristics" do
12
+ before do
13
+ allow(subject).to receive(:watch_lib_dirs)
14
+ end
15
+
16
+ it "adds heuristics for lib dirs, test, and test_helper" do
17
+ expect(subject).to receive(:watch_lib_dirs)
18
+ expect(observer).to receive(:watch_dir).with('test', :exs)
19
+ expect(observer).to receive(:watch).with('test/test_helper.exs')
20
+ expect { subject.heuristics }.to_not raise_exception
21
+ end
22
+ end
23
+
24
+ describe "#heuristics!" do
25
+ it "appends .exs extension to hike" do
26
+ hike = double('Hike')
27
+ allow(subject).to receive(:hike).and_return(hike)
28
+ expect(hike).to receive(:append_extension).with('.exs')
29
+ expect(hike).to receive(:append_path).with('test')
30
+ allow(subject).to receive(:heuristics)
31
+ subject.heuristics!
32
+ end
33
+ end
34
+
35
+ describe "#watch_lib_dirs" do
36
+ context "when lib directory exists with subdirectories" do
37
+ before do
38
+ allow(File).to receive(:directory?).with('lib').and_return(true)
39
+ allow(Dir).to receive(:glob).with('lib/*').and_return(['lib/my_app', 'lib/my_app_web'])
40
+ allow(File).to receive(:directory?).with('lib/my_app').and_return(true)
41
+ allow(File).to receive(:directory?).with('lib/my_app_web').and_return(true)
42
+ allow(Dir).to receive(:glob).with('lib/my_app/**/*.ex').and_return(['lib/my_app/accounts.ex'])
43
+ allow(Dir).to receive(:glob).with('lib/my_app_web/**/*.ex').and_return(['lib/my_app_web/controllers/page_controller.ex'])
44
+ end
45
+
46
+ it "watches all lib subdirectories with .ex files" do
47
+ expect(observer).to receive(:watch_dir).with('lib/my_app', :ex)
48
+ expect(observer).to receive(:watch_dir).with('lib/my_app_web', :ex)
49
+ subject.watch_lib_dirs
50
+ end
51
+ end
52
+
53
+ context "when lib directory does not exist" do
54
+ before do
55
+ allow(File).to receive(:directory?).with('lib').and_return(false)
56
+ end
57
+
58
+ it "does nothing" do
59
+ expect(observer).not_to receive(:watch_dir)
60
+ subject.watch_lib_dirs
61
+ end
62
+ end
63
+ end
64
+
65
+ describe ".run?" do
66
+ it "returns true if mix.exs exists and has lib/*_web directory" do
67
+ expect(File).to receive(:exist?).with('mix.exs').and_return(true)
68
+ expect(Dir).to receive(:glob).with('lib/*_web').and_return(['lib/my_app_web'])
69
+ expect(Phoenix).to be_run
70
+ end
71
+
72
+ it "returns false if mix.exs does not exist" do
73
+ expect(File).to receive(:exist?).with('mix.exs').and_return(false)
74
+ expect(Phoenix).not_to be_run
75
+ end
76
+
77
+ it "returns false if no lib/*_web directory exists" do
78
+ expect(File).to receive(:exist?).with('mix.exs').and_return(true)
79
+ expect(Dir).to receive(:glob).with('lib/*_web').and_return([])
80
+ expect(Phoenix).not_to be_run
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,95 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Framework
5
+ describe PythonPackage do
6
+ let(:observer) { double('Observer') }
7
+ let(:test_framework) { double('TestFramework', test_dir: 'tests', test_helper_file: 'tests/conftest.py') }
8
+ let(:continuous_test_server) { double('ContinuousTestServer', observer: observer, test_framework: test_framework) }
9
+ subject { PythonPackage.new(continuous_test_server) }
10
+
11
+ describe "#heuristics" do
12
+ before do
13
+ allow(subject).to receive(:watch_python_dirs)
14
+ allow(File).to receive(:exist?).with('tests/conftest.py').and_return(true)
15
+ end
16
+
17
+ it "adds heuristics for python dirs, test, and conftest" do
18
+ expect(subject).to receive(:watch_python_dirs)
19
+ expect(observer).to receive(:watch_dir).with('tests', :py)
20
+ expect(observer).to receive(:watch).with('tests/conftest.py')
21
+ expect { subject.heuristics }.to_not raise_exception
22
+ end
23
+ end
24
+
25
+ describe "#heuristics!" do
26
+ it "appends .py extension to hike" do
27
+ hike = double('Hike')
28
+ allow(subject).to receive(:hike).and_return(hike)
29
+ expect(hike).to receive(:append_extension).with('.py')
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 "#watch_python_dirs" do
37
+ context "when src directory exists" do
38
+ before do
39
+ allow(File).to receive(:directory?).with('src').and_return(true)
40
+ allow(File).to receive(:directory?).with('lib').and_return(false)
41
+ allow(Dir).to receive(:glob).with('*/__init__.py').and_return([])
42
+ allow(Dir).to receive(:glob).with('src/**/*.py').and_return(['src/mypackage/utils.py'])
43
+ end
44
+
45
+ it "watches the src directory" do
46
+ expect(observer).to receive(:watch_dir).with('src', :py)
47
+ subject.watch_python_dirs
48
+ end
49
+ end
50
+
51
+ context "when package directory with __init__.py exists" do
52
+ before do
53
+ allow(File).to receive(:directory?).with('src').and_return(false)
54
+ allow(File).to receive(:directory?).with('lib').and_return(false)
55
+ allow(Dir).to receive(:glob).with('*/__init__.py').and_return(['mypackage/__init__.py'])
56
+ allow(File).to receive(:directory?).with('mypackage').and_return(true)
57
+ allow(Dir).to receive(:glob).with('mypackage/**/*.py').and_return(['mypackage/utils.py'])
58
+ end
59
+
60
+ it "watches the package directory" do
61
+ expect(observer).to receive(:watch_dir).with('mypackage', :py)
62
+ subject.watch_python_dirs
63
+ end
64
+ end
65
+ end
66
+
67
+ describe ".run?" do
68
+ it "returns true if pyproject.toml exists" do
69
+ expect(File).to receive(:exist?).with('pyproject.toml').and_return(true)
70
+ expect(PythonPackage).to be_run
71
+ end
72
+
73
+ it "returns true if setup.py exists" do
74
+ expect(File).to receive(:exist?).with('pyproject.toml').and_return(false)
75
+ expect(File).to receive(:exist?).with('setup.py').and_return(true)
76
+ expect(PythonPackage).to be_run
77
+ end
78
+
79
+ it "returns true if setup.cfg exists" do
80
+ expect(File).to receive(:exist?).with('pyproject.toml').and_return(false)
81
+ expect(File).to receive(:exist?).with('setup.py').and_return(false)
82
+ expect(File).to receive(:exist?).with('setup.cfg').and_return(true)
83
+ expect(PythonPackage).to be_run
84
+ end
85
+
86
+ it "returns false if no Python package files exist" do
87
+ expect(File).to receive(:exist?).with('pyproject.toml').and_return(false)
88
+ expect(File).to receive(:exist?).with('setup.py').and_return(false)
89
+ expect(File).to receive(:exist?).with('setup.cfg').and_return(false)
90
+ expect(PythonPackage).not_to be_run
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Framework
5
+ describe Rails do
6
+ let(:observer) { double('Observer') }
7
+ let(:test_framework) { double('TestFramework', test_dir: 'spec') }
8
+ let(:continuous_test_server) { double('ContinuousTestServer', observer: observer, test_framework: test_framework) }
9
+ subject { Rails.new(continuous_test_server) }
10
+
11
+ describe "#heuristics" do
12
+ it "watches lib, test_dir, and test_helper_file" do
13
+ allow(File).to receive(:directory?).with('app').and_return(false)
14
+
15
+ expect(observer).to receive(:watch_dir).with(:lib)
16
+ expect(observer).to receive(:watch_dir).with('spec')
17
+ expect(observer).to receive(:watch)
18
+ expect(test_framework).to receive(:test_helper_file)
19
+
20
+ expect { subject.heuristics }.to_not raise_exception
21
+ end
22
+
23
+ it "auto-discovers app directories containing ruby files" do
24
+ allow(File).to receive(:directory?).with('app').and_return(true)
25
+ allow(Dir).to receive(:glob).with('app/*').and_return(['app/models', 'app/views', 'app/components'])
26
+ allow(File).to receive(:directory?).with('app/models').and_return(true)
27
+ allow(File).to receive(:directory?).with('app/views').and_return(true)
28
+ allow(File).to receive(:directory?).with('app/components').and_return(true)
29
+ allow(Dir).to receive(:glob).with('app/models/**/*.rb').and_return(['app/models/user.rb'])
30
+ allow(Dir).to receive(:glob).with('app/views/**/*.rb').and_return([])
31
+ allow(Dir).to receive(:glob).with('app/components/**/*.rb').and_return(['app/components/button.rb'])
32
+
33
+ # Should watch models and components (have .rb files), skip views (no .rb files)
34
+ expect(observer).to receive(:watch_dir).with('app/models')
35
+ expect(observer).to receive(:watch_dir).with('app/components')
36
+ expect(observer).to receive(:watch_dir).with(:lib)
37
+ expect(observer).to receive(:watch_dir).with('spec')
38
+ expect(observer).to receive(:watch)
39
+ expect(test_framework).to receive(:test_helper_file)
40
+
41
+ expect { subject.heuristics }.to_not raise_exception
42
+ end
43
+ end
44
+
45
+ describe ".run?" do
46
+ it "returns true if config/environment.rb exists" do
47
+ expect(File).to receive(:exist?).with(File.expand_path('./config/environment.rb')).and_return(true)
48
+ expect(Rails).to be_run
49
+ end
50
+
51
+ it "returns false if config/environment.rb does not exist" do
52
+ expect(File).to receive(:exist?).with(File.expand_path('./config/environment.rb')).and_return(false)
53
+ expect(Rails).not_to be_run
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Framework
5
+ describe Rocket 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 { Rocket.new(continuous_test_server) }
10
+
11
+ describe "#heuristics" do
12
+ before do
13
+ allow(File).to receive(:directory?).with('tests').and_return(true)
14
+ allow(File).to receive(:exist?).with('Rocket.toml').and_return(true)
15
+ end
16
+
17
+ it "adds heuristics for src, tests, Cargo.toml, and Rocket.toml" do
18
+ expect(observer).to receive(:watch_dir).with(:src, :rs)
19
+ expect(observer).to receive(:watch_dir).with('tests', :rs)
20
+ expect(observer).to receive(:watch).with('Cargo.toml')
21
+ expect(observer).to receive(:watch).with('Rocket.toml')
22
+ expect { subject.heuristics }.to_not raise_exception
23
+ end
24
+ end
25
+
26
+ describe "#heuristics!" do
27
+ it "appends .rs extension to hike" do
28
+ hike = double('Hike')
29
+ allow(subject).to receive(:hike).and_return(hike)
30
+ allow(File).to receive(:directory?).with('tests').and_return(true)
31
+ expect(hike).to receive(:append_extension).with('.rs')
32
+ expect(hike).to receive(:append_path).with('tests')
33
+ allow(subject).to receive(:heuristics)
34
+ subject.heuristics!
35
+ end
36
+ end
37
+
38
+ describe "#run_module_tests" do
39
+ let(:changed_file) { double('ChangedFile', name: 'src/routes.rs', path: 'routes') }
40
+
41
+ it "runs tests matching the module name" do
42
+ expect(continuous_test_server).to receive(:rerun_strategy).with('routes')
43
+ subject.run_module_tests(changed_file)
44
+ end
45
+ end
46
+
47
+ describe ".run?" do
48
+ it "returns true if Cargo.toml exists with rocket dependency" do
49
+ expect(File).to receive(:exist?).with('Cargo.toml').and_return(true)
50
+ expect(File).to receive(:exist?).with('Cargo.toml').and_return(true)
51
+ expect(File).to receive(:read).with('Cargo.toml').and_return('rocket = "0.5"')
52
+ expect(Rocket).to be_run
53
+ end
54
+
55
+ it "returns false if Cargo.toml does not exist" do
56
+ expect(File).to receive(:exist?).with('Cargo.toml').and_return(false)
57
+ expect(Rocket).not_to be_run
58
+ end
59
+
60
+ it "returns false if Cargo.toml does not contain rocket" do
61
+ expect(File).to receive(:exist?).with('Cargo.toml').and_return(true)
62
+ expect(File).to receive(:exist?).with('Cargo.toml').and_return(true)
63
+ expect(File).to receive(:read).with('Cargo.toml').and_return('[dependencies]')
64
+ expect(Rocket).not_to be_run
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Framework
5
+ describe Rubygems do
6
+ let(:observer) { double('Observer') }
7
+ let(:test_framework) { double('TestFramework') }
8
+ let(:continuous_test_server) { double('ContinuousTestServer', observer: observer, test_framework: test_framework) }
9
+ subject { Rubygems.new(continuous_test_server) }
10
+
11
+ describe "#heuristics" do
12
+ it "adds heuristics" do
13
+ expect(observer).to receive(:watch_dir).exactly(2)
14
+ expect(observer).to receive(:watch)
15
+ expect(test_framework).to receive(:test_helper_file)
16
+ expect(test_framework).to receive(:test_dir)
17
+ expect { subject.heuristics }.to_not raise_exception
18
+ end
19
+ end
20
+
21
+ describe ".run?" do
22
+ it "returns true if there is a .gemspec in the user current dir" do
23
+ expect(Dir).to receive(:[]).with('*.gemspec').and_return(['infinity_test.gemspec'])
24
+ expect(Rubygems).to be_run
25
+ end
26
+
27
+ it "returns false if there is no .gemspec in the user current dir" do
28
+ expect(Dir).to receive(:[]).with('*.gemspec').and_return([])
29
+ expect(Rubygems).not_to be_run
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end