infinity_test 1.0.3 → 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 (148) 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 → INFINITY_TEST} +18 -15
  9. data/LICENSE.txt +2 -2
  10. data/README.md +627 -0
  11. data/Rakefile +1 -65
  12. data/TODO.markdown +24 -19
  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 -189
  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 +272 -176
  76. data/.rvmrc +0 -1
  77. data/Gemfile.lock +0 -62
  78. data/Readme.markdown +0 -147
  79. data/Tasks +0 -4
  80. data/VERSION.yml +0 -5
  81. data/buzz_images/buzz_lightyear.jpg +0 -0
  82. data/buzz_images/buzz_lightyear_continencia.gif +0 -0
  83. data/buzz_images/to_infinity_and_beyond.png +0 -0
  84. data/features/heuristics.feature +0 -23
  85. data/features/support/env.rb +0 -2
  86. data/images/fuuu/sucess.png +0 -0
  87. data/lib/infinity_test/application.rb +0 -362
  88. data/lib/infinity_test/application_library/rails.rb +0 -94
  89. data/lib/infinity_test/application_library/rubygems.rb +0 -43
  90. data/lib/infinity_test/binary_path.rb +0 -43
  91. data/lib/infinity_test/builder.rb +0 -66
  92. data/lib/infinity_test/command.rb +0 -58
  93. data/lib/infinity_test/configuration.rb +0 -277
  94. data/lib/infinity_test/continuous_testing.rb +0 -40
  95. data/lib/infinity_test/dependencies.rb +0 -80
  96. data/lib/infinity_test/environment.rb +0 -15
  97. data/lib/infinity_test/heuristics.rb +0 -36
  98. data/lib/infinity_test/heuristics_helper.rb +0 -9
  99. data/lib/infinity_test/options.rb +0 -96
  100. data/lib/infinity_test/runner.rb +0 -38
  101. data/lib/infinity_test/test_framework.rb +0 -110
  102. data/lib/infinity_test/test_library/bacon.rb +0 -55
  103. data/lib/infinity_test/test_library/cucumber.rb +0 -22
  104. data/lib/infinity_test/test_library/rspec.rb +0 -60
  105. data/lib/infinity_test/test_library/test_unit.rb +0 -52
  106. data/lib/infinity_test/test_unit_loader.rb +0 -5
  107. data/spec/factories/buzz/lib/buzz.rb +0 -0
  108. data/spec/factories/buzz/spec/buzz_spec.rb +0 -0
  109. data/spec/factories/company/Gemfile +0 -0
  110. data/spec/factories/company/lib/company.rb +0 -0
  111. data/spec/factories/company/test/company_test.rb +0 -0
  112. data/spec/factories/images/failure.png +0 -0
  113. data/spec/factories/images/pending.png +0 -0
  114. data/spec/factories/images/sucess.png +0 -0
  115. data/spec/factories/infinity_test +0 -5
  116. data/spec/factories/infinity_test_example +0 -7
  117. data/spec/factories/slinky/spec/slinky/slinky_spec.rb +0 -0
  118. data/spec/factories/travel/lib/travel.rb +0 -0
  119. data/spec/factories/travel/test/partner_test.rb +0 -0
  120. data/spec/factories/travel/test/travel_test.rb +0 -0
  121. data/spec/factories/wood/lib/wood.rb +0 -0
  122. data/spec/factories/wood/spec/wood_spec.rb +0 -0
  123. data/spec/infinity_test/application_library/rails_spec.rb +0 -140
  124. data/spec/infinity_test/application_library/rubygems_spec.rb +0 -52
  125. data/spec/infinity_test/application_spec.rb +0 -434
  126. data/spec/infinity_test/binary_path_spec.rb +0 -72
  127. data/spec/infinity_test/command_spec.rb +0 -53
  128. data/spec/infinity_test/configuration_spec.rb +0 -382
  129. data/spec/infinity_test/continuous_testing_spec.rb +0 -25
  130. data/spec/infinity_test/environment_spec.rb +0 -23
  131. data/spec/infinity_test/heuristics_helper_spec.rb +0 -15
  132. data/spec/infinity_test/heuristics_spec.rb +0 -127
  133. data/spec/infinity_test/options_spec.rb +0 -111
  134. data/spec/infinity_test/runner_spec.rb +0 -42
  135. data/spec/infinity_test/test_framework_spec.rb +0 -127
  136. data/spec/infinity_test/test_library/bacon_spec.rb +0 -150
  137. data/spec/infinity_test/test_library/cucumber_spec.rb +0 -8
  138. data/spec/infinity_test/test_library/rspec_spec.rb +0 -189
  139. data/spec/infinity_test/test_library/test_unit_spec.rb +0 -184
  140. data/spec/infinity_test_spec.rb +0 -40
  141. /data/images/faces/{sucess.png → success.png} +0 -0
  142. /data/images/hands/{sucess.png → success.png} +0 -0
  143. /data/images/mario_bros/{sucess.jpg → success.jpg} +0 -0
  144. /data/images/rails/{sucess.png → success.png} +0 -0
  145. /data/images/rubies/{sucess.png → success.png} +0 -0
  146. /data/images/simpson/{sucess.jpg → success.jpg} +0 -0
  147. /data/images/street_fighter/{sucess.jpg → success.jpg} +0 -0
  148. /data/images/toy_story/{sucess.png → success.png} +0 -0
data/Readme.markdown DELETED
@@ -1,147 +0,0 @@
1
- # Infinity Test
2
-
3
- Infinity Test is a continuous testing library and a flexible alternative to
4
- Autotest, using the awesome Watchr library with RSpec, Test::Unit, Bacon and
5
- with RVM functionality, giving the possibility to test with all Ruby versions
6
- that you have in your RVM configuration.
7
-
8
- ## To Infinity and Beyond!
9
-
10
- <div style="padding:2px; border:1px solid silver; float:right; margin:0 0 1em 2em; background:white">
11
- <img src="https://github.com/tomas-stefano/infinity_test/raw/master/buzz_images/to_infinity_and_beyond.png" alt="Infinity Test" />
12
- <p style="text-align:center">Photo taken from <a href="http://www.mixed-metaphor.org/fan/buzz/" title="buzz-light-year">this site</a></p>
13
- </div>
14
-
15
- ## Install
16
-
17
- gem install infinity_test
18
-
19
- ## Running Tests with the current Ruby
20
-
21
- With RSpec:
22
-
23
- infinity_test --rspec
24
-
25
- With Test::Unit:
26
-
27
- infinity_test --test-unit
28
-
29
- With Bacon:
30
-
31
- infinity_test --bacon
32
-
33
- ## Running Tests with multiple Rubies
34
-
35
- With RSpec:
36
-
37
- infinity_test --rspec --rubies=1.8.7,jruby,1.9.2,ree
38
-
39
- Or with Test::Unit:
40
-
41
- infinity_test --test-unit --rubies=1.8.7,jruby,ree,1.9.2
42
-
43
- Or with bacon:
44
-
45
- infinity_test --bacon --rubies=1.8.7,ree,1.9.2
46
-
47
- You can pass arguments to specific versions of Ruby with a '+' character:
48
-
49
- infinity_test --rspec --rubies=jruby+"J-cp bar/whisky-in-the.jar:."
50
-
51
- **Now you are ready to run your test suite against all Ruby versions with
52
- Autotest-like behavior.**
53
-
54
- ## Running Tests with Rails
55
-
56
- infinity_test --rails
57
-
58
- ## Configuration file
59
-
60
- ### Simple Domain Specific Language for Infinity Test file
61
-
62
- If you'd rather not constantly specify which versions of Ruby to use, or the
63
- testing framework to use, or which notifications you want to receive, you can
64
- specify those options one time in an `.infinity_test` file.
65
-
66
- You can create this file in your `$HOME` directory to be used globally across
67
- all projects, or you can specify the options per-project in the project's root
68
- folder:
69
-
70
- # ~/.infinity_test or .infinity_test
71
-
72
- infinity_test do
73
- notifications :growl do
74
- show_images :mode => :mario_bros
75
- end
76
-
77
- use :rubies => %w(1.9.1 jruby 1.9.2 ree), :test_framework => :rspec
78
-
79
- use :specific_options => {'jruby' => 'J-cp bar/whisky-in-the.jar:.'}
80
-
81
- before(:each_ruby) do |environment|
82
- # ...
83
- end
84
-
85
- after(:each_ruby) do |environment|
86
- # ...
87
- end
88
-
89
- before_run do
90
- clear :terminal
91
- end
92
-
93
- after_run do
94
- # ...
95
- end
96
-
97
- heuristics('my_pattern') do |file|
98
- # ...
99
- end
100
-
101
- replace_patterns do |application|
102
- # ...
103
- end
104
- end
105
-
106
- ## Customize the .infinity_test file
107
-
108
- If you want to customize and understand the .infinity_test file, [read this
109
- page](http://github.com/tomas-stefano/infinity_test/wiki/Customize-Infinity-Test).
110
-
111
- # Color in RSpec
112
-
113
- ### Put this in your .rspec file:
114
-
115
- In RSpec 2.2.0:
116
-
117
- --color
118
- --tty
119
-
120
- In RSpec 2.1.0:
121
-
122
- --color
123
- --autotest
124
-
125
- In RSpec 1.3, use the **spec.opts** file:
126
-
127
- --color
128
- --autospec
129
-
130
- **Note: These options will be the defaults in a future version of Infinity Test**
131
-
132
- ### Future
133
-
134
- * Add support for focus files (run failed results and then run all tests if those pass, etc.)
135
-
136
- ## You Like it the Idea?
137
-
138
- So make a fork and start contributing =].
139
-
140
- ## You have a Feature request or Fix?
141
-
142
- Contact me on GitHub, or Twitter ([@tomas_stefano](https://twitter.com/tomas_stefano)) and let's talk! =]
143
-
144
- # Acknowledgments
145
-
146
- * Thanks to Mynyml and Watchr library.
147
- * Thanks to Waynee Seguin and the RVM.
data/Tasks DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- class InfinityTest < Morpheus::Base
3
- rspec :spec, :rvm_versions => %w(1.8.7 ree 1.9.2 jruby)
4
- end
data/VERSION.yml DELETED
@@ -1,5 +0,0 @@
1
- ---
2
- :major: 1
3
- :minor: 0
4
- :patch: 3
5
- :build:
Binary file
Binary file
@@ -1,23 +0,0 @@
1
- Feature: Infinity test Heuristics
2
- In order to add or remove the paths to monitoring
3
- As a user
4
- I want to add/remove my own patterns to monitoring changes
5
-
6
- Scenario: Show the default patterns to RubyGems
7
- When I run "ruby ../../bin/infinity_test --heuristics --rubygems --rspec"
8
- Then the output should contain:
9
- """
10
- - "^lib/*/(.*).rb"
11
- - "^spec/*/(.*)_spec.rb"
12
- - "^spec/*/spec_helper.rb"
13
- """
14
-
15
- Scenario: Show the default patterns to RubyGems
16
- When I run "ruby ../../bin/infinity_test --heuristics --rubygems --test-unit"
17
- Then the output should contain:
18
- """
19
- - "^lib/*/(.*).rb"
20
- - "^test/*/(.*)_test.rb"
21
- - "^test/*/test_helper.rb"
22
- """
23
-
@@ -1,2 +0,0 @@
1
- require 'cucumber'
2
- require 'aruba'
Binary file
@@ -1,362 +0,0 @@
1
- module InfinityTest
2
- class Application
3
- include InfinityTest::TestLibrary
4
- include InfinityTest::ApplicationLibrary
5
- include Notifiers
6
-
7
- attr_accessor :config, :watchr, :global_commands
8
-
9
- # Initialize the Application object with the configuration instance to
10
- # load configuration and set properly
11
- #
12
- def initialize
13
- @config = InfinityTest.configuration
14
- @watchr = InfinityTest.watchr
15
- end
16
-
17
- def load_configuration_file_or_read_the_options!(options)
18
- load_configuration_file
19
- setup!(options)
20
- end
21
-
22
- # Load the Configuration file
23
- #
24
- # Command line options can be persisted in a .infinity_test file in a project.
25
- # You can also store a .infinity_test file in your home directory (~/.infinity_test) with global options.
26
- #
27
- # Precedence is:
28
- # command line
29
- # ./.infinity_test
30
- # ~/.infinity_test
31
- #
32
- # Example:
33
- #
34
- # ~/.infinity_test -> infinity_test { notifications :growl }
35
- #
36
- # ./.infinity_test -> infinity_test { notifications :lib_notify } # High Priority
37
- #
38
- # After the load the Notifications Framework will be Lib Notify
39
- #
40
- def load_configuration_file
41
- load_global_configuration # Separate global and local configuration
42
- load_project_configuration # because it's more easy to test
43
- end
44
-
45
- # Setup over a precendence show below.
46
- #
47
- # THIS IS NOT RESPONSABILITY OF Application instances!!!
48
- #
49
- def setup!(options)
50
- config.use(
51
- :rubies => (options[:rubies] || rubies),
52
- :specific_options => (options[:specific_options] || specific_options),
53
- :test_framework => (options[:test_framework] || config.test_framework),
54
- :app_framework => (options[:app_framework] || config.app_framework),
55
- :cucumber => options[:cucumber],
56
- :verbose => options[:verbose] || config.verbose)
57
- config.skip_bundler! if options[:skip_bundler?]
58
- add_heuristics!
59
- heuristics_users_high_priority!
60
- end
61
-
62
- # Run the global commands
63
- #
64
- def run_global_commands!
65
- run!(global_commands)
66
- end
67
-
68
- # Construct the Global Commands and cache for all suite
69
- #
70
- def global_commands
71
- @global_commands ||= construct_commands
72
- end
73
-
74
- # Return the sucess image to show in the notifications
75
- #
76
- def sucess_image
77
- config.sucess_image
78
- end
79
-
80
- # Return the failure image to show in the notifications
81
- #
82
- def failure_image
83
- config.failure_image
84
- end
85
-
86
- # Return the pending image to show in the notifications
87
- #
88
- def pending_image
89
- config.pending_image
90
- end
91
-
92
- # Return the block object setting in the config file
93
- #
94
- def before_callback
95
- config.before_callback
96
- end
97
-
98
- # Return the block object setting in the config file
99
- #
100
- def after_callback
101
- config.after_callback
102
- end
103
-
104
- # Return the block object setting in the before(:each_ruby) block
105
- #
106
- def before_each_ruby_callback
107
- config.before_each_ruby_callback
108
- end
109
-
110
- # Return the block object setting in the after(:each_ruby) block
111
- #
112
- def after_each_ruby_callback
113
- config.after_each_ruby_callback
114
- end
115
-
116
- # Return the rubies setting in the config file or the command line
117
- #
118
- def rubies
119
- config.rubies
120
- end
121
-
122
- # Return the rubies specific options in the config file or the command line
123
- #
124
- def specific_options
125
- config.specific_options
126
- end
127
-
128
- # Return true if verbose mode is on
129
- # Verbose mode is false as default
130
- #
131
- def verbose?
132
- config.verbose
133
- end
134
-
135
- # Return true if the user application has a Gemfile
136
- # Return false if not exist the Gemfile
137
- #
138
- def have_gemfile?
139
- File.exist?(gemfile)
140
- end
141
-
142
- # Return false if you want the InfinityTest run with bundler
143
- # Return true otherwise
144
- #
145
- def skip_bundler?
146
- config.skip_bundler?
147
- end
148
-
149
- # Contruct all the commands for the test framework
150
- #
151
- def construct_commands
152
- test_framework.construct_commands
153
- end
154
-
155
- # Return a instance of the test framework class
156
- #
157
- def test_framework
158
- @test_framework ||= setting_test_framework
159
- end
160
-
161
- # Return true if the application is using Test::Unit
162
- # Return false otherwise
163
- #
164
- def using_test_unit?
165
- test_framework.instance_of?(TestUnit)
166
- end
167
-
168
- # Return a instance of the app framework class
169
- #
170
- def app_framework
171
- @app_framework ||= setting_app_framework
172
- end
173
-
174
- # Return all the Heuristics of the application
175
- #
176
- def heuristics
177
- config.instance_variable_get(:@heuristics)
178
- end
179
-
180
- # Triggers the #add_heuristics! method in the application_framework
181
- #
182
- def add_heuristics!
183
- app_framework.add_heuristics!
184
- end
185
-
186
- def heuristics_users_high_priority!
187
- @watchr.rules.reverse!
188
- end
189
-
190
- # Pass many commands(expecting something that talk like Hash) and run them
191
- # First, triggers all the before each callbacks, run the commands
192
- # and last, triggers after each callbacks
193
- #
194
- def run!(commands)
195
- before_callback.call if before_callback
196
-
197
- commands.each do |ruby_version, command|
198
- call_each_ruby_callback(:before_each_ruby_callback, ruby_version)
199
- command = say_the_ruby_version_and_run_the_command!(ruby_version, command) # This method exist because it's more easier to test
200
- notify!(:results => command.results, :ruby_version => ruby_version)
201
- call_each_ruby_callback(:after_each_ruby_callback, ruby_version)
202
- end
203
-
204
- after_callback.call if after_callback
205
- end
206
-
207
- # Return the notification_framework setting in the configuration file
208
- # Maybe is: :growl, :lib_notify
209
- #
210
- def notification_framework
211
- config.notification_framework
212
- end
213
-
214
- # Send the message,image and the actual ruby version to show in the notification system
215
- #
216
- def notify!(options)
217
- if notification_framework
218
- message = parse_results(options[:results])
219
- title = options[:ruby_version]
220
- send(notification_framework).title(title).message(message).image(image_to_show).notify!
221
- else
222
- # skip(do nothing) when not have notification framework
223
- end
224
- end
225
-
226
- # Parse the results for each command to the test framework
227
- #
228
- # app.parse_results(['.....','108 examples']) # => '108 examples'
229
- #
230
- def parse_results(results)
231
- test_framework.parse_results(results)
232
- end
233
-
234
- # If the test pass, show the sucess image
235
- # If is some pending test, show the pending image
236
- # If the test fails, show the failure image
237
- #
238
- def image_to_show
239
- if test_framework.failure?
240
- failure_image
241
- elsif test_framework.pending?
242
- pending_image
243
- else
244
- sucess_image
245
- end
246
- end
247
-
248
- # Return the files that match by the options
249
- # This very used in the #run method called in the heuristics instances
250
- #
251
- # Example:
252
- #
253
- # files_to_run!(:all => :files) # => Return all test files
254
- # files_to_run!(:all => :files, :in_dir => :models) # => Return all the test files in the models directory
255
- # files_to_run!(:test_for => match_data) # => Return the tests that match with the MatchData Object
256
- # files_to_run!(:test_for => match_data, :in_dir => :controllers) # => Return the tests that match with the MatchData Object
257
- # files_to_run!(match_data) # => return the test file
258
- #
259
- def files_to_run!(options)
260
- files = search_files_to_run!(options)
261
- # Fix fo Test::Unit - But this is not responsability of the Application instances - Refactoring this
262
- files = "#{test_framework.test_loader} #{files}" if test_framework.respond_to?(:test_loader)
263
- files
264
- end
265
-
266
- def search_files_to_run!(options)
267
- case options
268
- when MatchData
269
- options.to_s
270
- when Hash,Symbol
271
- if options.equal?(:all) or options.include?(:all)
272
- search_files_in_dir(all_test_files, :in_dir => options[:in_dir]).join(' ')
273
- else
274
- search_file(:pattern => options[:test_for][1], :in_dir => options[:in_dir]) if options.include?(:test_for)
275
- end
276
- end
277
- end
278
-
279
- # Search files under the dir(s) specified
280
- #
281
- def search_files_in_dir(files, options)
282
- dirs = [options[:in_dir]].compact.flatten
283
- match_files = dirs.collect do |directory|
284
- files.select { |file| file.match(directory.to_s) }
285
- end
286
- match_files.empty? ? files : match_files
287
- end
288
-
289
- # Search files that matches with the pattern
290
- #
291
- def search_file(options)
292
- files = all_test_files.grep(/#{options[:pattern]}/i)
293
- search_files_in_dir(files, :in_dir => options[:in_dir]).join(' ')
294
- end
295
-
296
- # Return all the tests files in the User application
297
- #
298
- def all_test_files
299
- test_framework.all_files
300
- end
301
-
302
- # Run commands for a file
303
- # If dont have a file, do nothing
304
- #
305
- def run_commands_for_file(file)
306
- if file and !file.empty?
307
- commands = test_framework.construct_commands(file)
308
- run!(commands)
309
- end
310
- end
311
-
312
- def say_the_ruby_version_and_run_the_command!(ruby_version, command)
313
- puts; puts "* { :ruby => #{ruby_version} }"
314
- puts command if verbose?
315
- Command.new(:ruby_version => ruby_version, :command => command).run!
316
- end
317
-
318
- private
319
-
320
- def call_each_ruby_callback(callback_type, ruby_version)
321
- callback = send(callback_type)
322
- callback.call(RVM::Environment.new(ruby_version)) if callback
323
- end
324
-
325
- def setting_test_framework
326
- case config.test_framework
327
- when :rspec
328
- Rspec.new :rubies => rubies, :specific_options => specific_options
329
- when :test_unit
330
- TestUnit.new :rubies => rubies, :specific_options => specific_options
331
- when :bacon
332
- Bacon.new :rubies => rubies, :specific_options => specific_options
333
- end
334
- end
335
-
336
- def setting_app_framework
337
- case config.app_framework
338
- when :rails
339
- Rails.new
340
- when :rubygems
341
- RubyGems.new
342
- end
343
- end
344
-
345
- def load_global_configuration
346
- load_file(File.expand_path('~/.infinity_test'))
347
- end
348
-
349
- def load_project_configuration
350
- load_file('./.infinity_test')
351
- end
352
-
353
- def load_file(file)
354
- load(file) if File.exist?(file)
355
- end
356
-
357
- def gemfile
358
- File.join(Dir.pwd, 'Gemfile')
359
- end
360
-
361
- end
362
- end
@@ -1,94 +0,0 @@
1
- module InfinityTest
2
- module ApplicationLibrary
3
- class Rails
4
- include HeuristicsHelper
5
- attr_accessor :lib_pattern,
6
- :test_pattern,
7
- :configuration_pattern,
8
- :routes_pattern,
9
- :fixtures_pattern,
10
- :controllers_pattern,
11
- :models_pattern,
12
- :helpers_pattern,
13
- :mailers_pattern,
14
- :application_controller_pattern,
15
- :application_helper_pattern
16
-
17
- def initialize
18
- @application = InfinityTest.application
19
- resolve_patterns!
20
- end
21
-
22
- def add_heuristics!
23
- rails = self
24
- heuristics do
25
-
26
- add(rails.application_controller_pattern) do |file|
27
- run :all => :tests, :in_dir => :controllers
28
- end
29
-
30
- add(rails.application_helper_pattern) do |file|
31
- run :all => :tests, :in_dir => [:helpers, :views]
32
- end
33
-
34
- add(rails.configuration_pattern) do |file|
35
- run(:all => :tests)
36
- end
37
-
38
- add(rails.routes_pattern) do |file|
39
- run(:all => :tests)
40
- end
41
-
42
- add(rails.controllers_pattern) do |file|
43
- run :test_for => file, :in_dir => :controllers
44
- end
45
-
46
- add(rails.models_pattern) do |file|
47
- run :test_for => file, :in_dir => :models
48
- end
49
-
50
- add(rails.helpers_pattern) do |file|
51
- run :test_for => file, :in_dir => :helpers
52
- end
53
-
54
- add(rails.mailers_pattern) do |file|
55
- run :test_for => file, :in_dir => :mailers
56
- end
57
-
58
- add(rails.lib_pattern) do |file|
59
- run :test_for => file, :in_dir => :lib
60
- end
61
-
62
- add(rails.test_pattern) do |file|
63
- run file
64
- end
65
-
66
- add(rails.fixtures_pattern) do |file|
67
- run :all => :tests, :in_dir => :models
68
- end
69
-
70
- end
71
- end
72
-
73
- def resolve_patterns!
74
- @configuration_pattern = "^config/application.rb"
75
- @routes_pattern = "^config/routes\.rb"
76
- @lib_pattern = "^lib/*/(.*)\.rb"
77
- if @application.using_test_unit?
78
- @test_pattern = "^test/*/(.*)_test.rb"
79
- @fixtures_pattern = "^test/fixtures/(.*).yml"
80
- else
81
- @test_pattern = "^spec/*/(.*)_spec.rb"
82
- @fixtures_pattern = "^spec/fixtures/(.*).yml"
83
- end
84
- @controllers_pattern = "^app/controllers/(.*)\.rb"
85
- @models_pattern = "^app/models/(.*)\.rb"
86
- @helpers_pattern = "^app/helpers/(.*)\.rb"
87
- @mailers_pattern = "^app/mailers/(.*)\.rb"
88
- @application_controller_pattern = "^app/controllers/application_controller.rb"
89
- @application_helper_pattern = "^app/helpers/application_helper.rb"
90
- end
91
-
92
- end
93
- end
94
- end
@@ -1,43 +0,0 @@
1
- module InfinityTest
2
- module ApplicationLibrary
3
- class RubyGems
4
- include HeuristicsHelper
5
- attr_accessor :lib_pattern, :test_pattern, :application, :test_helper_pattern
6
-
7
- def initialize
8
- @application = InfinityTest.application
9
- @lib_pattern = "^lib/*/(.*)\.rb"
10
- if @application.using_test_unit?
11
- @test_pattern = "^test/*/(.*)_test.rb"
12
- @test_helper_pattern = "^test/*/test_helper.rb"
13
- else
14
- @test_pattern = "^spec/*/(.*)_spec.rb"
15
- @test_helper_pattern = "^spec/*/spec_helper.rb"
16
- end
17
- end
18
-
19
- # Add Heuristics to send to Watchr Methods
20
- # This methods aren't tested!
21
- #
22
- def add_heuristics!
23
- rubygems = self
24
- heuristics do
25
-
26
- add(rubygems.lib_pattern) do |file|
27
- run :test_for => file
28
- end
29
-
30
- add(rubygems.test_pattern) do |file|
31
- run file
32
- end
33
-
34
- add(rubygems.test_helper_pattern) do |file|
35
- run :all => :tests
36
- end
37
-
38
- end
39
- end
40
-
41
- end
42
- end
43
- end