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
@@ -0,0 +1,26 @@
1
+ module InfinityTest
2
+ module OldDSL
3
+ class Configuration
4
+ # Pass the responsability to InfinityTest::Base class.
5
+ #
6
+ # <b>Don't need #super or #respond_to here.</b>
7
+ # <b>This class will be removed in infinity_test 2.0.1</b>
8
+ #
9
+ def method_missing(method_name, *arguments, &block)
10
+ InfinityTest::Base.send(method_name, *arguments, &block)
11
+ end
12
+ end
13
+
14
+ module InfinityTestMethod
15
+ # <b>DEPRECATED:</b> Please use <tt>InfinityTest::Base.setup</tt> instead.
16
+ #
17
+ def infinity_test(&block)
18
+ message = "infinity_test method is deprecated. Use InfinityTest.setup { |config| ... } instead."
19
+ ActiveSupport::Deprecation.warn(message)
20
+ ::InfinityTest::OldDSL::Configuration.new.instance_eval(&block)
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ include InfinityTest::OldDSL::InfinityTestMethod
@@ -0,0 +1,34 @@
1
+ module InfinityTest
2
+ module Strategy
3
+ class Base
4
+ def initialize(continuous_test_server)
5
+ @continuous_test_server = continuous_test_server
6
+ end
7
+
8
+ # ==== Returns
9
+ # CommandBuilderClass: A class that builds that command using method_missing.
10
+ #
11
+ def command_builder
12
+ Core::CommandBuilder.new
13
+ end
14
+
15
+ # Run the strategy and parse the results storing in the strategy.
16
+ #
17
+ def run
18
+ Core::CommandRunner.new(run!)
19
+ end
20
+
21
+ # Implement #run! method returning a string command to be run.
22
+ #
23
+ def run!
24
+ raise NotImplementedError, "not implemented in #{self}"
25
+ end
26
+
27
+ # Put all the requires to autodiscover use your strategy instead of others.
28
+ #
29
+ def self.run?
30
+ raise NotImplementedError, "not implemented in #{self}"
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,32 @@
1
+ module InfinityTest
2
+ module Strategy
3
+ class Rbenv < Base
4
+ attr_reader :continuous_test_server
5
+ delegate :binary, :test_files, to: :continuous_test_server
6
+
7
+ # Build and run commands for each ruby version specified.
8
+ # Uses rbenv's RBENV_VERSION environment variable to run tests in different Ruby environments.
9
+ #
10
+ # ==== Returns
11
+ # String: The command string for all ruby versions joined with &&
12
+ #
13
+ def run!
14
+ rubies = Core::Base.rubies
15
+
16
+ commands = rubies.map do |ruby_version|
17
+ "RBENV_VERSION=#{ruby_version} #{command_builder.ruby.option(:S).add(binary).add(test_files).to_s}"
18
+ end
19
+
20
+ commands.join(' && ')
21
+ end
22
+
23
+ # ==== Returns
24
+ # TrueClass: If the user has rbenv installed AND has specified rubies to test against.
25
+ # FalseClass: If rbenv is not installed OR no rubies are specified.
26
+ #
27
+ def self.run?
28
+ Core::Base.rubies.present? && File.exist?(File.expand_path('~/.rbenv'))
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,20 @@
1
+ module InfinityTest
2
+ module Strategy
3
+ class RubyDefault < Base
4
+ attr_reader :continuous_test_server
5
+ delegate :binary, :test_files, to: :continuous_test_server
6
+
7
+ def run!
8
+ command_builder.ruby.option(:S).add(binary).add(test_files).to_s
9
+ end
10
+
11
+ # ==== Returns
12
+ # TrueClass: If the user don't pass the ruby versions to run tests.
13
+ # FalseClass: If the user pass some ruby version to run tests.
14
+ #
15
+ def self.run?
16
+ Core::Base.rubies.blank?
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,50 @@
1
+ module InfinityTest
2
+ module Strategy
3
+ class Rvm < Base
4
+ attr_reader :continuous_test_server
5
+ delegate :binary, :test_files, to: :continuous_test_server
6
+
7
+ # Build and run commands for each ruby version specified.
8
+ # Uses RVM's `rvm <version> do` syntax to run tests in different Ruby environments.
9
+ #
10
+ # ==== Returns
11
+ # String: The command string for the first ruby version (others run sequentially)
12
+ #
13
+ def run!
14
+ rubies = Core::Base.rubies
15
+ gemset = Core::Base.gemset
16
+
17
+ commands = rubies.map do |ruby_version|
18
+ ruby_with_gemset = gemset.present? ? "#{ruby_version}@#{gemset}" : ruby_version
19
+ command_builder.rvm.add(ruby_with_gemset).do.ruby.option(:S).add(binary).add(test_files).to_s
20
+ end
21
+
22
+ commands.join(' && ')
23
+ end
24
+
25
+ # ==== Returns
26
+ # TrueClass: If the user has RVM installed AND has specified rubies to test against.
27
+ # FalseClass: If RVM is not installed OR no rubies are specified.
28
+ #
29
+ def self.run?
30
+ Core::Base.rubies.present? && (installed_users_home? || installed_system_wide?)
31
+ end
32
+
33
+ # ==== Returns
34
+ # TrueClass: Find rvm installed in ~/.rvm.
35
+ # FalseClass: Don't Find rvm installed in ~/.rvm.
36
+ #
37
+ def self.installed_users_home?
38
+ File.exist?(File.expand_path('~/.rvm'))
39
+ end
40
+
41
+ # ==== Returns
42
+ # TrueClass: Find rvm installed in /usr/local/rvm.
43
+ # FalseClass: Don't Find rvm installed in /usr/local/rvm.
44
+ #
45
+ def self.installed_system_wide?
46
+ File.exist?(File.expand_path("/usr/local/rvm"))
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,32 @@
1
+ module InfinityTest
2
+ module Strategy
3
+ module SharedExample
4
+ # Shared Examples to use in the RSpec specs when you want create your own strategy
5
+ #
6
+ # ==== Examples
7
+ #
8
+ # RSpec.configure do |config|
9
+ # config.include InfinityTest::Strategy::SharedExample
10
+ # end
11
+ #
12
+ # describe FooStrategy do
13
+ # subject { FooStrategy.new(InfinityTest::Core::Base) }
14
+ # it_should_behave_like 'a infinity test strategy'
15
+ # end
16
+ #
17
+ shared_examples_for 'a infinity test strategy' do
18
+ it 'responds to #run!' do
19
+ expect(subject).to respond_to(:run)
20
+ end
21
+
22
+ it 'responds to .run?' do
23
+ expect(subject.class).to respond_to(:run?)
24
+ end
25
+
26
+ it 'has Strategy::Base as superclass' do
27
+ expect(subject.class.superclass).to be InfinityTest::Strategy::Base
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,64 @@
1
+ module InfinityTest
2
+ module TestFramework
3
+ class Base
4
+ attr_writer :test_files
5
+ attr_reader :test_message
6
+
7
+ def test_helper_file
8
+ raise NotImplementedError, "not implemented in #{self}"
9
+ end
10
+
11
+ def test_dir
12
+ raise NotImplementedError, "not implemented in #{self}"
13
+ end
14
+
15
+ def test_dir=(dir)
16
+ raise NotImplementedError, "not implemented in #{self}"
17
+ end
18
+
19
+ def binary
20
+ raise NotImplementedError, "not implemented in #{self}"
21
+ end
22
+
23
+ # Parse the test results based by the framework patterns.
24
+ # <b>The subclass must implement the #patterns method.</b>
25
+ #
26
+ def test_message=(message)
27
+ @test_message = final_results(message).join.gsub(/\e\[\d+?m/, '') # Clean ANSIColor strings
28
+
29
+ patterns.each do |key, pattern|
30
+ spec_number = test_message[pattern, 1].to_i
31
+ instance_variable_set("@#{key}", spec_number)
32
+ end
33
+
34
+ @test_message
35
+ end
36
+
37
+ def patterns
38
+ raise NotImplementedError, "not implemented in #{self}"
39
+ end
40
+
41
+ def success?
42
+ raise NotImplementedError, "not implemented in #{self}"
43
+ end
44
+
45
+ def failure?
46
+ raise NotImplementedError, "not implemented in #{self}"
47
+ end
48
+
49
+ def pending?
50
+ raise NotImplementedError, "not implemented in #{self}"
51
+ end
52
+
53
+ private
54
+
55
+ def final_results(message)
56
+ lines = message.split("\n")
57
+
58
+ patterns.map do |pattern_name, pattern|
59
+ lines.find { |line| line =~ pattern }
60
+ end.flatten.uniq
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,48 @@
1
+ module InfinityTest
2
+ module TestFramework
3
+ class Rspec < Base
4
+ def binary
5
+ 'rspec'
6
+ end
7
+
8
+ def test_helper_file
9
+ File.join(test_dir, 'spec_helper.rb')
10
+ end
11
+
12
+ def test_dir
13
+ @test_dir ||= 'spec'
14
+ end
15
+
16
+ def test_dir=(dir)
17
+ @test_dir = dir
18
+ end
19
+
20
+ def test_files
21
+ @test_files || test_dir
22
+ end
23
+
24
+ def patterns
25
+ { :examples => /(\d+) example/, :failures => /(\d+) failure/, :pending => /(\d+) pending/ }
26
+ end
27
+
28
+ def success?
29
+ @failures.zero? and @pending.zero?
30
+ end
31
+
32
+ def failure?
33
+ @failures > 0
34
+ end
35
+
36
+ def pending?
37
+ @pending > 0
38
+ end
39
+
40
+ def self.run?
41
+ File.exist?('spec') && (
42
+ File.exist?('spec/spec_helper.rb') ||
43
+ Dir['spec/**/*_spec.rb'].any?
44
+ )
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,56 @@
1
+ module InfinityTest
2
+ module TestFramework
3
+ module SharedExample
4
+ # Shared Examples to use in the RSpec specs when you want create your own infinity test wrapper test framework
5
+ #
6
+ # ==== Examples
7
+ #
8
+ # RSpec.configure do |config|
9
+ # config.include InfinityTest::TestFramework::SharedExample
10
+ # end
11
+ #
12
+ # describe FooTestFramework do
13
+ # subject { FooStrategy.new(InfinityTest::Core::Base) }
14
+ # it_should_behave_like 'a infinity test test framework'
15
+ # end
16
+ #
17
+ shared_examples_for 'a infinity test test framework' do
18
+ it 'responds to #test_message=' do
19
+ expect(subject).to respond_to(:test_message=)
20
+ end
21
+
22
+ it 'responds to #test_message' do
23
+ expect(subject).to respond_to(:test_message)
24
+ end
25
+
26
+ it 'responds to #succeed?' do
27
+ expect(subject).to respond_to(:success?)
28
+ end
29
+
30
+ it 'responds to #failure?' do
31
+ expect(subject).to respond_to(:failure?)
32
+ end
33
+
34
+ it 'responds to #pending?' do
35
+ expect(subject).to respond_to(:pending?)
36
+ end
37
+
38
+ it 'responds to #test_helper_file' do
39
+ expect(subject).to respond_to(:test_helper_file)
40
+ end
41
+
42
+ it 'responds to #test_dir' do
43
+ expect(subject).to respond_to(:test_dir)
44
+ end
45
+
46
+ it 'responds to #test_dir=' do
47
+ expect(subject).to respond_to(:test_dir=)
48
+ end
49
+
50
+ it 'responds to #binary' do
51
+ expect(subject).to respond_to(:binary)
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,57 @@
1
+ module InfinityTest
2
+ module TestFramework
3
+ class TestUnit < Base
4
+ def test_dir
5
+ @test_dir ||= 'test'
6
+ end
7
+
8
+ def test_dir=(dir)
9
+ @test_dir = dir
10
+ end
11
+
12
+ def test_helper_file
13
+ File.join(test_dir, 'test_helper.rb')
14
+ end
15
+
16
+ def test_files
17
+ @test_files || test_dir
18
+ end
19
+
20
+ def binary
21
+ 'ruby'
22
+ end
23
+
24
+ # Patterns for parsing minitest/test-unit output
25
+ # Example: "10 runs, 15 assertions, 0 failures, 0 errors, 0 skips"
26
+ def patterns
27
+ {
28
+ :runs => /(\d+) runs,/,
29
+ :assertions => /(\d+) assertions,/,
30
+ :failures => /(\d+) failures,/,
31
+ :errors => /(\d+) errors,/,
32
+ :skips => /(\d+) skips/
33
+ }
34
+ end
35
+
36
+ def success?
37
+ @failures.zero? && @errors.zero? && @skips.zero?
38
+ end
39
+
40
+ def failure?
41
+ @failures > 0 || @errors > 0
42
+ end
43
+
44
+ def pending?
45
+ @skips > 0
46
+ end
47
+
48
+ def self.run?
49
+ File.exist?('test') && (
50
+ File.exist?('test/test_helper.rb') ||
51
+ Dir['test/**/*_test.rb'].any? ||
52
+ Dir['test/**/test_*.rb'].any?
53
+ )
54
+ end
55
+ end
56
+ end
57
+ end
data/lib/infinity_test.rb CHANGED
@@ -1,51 +1,69 @@
1
- require 'infinity_test/dependencies'
1
+ require 'optparse'
2
+ require 'active_support'
3
+ require 'active_support/core_ext'
4
+ require 'active_support/deprecation'
5
+ require 'hike'
6
+ require 'notifiers'
2
7
 
3
8
  module InfinityTest
4
-
5
- autoload :Application, 'infinity_test/application'
6
- autoload :BinaryPath, 'infinity_test/binary_path'
7
- autoload :Builder, 'infinity_test/builder'
8
- autoload :Command, 'infinity_test/command'
9
- autoload :Configuration, 'infinity_test/configuration'
10
- autoload :ContinuousTesting, 'infinity_test/continuous_testing'
11
- autoload :Environment, 'infinity_test/environment'
12
- autoload :Heuristics, 'infinity_test/heuristics'
13
- autoload :HeuristicsHelper, 'infinity_test/heuristics_helper'
14
- autoload :Options, 'infinity_test/options'
15
- autoload :Runner, 'infinity_test/runner'
16
- autoload :TestFramework, 'infinity_test/test_framework'
17
-
18
- module ApplicationLibrary
19
- autoload :Rails , 'infinity_test/application_library/rails'
20
- autoload :RubyGems, 'infinity_test/application_library/rubygems'
9
+ module Core
10
+ autoload :AutoDiscover, 'infinity_test/core/auto_discover'
11
+ autoload :Base, 'infinity_test/core/base'
12
+ autoload :Callback, 'infinity_test/core/callback'
13
+ autoload :CommandBuilder, 'infinity_test/core/command_builder'
14
+ autoload :CommandRunner, 'infinity_test/core/command_runner'
15
+ autoload :ConfigurationMerge, 'infinity_test/core/configuration_merge'
16
+ autoload :ContinuousTestServer, 'infinity_test/core/continuous_test_server'
17
+ autoload :ChangedFile, 'infinity_test/core/changed_file'
18
+ autoload :LoadConfiguration, 'infinity_test/core/load_configuration'
19
+ autoload :Notifier, 'infinity_test/core/notifier'
20
+ autoload :Options, 'infinity_test/core/options'
21
+ autoload :Runner, 'infinity_test/core/runner'
21
22
  end
22
23
 
23
- module TestLibrary
24
- autoload :Bacon, 'infinity_test/test_library/bacon'
25
- autoload :Cucumber, 'infinity_test/test_library/cucumber'
26
- autoload :Rspec, 'infinity_test/test_library/rspec'
27
- autoload :TestUnit, 'infinity_test/test_library/test_unit'
24
+ # This will be removed in the InfinityTest oficial 2.0.1.
25
+ #
26
+ module OldDSL
27
+ autoload :Configuration, 'infinity_test/old_dsl/configuration'
28
28
  end
29
29
 
30
- def self.application
31
- @application ||= Application.new
30
+ module Framework
31
+ autoload :Base, 'infinity_test/framework/base'
32
+ autoload :Helpers, 'infinity_test/framework/helpers'
33
+ autoload :SharedExample, 'infinity_test/framework/shared_example'
32
34
  end
33
35
 
34
- def self.configuration
35
- @configuration ||= Configuration.new
36
+ module Observer
37
+ autoload :Base, 'infinity_test/observer/base'
38
+ autoload :Listen, 'infinity_test/observer/listen'
39
+ autoload :Filewatcher, 'infinity_test/observer/filewatcher'
40
+ autoload :SharedExample, 'infinity_test/observer/shared_example'
36
41
  end
37
42
 
38
- def self.watchr
39
- @watchr ||= Watchr::Script.new
43
+ module Strategy
44
+ autoload :Base, 'infinity_test/strategy/base'
45
+ autoload :SharedExample, 'infinity_test/strategy/shared_example'
40
46
  end
41
47
 
42
- def self.start!
43
- Runner.new(ARGV).run!
48
+ module TestFramework
49
+ autoload :Base, 'infinity_test/test_framework/base'
50
+ autoload :SharedExample, 'infinity_test/test_framework/shared_example'
44
51
  end
45
-
46
- def self.version
47
- version = YAML.load_file(File.dirname(__FILE__) + '/../VERSION.yml')
48
- [version[:major], version[:minor], version[:patch]].compact.join(".")
52
+
53
+ # See Core::Base.setup to more information.
54
+ #
55
+ def self.setup(&block)
56
+ InfinityTest::Base.setup(&block)
49
57
  end
50
58
 
59
+ include Core
51
60
  end
61
+
62
+ require 'infinity_test/strategy/rbenv'
63
+ require 'infinity_test/strategy/rvm'
64
+ require 'infinity_test/strategy/ruby_default'
65
+ require 'infinity_test/framework/padrino'
66
+ require 'infinity_test/framework/rails'
67
+ require 'infinity_test/framework/rubygems'
68
+ require 'infinity_test/test_framework/test_unit'
69
+ require 'infinity_test/test_framework/rspec'
@@ -0,0 +1,149 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ module InfinityTest
5
+ describe AutoDiscover do
6
+ let(:base) { BaseFixture.new }
7
+ let(:auto_discover) { AutoDiscover.new(base) }
8
+
9
+ describe '#discover_libraries' do
10
+ it 'discovers strategy, framework and test framework' do
11
+ expect(auto_discover).to receive(:discover_strategy)
12
+ expect(auto_discover).to receive(:discover_framework)
13
+ expect(auto_discover).to receive(:discover_test_framework)
14
+ auto_discover.discover_libraries
15
+ end
16
+ end
17
+
18
+ describe '#discover_strategy' do
19
+ context 'when strategy is auto discover' do
20
+ before do
21
+ base.strategy = :auto_discover
22
+ allow(Strategy::RubyDefault).to receive(:run?).and_return(false)
23
+ expect(Strategy::Rvm).to receive(:run?).and_return(true)
24
+ end
25
+
26
+ it 'changes the base strategy' do
27
+ auto_discover.discover_strategy
28
+ expect(base.strategy).to be :rvm
29
+ end
30
+ end
31
+
32
+ context 'when strategy is different from auto discover' do
33
+ before { base.strategy = :ruby_default }
34
+
35
+ it 'does not change anything' do
36
+ auto_discover.discover_strategy
37
+ expect(base.strategy).to be :ruby_default
38
+ end
39
+ end
40
+
41
+ context 'when do not find any strategy' do
42
+ before do
43
+ base.strategy = :auto_discover
44
+ allow(Strategy::RubyDefault).to receive(:run?).and_return(false)
45
+ expect(Strategy::Rvm).to receive(:run?).and_return(false)
46
+ allow(Strategy::Rbenv).to receive(:run?).and_return(false)
47
+ end
48
+
49
+ it 'raises exception' do
50
+ expect { auto_discover.discover_strategy }.to raise_error(Exception)
51
+ end
52
+ end
53
+ end
54
+
55
+ describe '#discover_framework' do
56
+ context 'when framework is auto discover' do
57
+ before do
58
+ base.framework = :auto_discover
59
+ allow(Framework::Rubygems).to receive(:run?).and_return(false)
60
+ expect(Framework::Rails).to receive(:run?).and_return(true)
61
+ end
62
+
63
+ it 'changes the base framework' do
64
+ auto_discover.discover_framework
65
+ expect(base.framework).to be :rails
66
+ end
67
+ end
68
+
69
+ context 'when framework is different from auto discover' do
70
+ before { base.framework = :padrino }
71
+
72
+ it 'does not change anything' do
73
+ auto_discover.discover_framework
74
+ expect(base.framework).to be :padrino
75
+ end
76
+ end
77
+ end
78
+
79
+ describe '#discover_test_framework' do
80
+ context 'when framework is auto discover' do
81
+ before do
82
+ base.test_framework = :auto_discover
83
+ allow(TestFramework::TestUnit).to receive(:run?).and_return(false)
84
+ expect(TestFramework::Rspec).to receive(:run?).and_return(true)
85
+ end
86
+
87
+ it 'changes the base framework' do
88
+ auto_discover.discover_test_framework
89
+ expect(base.test_framework).to be :rspec
90
+ end
91
+ end
92
+
93
+ context 'when framework is different from auto discover' do
94
+ before { base.test_framework = :test_unit }
95
+
96
+ it 'does not change anything' do
97
+ auto_discover.discover_test_framework
98
+ expect(base.test_framework).to be :test_unit
99
+ end
100
+ end
101
+ end
102
+
103
+ describe 'PRIORITY' do
104
+ it 'defines priority order for strategies' do
105
+ expect(AutoDiscover::PRIORITY[:strategy]).to eq [:rvm, :rbenv, :ruby_default]
106
+ end
107
+
108
+ it 'defines priority order for frameworks' do
109
+ expect(AutoDiscover::PRIORITY[:framework]).to eq [:rails, :padrino, :rubygems]
110
+ end
111
+
112
+ it 'defines priority order for test frameworks' do
113
+ expect(AutoDiscover::PRIORITY[:test_framework]).to eq [:rspec, :test_unit]
114
+ end
115
+ end
116
+
117
+ describe 'priority ordering' do
118
+ context 'when multiple strategies match' do
119
+ before do
120
+ base.strategy = :auto_discover
121
+ # Both RVM and RubyDefault would match, but RVM has higher priority
122
+ allow(Strategy::Rvm).to receive(:run?).and_return(true)
123
+ allow(Strategy::Rbenv).to receive(:run?).and_return(false)
124
+ allow(Strategy::RubyDefault).to receive(:run?).and_return(true)
125
+ end
126
+
127
+ it 'selects the higher priority strategy (RVM over RubyDefault)' do
128
+ auto_discover.discover_strategy
129
+ expect(base.strategy).to be :rvm
130
+ end
131
+ end
132
+
133
+ context 'when multiple frameworks match' do
134
+ before do
135
+ base.framework = :auto_discover
136
+ # Both Rails and Rubygems would match, but Rails has higher priority
137
+ allow(Framework::Rails).to receive(:run?).and_return(true)
138
+ allow(Framework::Padrino).to receive(:run?).and_return(false)
139
+ allow(Framework::Rubygems).to receive(:run?).and_return(true)
140
+ end
141
+
142
+ it 'selects the higher priority framework (Rails over Rubygems)' do
143
+ auto_discover.discover_framework
144
+ expect(base.framework).to be :rails
145
+ end
146
+ end
147
+ end
148
+ end
149
+ end