rr 1.1.0 → 1.1.1.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +138 -102
  3. data/README.md +27 -23
  4. data/VERSION +1 -1
  5. data/lib/rr/adapters.rb +2 -19
  6. data/lib/rr/autohook.rb +3 -29
  7. data/lib/rr/integrations.rb +44 -2
  8. data/lib/rr/integrations/decorator.rb +40 -0
  9. data/lib/rr/integrations/minitest.rb +2 -0
  10. data/lib/rr/integrations/minitest_4.rb +3 -0
  11. data/lib/rr/integrations/minitest_4_active_support.rb +2 -0
  12. data/lib/rr/integrations/minitest_active_support.rb +2 -0
  13. data/lib/rr/integrations/rspec_1.rb +5 -1
  14. data/lib/rr/integrations/rspec_2.rb +5 -1
  15. data/lib/rr/integrations/test_unit_1.rb +11 -2
  16. data/lib/rr/integrations/test_unit_2.rb +3 -1
  17. data/lib/rr/integrations/test_unit_200.rb +27 -0
  18. data/lib/rr/integrations/test_unit_200_active_support.rb +25 -0
  19. data/lib/rr/integrations/test_unit_2_active_support.rb +6 -3
  20. data/lib/rr/without_autohook.rb +10 -4
  21. data/spec/global_helper.rb +45 -4
  22. data/spec/spec.opts +2 -0
  23. data/spec/suite.rb +23 -7
  24. data/spec/suites/common/adapter_integration_tests.rb +94 -31
  25. data/spec/suites/common/adapter_tests.rb +6 -0
  26. data/spec/suites/common/{rails_integration_test.rb → rails_integration_tests.rb} +40 -58
  27. data/spec/suites/minitest/integration/minitest_test.rb +5 -5
  28. data/spec/suites/minitest/test_helper.rb +5 -1
  29. data/spec/suites/minitest_4/integration/minitest_test.rb +13 -0
  30. data/spec/suites/minitest_4/test_helper.rb +7 -0
  31. data/spec/suites/rspec_1/helper.rb +24 -0
  32. data/spec/suites/rspec_1/integration/rspec_1_spec.rb +20 -18
  33. data/spec/suites/rspec_1/integration/test_unit_1_spec.rb +10 -14
  34. data/spec/suites/rspec_1/integration/test_unit_2_spec.rb +11 -18
  35. data/spec/suites/rspec_1/spec_helper.rb +2 -23
  36. data/spec/suites/{rspec_1/integration/test_unit_1_rails_spec.rb → rspec_1_rails_2/integration/test_unit_1_rails_2_spec.rb} +15 -16
  37. data/spec/suites/rspec_1_rails_2/integration/test_unit_2_rails_2_spec.rb +57 -0
  38. data/spec/suites/rspec_1_rails_2/spec_helper.rb +3 -0
  39. data/spec/suites/rspec_2/helper.rb +27 -0
  40. data/spec/suites/rspec_2/integration/minitest_4_spec.rb +8 -18
  41. data/spec/suites/rspec_2/integration/minitest_spec.rb +8 -10
  42. data/spec/suites/rspec_2/integration/rspec_2_spec.rb +22 -21
  43. data/spec/suites/rspec_2/integration/test_unit_200_spec.rb +57 -0
  44. data/spec/suites/rspec_2/integration/{test_unit_spec.rb → test_unit_2_spec.rb} +9 -11
  45. data/spec/suites/rspec_2/spec_helper.rb +2 -26
  46. data/spec/suites/{rspec_2/integration/minitest_4_rails_spec.rb → rspec_2_rails_3/integration/minitest_4_rails_3_spec.rb} +12 -18
  47. data/spec/suites/{rspec_2/integration/test_unit_rails_spec.rb → rspec_2_rails_3/integration/test_unit_200_rails_3_spec.rb} +16 -18
  48. data/spec/suites/{rspec_1/integration/test_unit_2_rails_spec.rb → rspec_2_rails_3/integration/test_unit_2_rails_3_spec.rb} +19 -28
  49. data/spec/suites/rspec_2_rails_3/spec_helper.rb +3 -0
  50. data/spec/suites/{rspec_2/integration/minitest_rails_spec.rb → rspec_2_rails_4/integration/minitest_4_rails_4_spec.rb} +14 -16
  51. data/spec/suites/rspec_2_rails_4/integration/rspec_2_rails_4_spec.rb +156 -0
  52. data/spec/suites/rspec_2_rails_4/integration/test_unit_200_rails_4_spec.rb +66 -0
  53. data/spec/suites/rspec_2_rails_4/integration/test_unit_2_rails_4_spec.rb +66 -0
  54. data/spec/suites/rspec_2_rails_4/spec_helper.rb +3 -0
  55. data/spec/suites/test_unit_1/integration/test_unit_1_test.rb +4 -0
  56. data/spec/suites/test_unit_1/test_helper.rb +4 -1
  57. data/spec/suites/test_unit_2/integration/test_unit_2_test.rb +4 -0
  58. data/spec/suites/test_unit_2/test_helper.rb +5 -2
  59. data/spec/suites/test_unit_200/integration/test_unit_200_test.rb +10 -0
  60. data/spec/suites/test_unit_200/test_helper.rb +6 -0
  61. data/spec/suites/test_unit_200_rails_3/integration/test_unit_200_rails_3_test.rb +10 -0
  62. data/spec/suites/test_unit_200_rails_3/test_helper.rb +7 -0
  63. data/spec/suites/test_unit_200_rails_4/integration/test_unit_200_rails_4_test.rb +10 -0
  64. data/spec/suites/test_unit_200_rails_4/test_helper.rb +7 -0
  65. data/spec/suites/test_unit_2_rails_2/integration/test_unit_2_rails_2_test.rb +10 -0
  66. data/spec/suites/test_unit_2_rails_2/test_helper.rb +7 -0
  67. data/spec/suites/test_unit_2_rails_3/integration/test_unit_2_rails_3_test.rb +10 -0
  68. data/spec/suites/test_unit_2_rails_3/test_helper.rb +7 -0
  69. data/spec/suites/test_unit_2_rails_4/integration/test_unit_2_rails_4_test.rb +10 -0
  70. data/spec/suites/test_unit_2_rails_4/test_helper.rb +7 -0
  71. metadata +71 -19
  72. data/lib/rr/integrations/none.rb +0 -17
data/README.md CHANGED
@@ -164,21 +164,13 @@ Want to contribute a bugfix or new feature to RR? Great! Follow these steps:
164
164
  ### Running test suites
165
165
 
166
166
  In order to test support for multiple Ruby versions and environments, there are
167
- multiple test suites, and Rake tasks to run these suites. Here is the list of
168
- available Rake tasks under Ruby >= 1.9:
167
+ multiple test suites, and Rake tasks to run these suites. The list of available
168
+ Rake tasks depends on which version of Ruby you are under, but you can get the
169
+ full list with:
169
170
 
170
- rake spec:rspec_2
171
- rake spec:minitest
172
- rake spec:test_unit_2
171
+ rake -D spec:
173
172
 
174
- Here is the list under Ruby 1.8:
175
-
176
- rake spec:rspec_1
177
- rake spec:test_unit_2
178
- rake spec:test_unit_1
179
-
180
- As a shortcut, to run all the available suites under the Ruby version you are
181
- on, you can simply say:
173
+ To run all the suites, simply say:
182
174
 
183
175
  rake
184
176
 
@@ -196,19 +188,31 @@ course, the necessary Rubies as well too.
196
188
 
197
189
  ## Compatibility
198
190
 
199
- RR is designed and tested to work against the following test frameworks and Ruby
200
- versions:
191
+ RR is designed and tested to work against the following test frameworks and
192
+ Ruby/Rails versions:
201
193
 
202
194
  | | Ruby 1.8.7-p371 | Ruby 1.9.3-p392 | Ruby 2.0.0-p0 | JRuby 1.7.3 (1.9 mode) |
203
195
  |-----------------------|:---------------:|:---------------:|:-------------:|:----------------------:|
204
- | MiniTest 4.x | | ✓ | ✓ | ✓ |
205
- | Test::Unit (Ruby 1.8) | ✓ | | | |
206
- | Test::Unit (Ruby 1.8) + Rails 2.x | ✓ | | | |
207
- | Test::Unit 2.x || ✓ | ✓ | ✓ |
208
- | Test::Unit 2.x + Rails 2.x | ✓ | | | |
209
- | Test::Unit 2.x + Rails 3.x | ||| ✓ |
210
- | RSpec 1.x | ✓ | | | |
211
- | RSpec 2.x | | ✓ | ✓ | ✓ |
196
+ | MiniTest 4.x | | ✓ | ✓ | ✓ |
197
+ | MiniTest 4.x + Rails 3 | | ✓ |||
198
+ | MiniTest 4.x + Rails 4.0.0.rc1 | | | ✓ ||
199
+ | Minitest 5.x | | ✓ | ✓ | ✓ |
200
+ | Minitest 5.x + Rails 3 | | ✓ |||
201
+ | Test::Unit 1 | | | | |
202
+ | Test::Unit 1 + Rails 2.x | ✓ | | | |
203
+ | Test::Unit 2.0.0 | | ✓ | ✓ | ✓ |
204
+ | Test::Unit 2.0.0 + Rails 3.x | | ✓ | ✓ | ✓ |
205
+ | Test::Unit 2.0.0 + Rails 4.0.0.rc1 | | ✓ | ✓ | ✓ |
206
+ | Test::Unit 2.4.x | ✓ | | | |
207
+ | Test::Unit 2.4.x + Rails 2.x | ✓ | | | |
208
+ | Test::Unit ~> 2.5 | | ✓ | ✓ | ✓ |
209
+ | Test::Unit ~> 2.5 + Rails 3.x | | ✓ | ✓ | ✓ |
210
+ | Test::Unit ~> 2.5 + Rails 4.0.0.rc1 | | ✓ | ✓ | ✓ |
211
+ | RSpec 1.x | ✓ | | | |
212
+ | RSpec 1.x + Rails 2.x | ✓ | | | |
213
+ | RSpec 2.x | | ✓ | ✓ | ✓ |
214
+ | RSpec 2.x + Rails 3.x | | ✓ | ✓ | ✓ |
215
+ | RSpec 2.x + Rails 4.0.0.rc1 | | ✓ | ✓ | ✓ |
212
216
 
213
217
 
214
218
  ## Author/Contact
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1.rc1
data/lib/rr/adapters.rb CHANGED
@@ -17,9 +17,9 @@ module RR
17
17
  adapter = shim_adapters[adapter_const_name] ||=
18
18
  case adapter_const_name
19
19
  when :TestUnit
20
- find_applicable_adapter(:TestUnit1, :TestUnit2ActiveSupport, :TestUnit2)
20
+ RR.find_applicable_adapter_matching(/^TestUnit/)
21
21
  when :MiniTest
22
- find_applicable_adapter(:MinitestActiveSupport, :Minitest, :MiniTest4ActiveSupport, :MiniTest4)
22
+ RR.find_applicable_adapter_matching(/^minitest/i)
23
23
  end
24
24
 
25
25
  adapter
@@ -31,23 +31,6 @@ module RR
31
31
  @shim_adapters ||= {}
32
32
  end
33
33
 
34
- def find_applicable_adapter(*adapter_const_names)
35
- adapter = adapter_const_names.
36
- map { |adapter_const_name| RR::Integrations.build(adapter_const_name) }.
37
- find { |adapter| adapter.applies? }
38
- if adapter
39
- mod = Module.new
40
- (class << mod; self; end).class_eval do
41
- define_method(:included) do |base|
42
- # Note: This assumes that the thing that is including this module
43
- # is the same that the adapter detected and will hook into.
44
- adapter.hook
45
- end
46
- end
47
- mod
48
- end
49
- end
50
-
51
34
  def show_warning_for(adapter_const_name)
52
35
  warn <<EOT
53
36
  --------------------------------------------------------------------------------
data/lib/rr/autohook.rb CHANGED
@@ -1,37 +1,11 @@
1
1
  module RR
2
2
  class << self
3
- ADAPTER_NAMES = [
4
- :RSpec1,
5
- :RSpec2,
6
- :TestUnit1,
7
- :TestUnit2ActiveSupport,
8
- :TestUnit2,
9
- :MiniTest4ActiveSupport,
10
- :MiniTest4,
11
- :MinitestActiveSupport,
12
- :Minitest
13
- ]
14
-
15
3
  def autohook
16
- applicable_adapters.each do |adapter|
17
- puts "Using adapter: #{adapter.name}" if RR.debug?
18
- adapter.hook
4
+ applicable_adapters.each { |adapter| adapter.load }
5
+ if applicable_adapters.empty?
6
+ puts "No adapters matched!" if RR.debug?
19
7
  end
20
8
  end
21
-
22
- private
23
-
24
- def adapters
25
- @adapters ||= ADAPTER_NAMES.map { |adapter_name|
26
- [adapter_name, RR::Integrations.build(adapter_name)]
27
- }
28
- end
29
-
30
- def applicable_adapters
31
- @applicable_adapters ||= adapters.
32
- map { |_, adapter| adapter }.
33
- select { |adapter| adapter.applies? }
34
- end
35
9
  end
36
10
  end
37
11
 
@@ -1,7 +1,49 @@
1
+ require 'set'
2
+
1
3
  module RR
2
4
  module Integrations
3
- def self.build(name)
4
- const_get(name).new
5
+ end
6
+
7
+ def self.register_adapter(klass)
8
+ adapter = Integrations::Decorator.new(klass.new)
9
+ unless adapters_by_name.key?(adapter.name)
10
+ adapters << adapter
11
+ adapters_by_name[adapter.name] = adapter
12
+ end
13
+ end
14
+
15
+ def self.adapters
16
+ @adapters ||= []
17
+ end
18
+
19
+ def self.adapters_by_name
20
+ @adapters_by_name ||= {}
21
+ end
22
+
23
+ def self.loaded_adapter_names
24
+ adapters.
25
+ select { |adapter| adapter.loaded? }.
26
+ map { |adapter| adapter.name }
27
+ end
28
+
29
+ def self.applicable_adapters
30
+ adapters.select { |adapter| adapter.applies? }
31
+ end
32
+
33
+ def self.find_applicable_adapter_matching(pattern)
34
+ adapter = adapters.
35
+ select { |adapter| adapter.name.to_s =~ pattern }.
36
+ find { |adapter| adapter.applies? }
37
+ if adapter
38
+ mod = Module.new
39
+ (class << mod; self; end).class_eval do
40
+ define_method(:included) do |base|
41
+ # Note: This assumes that the thing that is including this module
42
+ # is the same that the adapter detected and will hook into.
43
+ adapter.hook
44
+ end
45
+ end
46
+ mod
5
47
  end
6
48
  end
7
49
  end
@@ -0,0 +1,40 @@
1
+ require 'delegate'
2
+
3
+ module RR
4
+ module Integrations
5
+ class Decorator < SimpleDelegator
6
+ def initialize(adapter)
7
+ super(adapter)
8
+ @loaded = false
9
+ end
10
+
11
+ def name
12
+ __getobj__.class.to_s.split('::').last.to_sym
13
+ end
14
+
15
+ def applies?
16
+ __getobj__.applies?
17
+ rescue => e
18
+ if RR.debug?
19
+ puts "#{__getobj__.class}#applies? failed: #{e.class} (#{e.message})"
20
+ puts e.backtrace.map {|x| " " + x }.join("\n")
21
+ end
22
+ end
23
+
24
+ def load
25
+ hook
26
+ @loaded = true
27
+ puts "Loaded adapter: #{name}" if RR.debug?
28
+ rescue => e
29
+ if RR.debug?
30
+ puts "Couldn't load adapter #{name}: #{e.class} (#{e.message})"
31
+ puts e.backtrace.map {|x| " " + x }.join("\n")
32
+ end
33
+ end
34
+
35
+ def loaded?
36
+ @loaded
37
+ end
38
+ end
39
+ end
40
+ end
@@ -23,5 +23,7 @@ module RR
23
23
  ::Minitest::VERSION
24
24
  end
25
25
  end
26
+
27
+ RR.register_adapter Minitest
26
28
  end
27
29
  end
@@ -62,5 +62,8 @@ module RR
62
62
  end
63
63
  end
64
64
  end
65
+
66
+ RR.register_adapter MiniTest4
65
67
  end
66
68
  end
69
+
@@ -35,5 +35,7 @@ module RR
35
35
  end
36
36
  end
37
37
  end
38
+
39
+ RR.register_adapter MiniTest4ActiveSupport
38
40
  end
39
41
  end
@@ -9,5 +9,7 @@ module RR
9
9
  'Minitest + ActiveSupport'
10
10
  end
11
11
  end
12
+
13
+ RR.register_adapter MinitestActiveSupport
12
14
  end
13
15
  end
@@ -24,7 +24,9 @@ module RR
24
24
  end
25
25
 
26
26
  def applies?
27
- defined?(::Spec)
27
+ defined?(::Spec) &&
28
+ defined?(::Spec::VERSION::STRING) &&
29
+ ::Spec::VERSION::STRING =~ /^1/
28
30
  end
29
31
 
30
32
  def hook
@@ -38,5 +40,7 @@ module RR
38
40
  end
39
41
  end
40
42
  end
43
+
44
+ RR.register_adapter RSpec1
41
45
  end
42
46
  end
@@ -6,7 +6,9 @@ module RR
6
6
  end
7
7
 
8
8
  def applies?
9
- defined?(::RSpec)
9
+ defined?(::RSpec) &&
10
+ defined?(::RSpec::Core::Version::STRING) &&
11
+ ::RSpec::Core::Version::STRING =~ /^2/
10
12
  end
11
13
 
12
14
  def hook
@@ -20,5 +22,7 @@ module RR
20
22
  end
21
23
  end
22
24
  end
25
+
26
+ RR.register_adapter RSpec2
23
27
  end
24
28
  end
@@ -12,7 +12,10 @@ module RR
12
12
  end
13
13
 
14
14
  def applies?
15
- defined?(::Test::Unit) && !has_test_unit_version?
15
+ defined?(::Test::Unit) &&
16
+ defined?(::Test::Unit::TestCase) &&
17
+ !has_test_unit_version? &&
18
+ !test_unit_just_wraps_minitest?
16
19
  end
17
20
 
18
21
  def hook(test_case_class = ::Test::Unit::TestCase)
@@ -41,7 +44,11 @@ module RR
41
44
  end
42
45
  end
43
46
 
44
- private
47
+ def test_unit_just_wraps_minitest?
48
+ defined?(::Test::Unit::TestCase) &&
49
+ defined?(::MiniTest::Unit::TestCase) &&
50
+ ::Test::Unit::TestCase < ::MiniTest::Unit::TestCase
51
+ end
45
52
 
46
53
  def has_test_unit_version?
47
54
  require 'test/unit/version'
@@ -50,5 +57,7 @@ module RR
50
57
  false
51
58
  end
52
59
  end
60
+
61
+ RR.register_adapter TestUnit1
53
62
  end
54
63
  end
@@ -2,12 +2,14 @@ module RR
2
2
  module Integrations
3
3
  class TestUnit2 < TestUnit1
4
4
  def name
5
- 'Test::Unit 2'
5
+ RR.ruby_18? ? 'Test::Unit 2.4.x' : 'Test::Unit >= 2.5'
6
6
  end
7
7
 
8
8
  def applies?
9
9
  defined?(::Test::Unit) && has_test_unit_version?
10
10
  end
11
11
  end
12
+
13
+ RR.register_adapter TestUnit2
12
14
  end
13
15
  end
@@ -0,0 +1,27 @@
1
+ module RR
2
+ module Integrations
3
+ class TestUnit200
4
+ def initialize
5
+ @mt4_adapter = RR.adapters_by_name[:MiniTest4]
6
+ @tu_adapter = RR.adapters_by_name[:TestUnit1]
7
+ end
8
+
9
+ def name
10
+ 'Test::Unit 2.0.0'
11
+ end
12
+
13
+ def applies?
14
+ @mt4_adapter.applies? &&
15
+ defined?(::Test::Unit) &&
16
+ !@tu_adapter.has_test_unit_version? &&
17
+ @tu_adapter.test_unit_just_wraps_minitest?
18
+ end
19
+
20
+ def hook
21
+ @mt4_adapter.hook
22
+ end
23
+ end
24
+
25
+ RR.register_adapter TestUnit200
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ module RR
2
+ module Integrations
3
+ class TestUnit200ActiveSupport
4
+ def initialize
5
+ @mt4as_adapter = RR.adapters_by_name[:MiniTest4ActiveSupport]
6
+ @tu200_adapter = RR.adapters_by_name[:TestUnit200]
7
+ end
8
+
9
+ def name
10
+ "#{@tu200_adapter.name} + ActiveSupport"
11
+ end
12
+
13
+ def applies?
14
+ @tu200_adapter.applies? && defined?(::ActiveSupport::TestCase)
15
+ end
16
+
17
+ def hook
18
+ @mt4as_adapter.hook
19
+ end
20
+ end
21
+
22
+ RR.register_adapter TestUnit200ActiveSupport
23
+ end
24
+ end
25
+
@@ -2,15 +2,16 @@ module RR
2
2
  module Integrations
3
3
  class TestUnit2ActiveSupport
4
4
  def initialize
5
- @tu2_adapter = TestUnit2.new
5
+ @tu2_adapter = RR.adapters_by_name[:TestUnit2]
6
6
  end
7
7
 
8
8
  def name
9
- 'Test::Unit 2 w/ ActiveSupport'
9
+ "#{@tu2_adapter.name} + ActiveSupport"
10
10
  end
11
11
 
12
12
  def applies?
13
- @tu2_adapter.applies? && defined?(::ActiveSupport::TestCase)
13
+ @tu2_adapter.applies? &&
14
+ defined?(::ActiveSupport::TestCase)
14
15
  end
15
16
 
16
17
  def hook
@@ -31,5 +32,7 @@ module RR
31
32
  end
32
33
  end
33
34
  end
35
+
36
+ RR.register_adapter TestUnit2ActiveSupport
34
37
  end
35
38
  end