infinity_test 1.0.2 → 2.0.0.rc1

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 (149) 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.markdown +82 -0
  8. data/INFINITY_TEST +48 -0
  9. data/LICENSE.txt +2 -2
  10. data/README.md +627 -0
  11. data/Rakefile +1 -65
  12. data/TODO.markdown +26 -9
  13. data/bin/infinity_test +1 -4
  14. data/images/fuuu/pending.png +0 -0
  15. data/images/fuuu/success.png +0 -0
  16. data/infinity_test.gemspec +41 -191
  17. data/lib/infinity_test/core/auto_discover.rb +67 -0
  18. data/lib/infinity_test/core/base.rb +369 -0
  19. data/lib/infinity_test/core/callback.rb +59 -0
  20. data/lib/infinity_test/core/changed_file.rb +13 -0
  21. data/lib/infinity_test/core/command_builder.rb +48 -0
  22. data/lib/infinity_test/core/command_runner.rb +62 -0
  23. data/lib/infinity_test/core/configuration_merge.rb +37 -0
  24. data/lib/infinity_test/core/continuous_test_server.rb +106 -0
  25. data/lib/infinity_test/core/load_configuration.rb +48 -0
  26. data/lib/infinity_test/core/notifier.rb +59 -0
  27. data/lib/infinity_test/core/options.rb +134 -0
  28. data/lib/infinity_test/core/runner.rb +18 -0
  29. data/lib/infinity_test/core/version.rb +5 -0
  30. data/lib/infinity_test/framework/base.rb +57 -0
  31. data/lib/infinity_test/framework/padrino.rb +33 -0
  32. data/lib/infinity_test/framework/rails.rb +35 -0
  33. data/lib/infinity_test/framework/rubygems.rb +29 -0
  34. data/lib/infinity_test/framework/shared_example.rb +47 -0
  35. data/lib/infinity_test/observer/base.rb +40 -0
  36. data/lib/infinity_test/observer/filewatcher.rb +72 -0
  37. data/lib/infinity_test/observer/listen.rb +74 -0
  38. data/lib/infinity_test/observer/shared_example.rb +35 -0
  39. data/lib/infinity_test/old_dsl/configuration.rb +26 -0
  40. data/lib/infinity_test/strategy/base.rb +34 -0
  41. data/lib/infinity_test/strategy/rbenv.rb +32 -0
  42. data/lib/infinity_test/strategy/ruby_default.rb +20 -0
  43. data/lib/infinity_test/strategy/rvm.rb +50 -0
  44. data/lib/infinity_test/strategy/shared_example.rb +32 -0
  45. data/lib/infinity_test/test_framework/base.rb +64 -0
  46. data/lib/infinity_test/test_framework/rspec.rb +48 -0
  47. data/lib/infinity_test/test_framework/shared_example.rb +56 -0
  48. data/lib/infinity_test/test_framework/test_unit.rb +57 -0
  49. data/lib/infinity_test.rb +53 -35
  50. data/spec/infinity_test/core/auto_discover_spec.rb +149 -0
  51. data/spec/infinity_test/core/base_spec.rb +240 -0
  52. data/spec/infinity_test/core/callback_spec.rb +89 -0
  53. data/spec/infinity_test/core/changed_file_spec.rb +26 -0
  54. data/spec/infinity_test/core/command_builder_spec.rb +38 -0
  55. data/spec/infinity_test/core/configuration_merge_spec.rb +124 -0
  56. data/spec/infinity_test/core/continuous_test_server_spec.rb +116 -0
  57. data/spec/infinity_test/core/load_configuration_spec.rb +43 -0
  58. data/spec/infinity_test/core/notifier_spec.rb +151 -0
  59. data/spec/infinity_test/core/options_spec.rb +168 -0
  60. data/spec/infinity_test/core/runner_spec.rb +17 -0
  61. data/spec/infinity_test/framework/base_spec.rb +55 -0
  62. data/spec/infinity_test/framework/padrino_spec.rb +36 -0
  63. data/spec/infinity_test/framework/rails_spec.rb +36 -0
  64. data/spec/infinity_test/framework/rubygems_spec.rb +34 -0
  65. data/spec/infinity_test/observer/base_spec.rb +78 -0
  66. data/spec/infinity_test/observer/filewatcher_spec.rb +51 -0
  67. data/spec/infinity_test/observer/listen_spec.rb +50 -0
  68. data/spec/infinity_test/{builder_spec.rb → strategy/base_spec.rb} +1 -2
  69. data/spec/infinity_test/strategy/rbenv_spec.rb +53 -0
  70. data/spec/infinity_test/strategy/ruby_default_spec.rb +32 -0
  71. data/spec/infinity_test/strategy/rvm_spec.rb +69 -0
  72. data/spec/infinity_test/test_framework/rspec_spec.rb +119 -0
  73. data/spec/infinity_test/test_framework/test_unit_spec.rb +193 -0
  74. data/spec/spec_helper.rb +34 -119
  75. metadata +276 -205
  76. data/.infinity_test +0 -36
  77. data/.rvmrc +0 -1
  78. data/Gemfile.lock +0 -62
  79. data/Readme.markdown +0 -122
  80. data/Tasks +0 -4
  81. data/VERSION.yml +0 -5
  82. data/buzz_images/buzz_lightyear.jpg +0 -0
  83. data/buzz_images/buzz_lightyear_continencia.gif +0 -0
  84. data/buzz_images/to_infinity_and_beyond.png +0 -0
  85. data/features/heuristics.feature +0 -23
  86. data/features/support/env.rb +0 -2
  87. data/images/fuuu/sucess.png +0 -0
  88. data/lib/infinity_test/application.rb +0 -355
  89. data/lib/infinity_test/application_library/rails.rb +0 -94
  90. data/lib/infinity_test/application_library/rubygems.rb +0 -43
  91. data/lib/infinity_test/binary_path.rb +0 -43
  92. data/lib/infinity_test/builder.rb +0 -67
  93. data/lib/infinity_test/command.rb +0 -58
  94. data/lib/infinity_test/configuration.rb +0 -273
  95. data/lib/infinity_test/continuous_testing.rb +0 -40
  96. data/lib/infinity_test/dependencies.rb +0 -80
  97. data/lib/infinity_test/environment.rb +0 -15
  98. data/lib/infinity_test/heuristics.rb +0 -36
  99. data/lib/infinity_test/heuristics_helper.rb +0 -9
  100. data/lib/infinity_test/options.rb +0 -89
  101. data/lib/infinity_test/runner.rb +0 -38
  102. data/lib/infinity_test/test_framework.rb +0 -109
  103. data/lib/infinity_test/test_library/bacon.rb +0 -55
  104. data/lib/infinity_test/test_library/cucumber.rb +0 -22
  105. data/lib/infinity_test/test_library/rspec.rb +0 -58
  106. data/lib/infinity_test/test_library/test_unit.rb +0 -52
  107. data/lib/infinity_test/test_unit_loader.rb +0 -5
  108. data/spec/factories/buzz/lib/buzz.rb +0 -0
  109. data/spec/factories/buzz/spec/buzz_spec.rb +0 -0
  110. data/spec/factories/company/Gemfile +0 -0
  111. data/spec/factories/company/lib/company.rb +0 -0
  112. data/spec/factories/company/test/company_test.rb +0 -0
  113. data/spec/factories/images/failure.png +0 -0
  114. data/spec/factories/images/pending.png +0 -0
  115. data/spec/factories/images/sucess.png +0 -0
  116. data/spec/factories/infinity_test +0 -5
  117. data/spec/factories/infinity_test_example +0 -7
  118. data/spec/factories/slinky/spec/slinky/slinky_spec.rb +0 -0
  119. data/spec/factories/travel/lib/travel.rb +0 -0
  120. data/spec/factories/travel/test/partner_test.rb +0 -0
  121. data/spec/factories/travel/test/travel_test.rb +0 -0
  122. data/spec/factories/wood/lib/wood.rb +0 -0
  123. data/spec/factories/wood/spec/wood_spec.rb +0 -0
  124. data/spec/infinity_test/application_library/rails_spec.rb +0 -140
  125. data/spec/infinity_test/application_library/rubygems_spec.rb +0 -52
  126. data/spec/infinity_test/application_spec.rb +0 -424
  127. data/spec/infinity_test/binary_path_spec.rb +0 -72
  128. data/spec/infinity_test/command_spec.rb +0 -53
  129. data/spec/infinity_test/configuration_spec.rb +0 -377
  130. data/spec/infinity_test/continuous_testing_spec.rb +0 -25
  131. data/spec/infinity_test/environment_spec.rb +0 -23
  132. data/spec/infinity_test/heuristics_helper_spec.rb +0 -15
  133. data/spec/infinity_test/heuristics_spec.rb +0 -127
  134. data/spec/infinity_test/options_spec.rb +0 -91
  135. data/spec/infinity_test/runner_spec.rb +0 -42
  136. data/spec/infinity_test/test_framework_spec.rb +0 -127
  137. data/spec/infinity_test/test_library/bacon_spec.rb +0 -150
  138. data/spec/infinity_test/test_library/cucumber_spec.rb +0 -8
  139. data/spec/infinity_test/test_library/rspec_spec.rb +0 -185
  140. data/spec/infinity_test/test_library/test_unit_spec.rb +0 -184
  141. data/spec/infinity_test_spec.rb +0 -40
  142. /data/images/faces/{sucess.png → success.png} +0 -0
  143. /data/images/hands/{sucess.png → success.png} +0 -0
  144. /data/images/mario_bros/{sucess.jpg → success.jpg} +0 -0
  145. /data/images/rails/{sucess.png → success.png} +0 -0
  146. /data/images/rubies/{sucess.png → success.png} +0 -0
  147. /data/images/simpson/{sucess.jpg → success.jpg} +0 -0
  148. /data/images/street_fighter/{sucess.jpg → success.jpg} +0 -0
  149. /data/images/toy_story/{sucess.png → success.png} +0 -0
@@ -0,0 +1,151 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Core
5
+ describe Notifier do
6
+ let(:test_framework) { double }
7
+
8
+ subject(:notifier) { Notifier.new(test_framework: test_framework, library: :auto_discover) }
9
+
10
+ describe '#image' do
11
+ before do
12
+ expect(Core::Base).to receive(:mode).and_return(:simpson)
13
+ end
14
+
15
+ context 'when success tests' do
16
+ before do
17
+ expect(test_framework).to receive(:success?).and_return(true)
18
+ end
19
+
20
+ it 'returns the success image' do
21
+ expect(notifier.image).to include 'success'
22
+ end
23
+ end
24
+
25
+ context 'when pending tests' do
26
+ before do
27
+ expect(test_framework).to receive(:success?).and_return(false)
28
+ expect(test_framework).to receive(:failure?).and_return(false)
29
+ end
30
+
31
+ it 'returns the pending image' do
32
+ expect(notifier.image).to include 'pending'
33
+ end
34
+ end
35
+
36
+ context 'when failing tests' do
37
+ before do
38
+ expect(test_framework).to receive(:success?).and_return(false)
39
+ expect(test_framework).to receive(:failure?).and_return(true)
40
+ end
41
+
42
+ it 'returns the failure image' do
43
+ expect(notifier.image).to include 'failure'
44
+ end
45
+ end
46
+ end
47
+
48
+ describe '#library' do
49
+ it 'returns the primitive value' do
50
+ expect(notifier.library).to be :auto_discover
51
+ end
52
+ end
53
+
54
+ describe '#test_message' do
55
+ it 'respond to' do
56
+ expect(notifier).to respond_to(:test_message)
57
+ end
58
+ end
59
+
60
+ describe '#images_dir' do
61
+ context 'when is default infinity test dir' do
62
+ before do
63
+ expect(Core::Base).to receive(:mode).and_return(:simpson)
64
+ end
65
+
66
+ it 'returns the dir with the base mode' do
67
+ expect(notifier.images_dir).to include '/images/simpson'
68
+ end
69
+ end
70
+
71
+ context 'when is pre defined images dir' do
72
+ before do
73
+ expect(Core::Base).to receive(:mode).and_return('/my_images_dir')
74
+ end
75
+
76
+ it 'returns the user dir expanded path' do
77
+ expect(notifier.images_dir).to eq '/my_images_dir'
78
+ end
79
+ end
80
+ end
81
+
82
+ describe '#success_image' do
83
+ context 'when core base image is blank' do
84
+ it 'find a image inside mode dir' do
85
+ expect(notifier).to receive(:find_image).with(:success)
86
+ notifier.success_image
87
+ end
88
+ end
89
+
90
+ context 'when core base has a image' do
91
+ it 'returns core base image' do
92
+ expect(Core::Base).to receive(:success_image).and_return('some_image.png')
93
+ expect(notifier.success_image).to eq 'some_image.png'
94
+ end
95
+ end
96
+ end
97
+
98
+ describe '#failure_image' do
99
+ context 'when core base image is blank' do
100
+ it 'find a image inside mode dir' do
101
+ expect(notifier).to receive(:find_image).with(:failure)
102
+ notifier.failure_image
103
+ end
104
+ end
105
+
106
+ context 'when core base has a image' do
107
+ it 'returns core base image' do
108
+ expect(Core::Base).to receive(:failure_image).and_return('some_image.png')
109
+ expect(notifier.failure_image).to eq 'some_image.png'
110
+ end
111
+ end
112
+ end
113
+
114
+ describe '#pending_image' do
115
+ context 'when core base image is blank' do
116
+ it 'find a image inside mode dir' do
117
+ expect(notifier).to receive(:find_image).with(:pending)
118
+ notifier.pending_image
119
+ end
120
+ end
121
+
122
+ context 'when core base has a image' do
123
+ it 'returns core base image' do
124
+ expect(Core::Base).to receive(:pending_image).and_return('some_image.png')
125
+ expect(notifier.pending_image).to eq 'some_image.png'
126
+ end
127
+ end
128
+ end
129
+
130
+ describe '#notify' do
131
+ let(:notification_builder) { double }
132
+
133
+ before do
134
+ expect(Core::Base).to receive(:mode).and_return(:simpson)
135
+ expect(test_framework).to receive(:success?).and_return(true)
136
+ expect(test_framework).to receive(:test_message).and_return('5 examples, 0 failures')
137
+ end
138
+
139
+ it 'sends a notification with title, message and image' do
140
+ expect(notifier).to receive(:auto_discover).and_return(notification_builder)
141
+ expect(notification_builder).to receive(:title).with(RUBY_VERSION).and_return(notification_builder)
142
+ expect(notification_builder).to receive(:message).with('5 examples, 0 failures').and_return(notification_builder)
143
+ expect(notification_builder).to receive(:image).and_return(notification_builder)
144
+ expect(notification_builder).to receive(:notify)
145
+
146
+ notifier.notify
147
+ end
148
+ end
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,168 @@
1
+ require "spec_helper"
2
+
3
+ module InfinityTest
4
+ describe Options do
5
+ describe "#parse!" do
6
+ describe "#strategy" do
7
+ it "parses the --ruby options with rvm" do
8
+ expect(parse('--ruby', 'rvm').strategy).to be :rvm
9
+ end
10
+
11
+ it "parses the --ruby options with rbenv" do
12
+ expect(parse('--ruby', 'rbenv').strategy).to be :rbenv
13
+ end
14
+ end
15
+
16
+ describe "#rubies" do
17
+ it "passes the ruby versions" do
18
+ expect(parse('--rubies=ree,jruby').rubies).to eql %w(ree jruby)
19
+ end
20
+
21
+ it "has empty rubies when pass rubies= without versions" do
22
+ expect(parse('--rubies=').rubies).to eql []
23
+ end
24
+
25
+ it "is nil when rubies option is not passed" do
26
+ expect(parse.rubies).to be_nil
27
+ end
28
+ end
29
+
30
+ describe "#infinity_and_beyond" do
31
+ it "returns false when setting --no-infinity-and-beyond" do
32
+ expect(parse('--no-infinity-and-beyond').infinity_and_beyond).to equal false
33
+ expect(parse('-n').infinity_and_beyond).to equal false
34
+ end
35
+
36
+ it "returns nil when not setting the --no-infinity-and-beyond" do
37
+ expect(parse.infinity_and_beyond).to be_nil
38
+ end
39
+ end
40
+
41
+ describe "#specific_options" do
42
+ it "parses the options" do
43
+ expect(parse('--options=-J-Ilib-Itest').specific_options).to eql '-J -Ilib -Itest'
44
+ end
45
+ end
46
+
47
+ describe "#test_framework" do
48
+ it "parses the test framework as rspec" do
49
+ expect(parse('--test', 'rspec').test_framework).to be :rspec
50
+ end
51
+
52
+ it "parses the test framework as test_unit" do
53
+ expect(parse('--test', 'test_unit').test_framework).to be :test_unit
54
+ end
55
+
56
+ it "parses the test framework as other" do
57
+ expect(parse('--test', 'other').test_framework).to be :other
58
+ end
59
+ end
60
+
61
+ describe "#framework" do
62
+ it "parses the app framework as rails" do
63
+ expect(parse('--framework', 'rails').framework).to be :rails
64
+ end
65
+
66
+ it "parses the app framework as rubygems" do
67
+ expect(parse('--framework', 'rubygems').framework).to be :rubygems
68
+ end
69
+
70
+ it "parses the app framework as other" do
71
+ expect(parse('--framework', 'other').framework).to be :other
72
+ end
73
+ end
74
+
75
+ describe "#verbose?" do
76
+ it "returns nil when nothing is passed" do
77
+ expect(parse.verbose?).to be_nil
78
+ end
79
+
80
+ it "is not verbose when passing the option --no-verbose" do
81
+ expect(parse('--no-verbose')).not_to be_verbose
82
+ end
83
+ end
84
+
85
+ describe "#bundler?" do
86
+ it "does not use bundler when passing this option" do
87
+ expect(parse('--no-bundler')).not_to be_bundler
88
+ end
89
+
90
+ it "returns nil when nothing is passed" do
91
+ expect(parse.bundler?).to be_nil
92
+ end
93
+ end
94
+
95
+ describe "#notifications" do
96
+ it "parses the notifications library as auto_discover" do
97
+ expect(parse('--notifications', 'auto_discover').notifications).to be :auto_discover
98
+ end
99
+
100
+ it "parses the notifications library as osascript" do
101
+ expect(parse('--notifications', 'osascript').notifications).to be :osascript
102
+ end
103
+
104
+ it "parses the notifications library as terminal_notifier" do
105
+ expect(parse('--notifications', 'terminal_notifier').notifications).to be :terminal_notifier
106
+ end
107
+
108
+ it "returns nil when nothing is passed" do
109
+ expect(parse.notifications).to be_nil
110
+ end
111
+ end
112
+
113
+ describe "#mode" do
114
+ it "parses the image mode as simpson" do
115
+ expect(parse('--mode', 'simpson').mode).to be :simpson
116
+ end
117
+
118
+ it "parses the image mode as faces" do
119
+ expect(parse('--mode', 'faces').mode).to be :faces
120
+ end
121
+
122
+ it "parses the image mode as rails" do
123
+ expect(parse('--mode', 'rails').mode).to be :rails
124
+ end
125
+
126
+ it "returns nil when nothing is passed" do
127
+ expect(parse.mode).to be_nil
128
+ end
129
+ end
130
+
131
+ describe "#just_watch" do
132
+ it "returns true when setting --just-watch" do
133
+ expect(parse('--just-watch').just_watch).to eq true
134
+ end
135
+
136
+ it "returns true when setting -j" do
137
+ expect(parse('-j').just_watch).to eq true
138
+ end
139
+
140
+ it "returns nil when nothing is passed" do
141
+ expect(parse.just_watch).to be_nil
142
+ end
143
+ end
144
+
145
+ describe "#focus" do
146
+ it "parses --focus with file path" do
147
+ expect(parse('--focus', 'spec/models/user_spec.rb').focus).to eq 'spec/models/user_spec.rb'
148
+ end
149
+
150
+ it "parses -f with file path" do
151
+ expect(parse('-f', 'spec/models/user_spec.rb').focus).to eq 'spec/models/user_spec.rb'
152
+ end
153
+
154
+ it "parses --focus failures as symbol" do
155
+ expect(parse('--focus', 'failures').focus).to eq :failures
156
+ end
157
+
158
+ it "returns nil when nothing is passed" do
159
+ expect(parse.focus).to be_nil
160
+ end
161
+ end
162
+ end
163
+
164
+ def parse(*args)
165
+ InfinityTest::Options.new(args.flatten).parse!
166
+ end
167
+ end
168
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ describe Runner do
5
+ let(:runner) { Runner.new('--ruby', 'rvm') }
6
+
7
+ describe '#start' do
8
+ it 'load configuration, merge with command line, find user libraries and start continuous server' do
9
+ expect_any_instance_of(Core::LoadConfiguration).to receive(:load!)
10
+ expect(Core::Base).to receive(:merge!).with(runner.options)
11
+ expect_any_instance_of(Core::AutoDiscover).to receive(:discover_libraries)
12
+ expect_any_instance_of(ContinuousTestServer).to receive(:start)
13
+ runner.start
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ module Framework
5
+ describe Base do
6
+ subject(:base) { Base.new(continuous_test_server) }
7
+ let(:continuous_test_server) { double(extension: :rb) }
8
+
9
+ describe '#run_all' do
10
+ it 'call run strategy to continuous test server' do
11
+ expect(continuous_test_server).to receive(:run_strategy)
12
+ base.run_all
13
+ end
14
+ end
15
+
16
+ describe '#run_test' do
17
+ let(:test_framework) { double(test_dir: 'test') }
18
+
19
+ before do
20
+ expect(base).to receive(:test_framework).and_return(test_framework)
21
+ end
22
+
23
+ context 'find a file' do
24
+ it 'call run strategy to continuous test server' do
25
+ expect(base.hike).to receive(:find).with('framework/base_test.rb').and_return('framework/base_test.rb')
26
+ expect(continuous_test_server).to receive(:rerun_strategy).with('framework/base_test.rb')
27
+ base.run_test(double(path: 'framework/base'))
28
+ end
29
+
30
+ it 'use the extension name from core base' do
31
+ expect(base).to receive(:extension).and_return('py')
32
+ expect(base.hike).to receive(:find).with('framework/base_test.py').and_return('framework/base_test.py')
33
+ expect(continuous_test_server).to receive(:rerun_strategy).with('framework/base_test.py')
34
+ base.run_test(double(path: 'framework/base'))
35
+ end
36
+ end
37
+
38
+ context 'when do not find any files' do
39
+ it 'do not call rerun strategy' do
40
+ expect(base.hike).to receive(:find).with('test_framework/rspec_test.rb').and_return(nil)
41
+ expect(continuous_test_server).to_not receive(:rerun_strategy)
42
+ base.run_test(double(path: 'test_framework/rspec'))
43
+ end
44
+ end
45
+ end
46
+
47
+ describe '#run_file' do
48
+ it 'rerun strategy passing the changed file path' do
49
+ expect(continuous_test_server).to receive(:rerun_strategy).with('base_spec.rb')
50
+ base.run_file(double(name: 'base_spec.rb', path: 'base_spec'))
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,36 @@
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') }
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 "adds heuristics" do
13
+ # 6 watch_dir calls: models, controllers, helpers, mailers, lib, test_dir
14
+ expect(observer).to receive(:watch_dir).exactly(6)
15
+ # 1 watch call for test_helper_file
16
+ expect(observer).to receive(:watch)
17
+ expect(test_framework).to receive(:test_helper_file)
18
+ expect(test_framework).to receive(:test_dir)
19
+ expect { subject.heuristics }.to_not raise_exception
20
+ end
21
+ end
22
+
23
+ describe ".run?" do
24
+ it "returns true if config/apps.rb exists" do
25
+ expect(File).to receive(:exist?).with(File.expand_path('./config/apps.rb')).and_return(true)
26
+ expect(Padrino).to be_run
27
+ end
28
+
29
+ it "returns false if config/apps.rb does not exist" do
30
+ expect(File).to receive(:exist?).with(File.expand_path('./config/apps.rb')).and_return(false)
31
+ expect(Padrino).not_to be_run
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,36 @@
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') }
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 "adds heuristics" do
13
+ # 6 watch_dir calls: models, controllers, helpers, mailers, jobs, lib, test_dir
14
+ expect(observer).to receive(:watch_dir).exactly(7)
15
+ # 1 watch call for test_helper_file
16
+ expect(observer).to receive(:watch)
17
+ expect(test_framework).to receive(:test_helper_file)
18
+ expect(test_framework).to receive(:test_dir)
19
+ expect { subject.heuristics }.to_not raise_exception
20
+ end
21
+ end
22
+
23
+ describe ".run?" do
24
+ it "returns true if config/environment.rb exists" do
25
+ expect(File).to receive(:exist?).with(File.expand_path('./config/environment.rb')).and_return(true)
26
+ expect(Rails).to be_run
27
+ end
28
+
29
+ it "returns false if config/environment.rb does not exist" do
30
+ expect(File).to receive(:exist?).with(File.expand_path('./config/environment.rb')).and_return(false)
31
+ expect(Rails).not_to be_run
32
+ end
33
+ end
34
+ end
35
+ end
36
+ 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
@@ -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