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,145 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module TestFramework
5
+ describe CargoTest do
6
+ it_should_behave_like 'a infinity test test framework'
7
+
8
+ describe "#test_dir" do
9
+ it "returns tests as test dir" do
10
+ expect(subject.test_dir).to eq 'tests'
11
+ end
12
+ end
13
+
14
+ describe '#test_files' do
15
+ context 'when is empty' do
16
+ it 'returns empty string' do
17
+ expect(subject.test_files).to eq ''
18
+ end
19
+ end
20
+
21
+ context 'when assign the test files' do
22
+ it 'returns the assigned value' do
23
+ subject.test_files = 'user'
24
+ expect(subject.test_files).to eq 'user'
25
+ end
26
+ end
27
+ end
28
+
29
+ describe "#test_helper_file" do
30
+ it "is Cargo.toml" do
31
+ expect(subject.test_helper_file).to eq 'Cargo.toml'
32
+ end
33
+ end
34
+
35
+ describe "#binary" do
36
+ it "returns cargo as binary" do
37
+ expect(subject.binary).to eq 'cargo'
38
+ end
39
+ end
40
+
41
+ describe '#test_message' do
42
+ subject(:cargo_test) { CargoTest.new }
43
+
44
+ it 'returns the final test results' do
45
+ cargo_test.test_message = "test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out"
46
+ expect(cargo_test.test_message).to eq 'test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out'
47
+ end
48
+ end
49
+
50
+ describe '#success?' do
51
+ subject(:cargo_test) { CargoTest.new }
52
+
53
+ context 'when all tests pass' do
54
+ before do
55
+ cargo_test.test_message = "test result: ok. 5 passed; 0 failed; 0 ignored"
56
+ end
57
+
58
+ it 'returns true' do
59
+ expect(cargo_test).to be_success
60
+ end
61
+ end
62
+
63
+ context 'when there are failures' do
64
+ before do
65
+ cargo_test.test_message = "test result: FAILED. 3 passed; 2 failed; 0 ignored"
66
+ end
67
+
68
+ it 'returns false' do
69
+ expect(cargo_test).to_not be_success
70
+ end
71
+ end
72
+
73
+ context 'when there are ignored tests' do
74
+ before do
75
+ cargo_test.test_message = "test result: ok. 4 passed; 0 failed; 1 ignored"
76
+ end
77
+
78
+ it 'returns false' do
79
+ expect(cargo_test).to_not be_success
80
+ end
81
+ end
82
+ end
83
+
84
+ describe '#failure?' do
85
+ subject(:cargo_test) { CargoTest.new }
86
+
87
+ context 'when there are failures' do
88
+ before do
89
+ cargo_test.test_message = "test result: FAILED. 3 passed; 2 failed; 0 ignored"
90
+ end
91
+
92
+ it 'returns true' do
93
+ expect(cargo_test).to be_failure
94
+ end
95
+ end
96
+
97
+ context 'when all tests pass' do
98
+ before do
99
+ cargo_test.test_message = "test result: ok. 5 passed; 0 failed; 0 ignored"
100
+ end
101
+
102
+ it 'returns false' do
103
+ expect(cargo_test).to_not be_failure
104
+ end
105
+ end
106
+ end
107
+
108
+ describe '#pending?' do
109
+ subject(:cargo_test) { CargoTest.new }
110
+
111
+ context 'when there are ignored tests' do
112
+ before do
113
+ cargo_test.test_message = "test result: ok. 4 passed; 0 failed; 1 ignored"
114
+ end
115
+
116
+ it 'returns true' do
117
+ expect(cargo_test).to be_pending
118
+ end
119
+ end
120
+
121
+ context 'when no tests are ignored' do
122
+ before do
123
+ cargo_test.test_message = "test result: ok. 5 passed; 0 failed; 0 ignored"
124
+ end
125
+
126
+ it 'returns false' do
127
+ expect(cargo_test).to_not be_pending
128
+ end
129
+ end
130
+ end
131
+
132
+ describe '.run?' do
133
+ it 'returns true if Cargo.toml exists' do
134
+ allow(File).to receive(:exist?).with('Cargo.toml').and_return(true)
135
+ expect(CargoTest).to be_run
136
+ end
137
+
138
+ it 'returns false if Cargo.toml does not exist' do
139
+ allow(File).to receive(:exist?).with('Cargo.toml').and_return(false)
140
+ expect(CargoTest).not_to be_run
141
+ end
142
+ end
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,153 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module TestFramework
5
+ describe ExUnit do
6
+ it_should_behave_like 'a infinity test test framework'
7
+
8
+ describe "#test_dir" do
9
+ it "returns test as test dir" do
10
+ expect(subject.test_dir).to eq 'test'
11
+ end
12
+ end
13
+
14
+ describe '#test_files' do
15
+ context 'when is empty' do
16
+ it 'returns the test dir' do
17
+ expect(subject.test_files).to eq 'test'
18
+ end
19
+ end
20
+
21
+ context 'when assign the test files' do
22
+ it 'returns the assigned value' do
23
+ subject.test_files = 'test/my_app/user_test.exs'
24
+ expect(subject.test_files).to eq 'test/my_app/user_test.exs'
25
+ end
26
+ end
27
+ end
28
+
29
+ describe "#test_helper_file" do
30
+ it "is the test helper" do
31
+ expect(subject.test_helper_file).to eq 'test/test_helper.exs'
32
+ end
33
+ end
34
+
35
+ describe "#binary" do
36
+ it "returns mix as binary" do
37
+ expect(subject.binary).to eq 'mix'
38
+ end
39
+ end
40
+
41
+ describe '#test_message' do
42
+ subject(:ex_unit) { ExUnit.new }
43
+
44
+ it 'returns the final test results' do
45
+ ex_unit.test_message = "Finished in 0.1 seconds (0.1s async, 0.0s sync)\n3 tests, 0 failures"
46
+ expect(ex_unit.test_message).to eq '3 tests, 0 failures'
47
+ end
48
+ end
49
+
50
+ describe '#success?' do
51
+ subject(:ex_unit) { ExUnit.new }
52
+
53
+ context 'when is test message with ZERO failures and ZERO skipped' do
54
+ before do
55
+ ex_unit.test_message = "3 tests, 0 failures"
56
+ end
57
+
58
+ it 'returns true' do
59
+ expect(ex_unit).to be_success
60
+ end
61
+ end
62
+
63
+ context 'when is test message with ONE failure and ZERO skipped' do
64
+ before do
65
+ ex_unit.test_message = "3 tests, 1 failure"
66
+ end
67
+
68
+ it 'returns false' do
69
+ expect(ex_unit).to_not be_success
70
+ end
71
+ end
72
+
73
+ context 'when is test message with ZERO failures and ONE skipped' do
74
+ before do
75
+ ex_unit.test_message = "3 tests, 0 failures, 1 skipped"
76
+ end
77
+
78
+ it 'returns false' do
79
+ expect(ex_unit).to_not be_success
80
+ end
81
+ end
82
+ end
83
+
84
+ describe '#failure?' do
85
+ subject(:ex_unit) { ExUnit.new }
86
+
87
+ context 'when is test message with ONE failure' do
88
+ before do
89
+ ex_unit.test_message = "3 tests, 1 failure"
90
+ end
91
+
92
+ it 'returns true' do
93
+ expect(ex_unit).to be_failure
94
+ end
95
+ end
96
+
97
+ context 'when is test message with ZERO failures' do
98
+ before do
99
+ ex_unit.test_message = "3 tests, 0 failures"
100
+ end
101
+
102
+ it 'returns false' do
103
+ expect(ex_unit).to_not be_failure
104
+ end
105
+ end
106
+ end
107
+
108
+ describe '#pending?' do
109
+ subject(:ex_unit) { ExUnit.new }
110
+
111
+ context 'when is test message with skipped tests' do
112
+ before do
113
+ ex_unit.test_message = "3 tests, 0 failures, 1 skipped"
114
+ end
115
+
116
+ it 'returns true' do
117
+ expect(ex_unit).to be_pending
118
+ end
119
+ end
120
+
121
+ context 'when is test message without skipped tests' do
122
+ before do
123
+ ex_unit.test_message = "3 tests, 0 failures"
124
+ end
125
+
126
+ it 'returns false' do
127
+ expect(ex_unit).to_not be_pending
128
+ end
129
+ end
130
+ end
131
+
132
+ describe '.run?' do
133
+ it 'returns true if test dir exists and has exs test files' do
134
+ allow(File).to receive(:exist?).with('test').and_return(true)
135
+ allow(File).to receive(:exist?).with('test/test_helper.exs').and_return(false)
136
+ allow(Dir).to receive(:[]).with('test/**/*_test.exs').and_return(['test/my_app_test.exs'])
137
+ expect(ExUnit).to be_run
138
+ end
139
+
140
+ it 'returns true if test_helper.exs exists' do
141
+ allow(File).to receive(:exist?).with('test').and_return(true)
142
+ allow(File).to receive(:exist?).with('test/test_helper.exs').and_return(true)
143
+ expect(ExUnit).to be_run
144
+ end
145
+
146
+ it 'returns false if no test dir' do
147
+ allow(File).to receive(:exist?).with('test').and_return(false)
148
+ expect(ExUnit).not_to be_run
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,182 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module TestFramework
5
+ describe Pytest do
6
+ it_should_behave_like 'a infinity test test framework'
7
+
8
+ describe "#test_dir" do
9
+ context "when tests directory exists" do
10
+ before do
11
+ allow(File).to receive(:exist?).with('tests').and_return(true)
12
+ end
13
+
14
+ it "returns tests as test dir" do
15
+ expect(subject.test_dir).to eq 'tests'
16
+ end
17
+ end
18
+
19
+ context "when test directory exists" do
20
+ before do
21
+ allow(File).to receive(:exist?).with('tests').and_return(false)
22
+ allow(File).to receive(:exist?).with('test').and_return(true)
23
+ end
24
+
25
+ it "returns test as test dir" do
26
+ expect(subject.test_dir).to eq 'test'
27
+ end
28
+ end
29
+ end
30
+
31
+ describe '#test_files' do
32
+ context 'when is empty' do
33
+ before do
34
+ allow(File).to receive(:exist?).with('tests').and_return(true)
35
+ end
36
+
37
+ it 'returns the test dir' do
38
+ expect(subject.test_files).to eq 'tests'
39
+ end
40
+ end
41
+
42
+ context 'when assign the test files' do
43
+ it 'returns the assigned value' do
44
+ subject.test_files = 'tests/test_utils.py'
45
+ expect(subject.test_files).to eq 'tests/test_utils.py'
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "#test_helper_file" do
51
+ before do
52
+ allow(File).to receive(:exist?).with('tests').and_return(true)
53
+ end
54
+
55
+ it "is conftest.py" do
56
+ expect(subject.test_helper_file).to eq 'tests/conftest.py'
57
+ end
58
+ end
59
+
60
+ describe "#binary" do
61
+ it "returns pytest as binary" do
62
+ expect(subject.binary).to eq 'pytest'
63
+ end
64
+ end
65
+
66
+ describe '#test_message' do
67
+ subject(:pytest) { Pytest.new }
68
+
69
+ it 'returns the final test results' do
70
+ pytest.test_message = "========================= 5 passed in 0.12s ========================="
71
+ expect(pytest.test_message).to eq '========================= 5 passed in 0.12s ========================='
72
+ end
73
+ end
74
+
75
+ describe '#success?' do
76
+ subject(:pytest) { Pytest.new }
77
+
78
+ context 'when all tests pass' do
79
+ before do
80
+ pytest.test_message = "5 passed in 0.12s"
81
+ end
82
+
83
+ it 'returns true' do
84
+ expect(pytest).to be_success
85
+ end
86
+ end
87
+
88
+ context 'when there are failures' do
89
+ before do
90
+ pytest.test_message = "1 failed, 4 passed in 0.15s"
91
+ end
92
+
93
+ it 'returns false' do
94
+ expect(pytest).to_not be_success
95
+ end
96
+ end
97
+
98
+ context 'when there are skipped tests' do
99
+ before do
100
+ pytest.test_message = "4 passed, 1 skipped in 0.15s"
101
+ end
102
+
103
+ it 'returns false' do
104
+ expect(pytest).to_not be_success
105
+ end
106
+ end
107
+ end
108
+
109
+ describe '#failure?' do
110
+ subject(:pytest) { Pytest.new }
111
+
112
+ context 'when there are failures' do
113
+ before do
114
+ pytest.test_message = "1 failed, 4 passed in 0.15s"
115
+ end
116
+
117
+ it 'returns true' do
118
+ expect(pytest).to be_failure
119
+ end
120
+ end
121
+
122
+ context 'when all tests pass' do
123
+ before do
124
+ pytest.test_message = "5 passed in 0.12s"
125
+ end
126
+
127
+ it 'returns false' do
128
+ expect(pytest).to_not be_failure
129
+ end
130
+ end
131
+ end
132
+
133
+ describe '#pending?' do
134
+ subject(:pytest) { Pytest.new }
135
+
136
+ context 'when there are skipped tests' do
137
+ before do
138
+ pytest.test_message = "4 passed, 1 skipped in 0.15s"
139
+ end
140
+
141
+ it 'returns true' do
142
+ expect(pytest).to be_pending
143
+ end
144
+ end
145
+
146
+ context 'when no tests are skipped' do
147
+ before do
148
+ pytest.test_message = "5 passed in 0.12s"
149
+ end
150
+
151
+ it 'returns false' do
152
+ expect(pytest).to_not be_pending
153
+ end
154
+ end
155
+ end
156
+
157
+ describe '.run?' do
158
+ it 'returns true if tests dir exists with test files' do
159
+ allow(File).to receive(:exist?).with('tests').and_return(true)
160
+ allow(File).to receive(:exist?).with('test').and_return(false)
161
+ allow(File).to receive(:exist?).with('tests/conftest.py').and_return(false)
162
+ allow(File).to receive(:exist?).with('test/conftest.py').and_return(false)
163
+ allow(Dir).to receive(:[]).with('tests/**/test_*.py').and_return(['tests/test_utils.py'])
164
+ expect(Pytest).to be_run
165
+ end
166
+
167
+ it 'returns true if conftest.py exists' do
168
+ allow(File).to receive(:exist?).with('tests').and_return(true)
169
+ allow(File).to receive(:exist?).with('test').and_return(false)
170
+ allow(File).to receive(:exist?).with('tests/conftest.py').and_return(true)
171
+ expect(Pytest).to be_run
172
+ end
173
+
174
+ it 'returns false if no test directory' do
175
+ allow(File).to receive(:exist?).with('tests').and_return(false)
176
+ allow(File).to receive(:exist?).with('test').and_return(false)
177
+ expect(Pytest).not_to be_run
178
+ end
179
+ end
180
+ end
181
+ end
182
+ end
@@ -0,0 +1,119 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module TestFramework
5
+ describe Rspec do
6
+ it_should_behave_like 'a infinity test test framework'
7
+
8
+ describe "#test_dir" do
9
+ it "returns spec as test dir" do
10
+ expect(subject.test_dir).to eq 'spec'
11
+ end
12
+ end
13
+
14
+ describe '#test_files' do
15
+ context 'when is empty' do
16
+ it 'returns the test dir' do
17
+ expect(subject.test_files).to eq 'spec'
18
+ end
19
+ end
20
+
21
+ context 'when assign the test files' do
22
+ it 'returns the assigned value' do
23
+ subject.test_files = 'framework/base_spec.rb'
24
+ expect(subject.test_files).to eq 'framework/base_spec.rb'
25
+ end
26
+ end
27
+ end
28
+
29
+ describe "#test_helper_file" do
30
+ it "is the spec helper" do
31
+ expect(subject.test_helper_file).to eq 'spec/spec_helper.rb'
32
+ end
33
+ end
34
+
35
+ describe "#binary" do
36
+ it "returns rspec as binary" do
37
+ expect(subject.binary).to eq 'rspec'
38
+ end
39
+ end
40
+
41
+ describe '#test_message' do
42
+ subject(:rspec) { Rspec.new }
43
+
44
+ it 'returns the final specs results' do
45
+ rspec.test_message = "Finished in 2.19 seconds\n\e[33m162 examples, 0 failures, 8 pending\e[0m\n"
46
+ expect(rspec.test_message).to eq '162 examples, 0 failures, 8 pending'
47
+ end
48
+ end
49
+
50
+ describe '#success?' do
51
+ subject(:rspec) { Rspec.new }
52
+
53
+ context 'when is test message with ZERO failures and ZERO pending' do
54
+ before do
55
+ rspec.test_message = "162 examples, 0 failures, 0 pending"
56
+ end
57
+
58
+ it 'returns true' do
59
+ expect(rspec).to be_success
60
+ end
61
+ end
62
+
63
+ context 'when is test message with ONE failure and ZERO pending' do
64
+ before do
65
+ rspec.test_message = "162 examples, 1 failures, 0 pending"
66
+ end
67
+
68
+ it 'returns false' do
69
+ expect(rspec).to_not be_success
70
+ end
71
+ end
72
+
73
+ context 'when is test message with ZERO failures and ONE pending' do
74
+ before do
75
+ rspec.test_message = "162 examples, 0 failures, 1 pending"
76
+ end
77
+
78
+ it 'returns false' do
79
+ expect(rspec).to_not be_success
80
+ end
81
+ end
82
+ end
83
+
84
+ describe '#failure?' do
85
+ subject(:rspec) { Rspec.new }
86
+
87
+ context 'when is test message with ONE failure and ZERO pending' do
88
+ before do
89
+ rspec.test_message = "162 examples, 1 failures, 0 pending"
90
+ end
91
+
92
+ it 'returns true' do
93
+ expect(rspec).to be_failure
94
+ end
95
+ end
96
+
97
+ context 'when is test message with ZERO failures and ZERO pending' do
98
+ before do
99
+ rspec.test_message = "162 examples, 0 failures, 0 pending"
100
+ end
101
+
102
+ it 'returns false' do
103
+ expect(rspec).to_not be_failure
104
+ end
105
+ end
106
+
107
+ context 'when is test message with ZERO failures and ONE pending' do
108
+ before do
109
+ rspec.test_message = "162 examples, 0 failures, 1 pending"
110
+ end
111
+
112
+ it 'returns false' do
113
+ expect(rspec).to_not be_failure
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end