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
@@ -1,13 +1,13 @@
1
1
  require File.expand_path('../../test_helper', __FILE__)
2
2
  require File.expand_path('../../../common/test_unit_tests', __FILE__)
3
3
 
4
- test_case_superclass = (defined?(Minitest) && defined?(Minitest::VERSION)) ? \
5
- Minitest::Test : \
6
- MiniTest::Unit::TestCase
7
-
8
- class MiniTestIntegrationTest < test_case_superclass
4
+ class MiniTestIntegrationTest < Minitest::Test
9
5
  # Test::Unit compatibility
10
6
  alias_method :assert_raise, :assert_raises
11
7
 
8
+ def applicable_adapter_names
9
+ [:Minitest]
10
+ end
11
+
12
12
  include TestUnitTests
13
13
  end
@@ -1,3 +1,7 @@
1
+ require File.expand_path('../../../global_helper', __FILE__)
2
+ RR::Test.setup_test_suite(:minitest)
3
+
1
4
  require 'minitest/autorun'
2
5
 
3
- require File.expand_path('../../../global_helper', __FILE__)
6
+ require 'rr'
7
+
@@ -0,0 +1,13 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+ require File.expand_path('../../../common/test_unit_tests', __FILE__)
3
+
4
+ class MiniTestIntegrationTest < MiniTest::Unit::TestCase
5
+ # Test::Unit compatibility
6
+ alias_method :assert_raise, :assert_raises
7
+
8
+ def applicable_adapter_names
9
+ [:MiniTest4]
10
+ end
11
+
12
+ include TestUnitTests
13
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path('../../../global_helper', __FILE__)
2
+ RR::Test.setup_test_suite(:minitest_4)
3
+
4
+ require 'minitest/autorun'
5
+
6
+ require 'rr'
7
+
@@ -0,0 +1,24 @@
1
+ require 'spec/autorun'
2
+
3
+ require 'rr'
4
+
5
+ module ExampleMethods
6
+ def eigen(object)
7
+ class << object; self; end
8
+ end
9
+ end
10
+
11
+ module ExampleGroupMethods
12
+ def macro(name, &implementation)
13
+ (class << self; self; end).class_eval do
14
+ define_method(name, &implementation)
15
+ end
16
+ end
17
+ end
18
+
19
+ Spec::Runner.configure do |c|
20
+ c.include ExampleMethods
21
+ c.extend ExampleGroupMethods
22
+ end
23
+
24
+ Dir[ File.expand_path('../shared/*.rb', __FILE__) ].each {|fn| require fn }
@@ -3,15 +3,6 @@ require File.expand_path('../../../common/adapter_tests', __FILE__)
3
3
  require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
4
4
 
5
5
  describe 'Integration with RSpec 1' do
6
- include AdapterTests
7
- instance_methods.each do |method_name|
8
- if method_name =~ /^test_(.+)$/
9
- it(method_name) { __send__(method_name) }
10
- end
11
- end
12
-
13
- include AdapterIntegrationTests
14
-
15
6
  def assert_equal(expected, actual)
16
7
  actual.should be == expected
17
8
  end
@@ -20,14 +11,20 @@ describe 'Integration with RSpec 1' do
20
11
  expect(&block).to raise_error(error, message)
21
12
  end
22
13
 
14
+ def adapter_name
15
+ 'rspec_1'
16
+ end
17
+
18
+ def applicable_adapter_names
19
+ [:RSpec1]
20
+ end
21
+
23
22
  def test_framework_path
24
23
  'spec/autorun'
25
24
  end
26
25
 
27
26
  def error_test
28
- <<-EOT
29
- #{bootstrap}
30
-
27
+ with_bootstrap <<-EOT
31
28
  describe 'A test' do
32
29
  it 'is a test' do
33
30
  object = Object.new
@@ -38,9 +35,7 @@ describe 'Integration with RSpec 1' do
38
35
  end
39
36
 
40
37
  def include_adapter_test
41
- <<-EOT
42
- #{bootstrap}
43
-
38
+ with_bootstrap <<-EOT
44
39
  Spec::Runner.configure do |c|
45
40
  c.mock_with :rr
46
41
  end
@@ -56,9 +51,7 @@ describe 'Integration with RSpec 1' do
56
51
  end
57
52
 
58
53
  def include_adapter_where_rr_included_before_test_framework_test
59
- <<-EOT
60
- #{bootstrap :include_rr_before => true}
61
-
54
+ with_bootstrap <<-EOT, :include_rr_before_test_framework => true
62
55
  Spec::Runner.configure do |c|
63
56
  c.mock_with :rr
64
57
  end
@@ -72,4 +65,13 @@ describe 'Integration with RSpec 1' do
72
65
  end
73
66
  EOT
74
67
  end
68
+
69
+ include AdapterTests
70
+ instance_methods.each do |method_name|
71
+ if method_name =~ /^test_(.+)$/
72
+ it(method_name) { __send__(method_name) }
73
+ end
74
+ end
75
+
76
+ include AdapterIntegrationTests
75
77
  end
@@ -1,21 +1,17 @@
1
1
  require File.expand_path('../../spec_helper', __FILE__)
2
2
  require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
3
3
 
4
- describe 'Test::Unit 1 integration' do
5
- include AdapterIntegrationTests
4
+ describe 'Integration with Test::Unit 1' do
5
+ def adapter_name
6
+ 'test_unit_1'
7
+ end
6
8
 
7
- def bootstrap
8
- <<-EOT
9
- require 'test/unit'
10
- require 'rubygems'
11
- require 'rr'
12
- EOT
9
+ def test_framework_path
10
+ 'test/unit'
13
11
  end
14
12
 
15
13
  def error_test
16
- <<-EOT
17
- #{bootstrap}
18
-
14
+ with_bootstrap <<-EOT
19
15
  class FooTest < Test::Unit::TestCase
20
16
  def test_foo
21
17
  object = Object.new
@@ -26,9 +22,7 @@ describe 'Test::Unit 1 integration' do
26
22
  end
27
23
 
28
24
  def include_adapter_test
29
- <<-EOT
30
- #{bootstrap}
31
-
25
+ with_bootstrap <<-EOT
32
26
  class Test::Unit::TestCase
33
27
  include RR::Adapters::TestUnit
34
28
  end
@@ -42,4 +36,6 @@ describe 'Test::Unit 1 integration' do
42
36
  end
43
37
  EOT
44
38
  end
39
+
40
+ include AdapterIntegrationTests
45
41
  end
@@ -1,22 +1,17 @@
1
1
  require File.expand_path('../../spec_helper', __FILE__)
2
2
  require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
3
3
 
4
- describe 'Test::Unit 2 integration' do
5
- include AdapterIntegrationTests
4
+ describe 'Integration with Test::Unit 2.4.x' do
5
+ def adapter_name
6
+ 'test_unit_2'
7
+ end
6
8
 
7
- def bootstrap(opts={})
8
- str = ""
9
- str << "require 'rubygems'\n"
10
- str << "require 'rr'\n" if opts[:include_rr_before]
11
- str << "require 'test/unit'\n"
12
- str << "require 'rr'\n" unless opts[:include_rr_before]
13
- str
9
+ def test_framework_path
10
+ 'test/unit'
14
11
  end
15
12
 
16
13
  def error_test
17
- <<-EOT
18
- #{bootstrap}
19
-
14
+ with_bootstrap <<-EOT
20
15
  class FooTest < Test::Unit::TestCase
21
16
  def test_foo
22
17
  object = Object.new
@@ -27,9 +22,7 @@ describe 'Test::Unit 2 integration' do
27
22
  end
28
23
 
29
24
  def include_adapter_test
30
- <<-EOT
31
- #{bootstrap}
32
-
25
+ with_bootstrap <<-EOT
33
26
  class Test::Unit::TestCase
34
27
  include RR::Adapters::TestUnit
35
28
  end
@@ -45,9 +38,7 @@ describe 'Test::Unit 2 integration' do
45
38
  end
46
39
 
47
40
  def include_adapter_where_rr_included_before_test_framework_test
48
- <<-EOT
49
- #{bootstrap :include_rr_before => true}
50
-
41
+ with_bootstrap <<-EOT, :include_rr_before => true
51
42
  class Test::Unit::TestCase
52
43
  include RR::Adapters::TestUnit
53
44
  end
@@ -61,4 +52,6 @@ describe 'Test::Unit 2 integration' do
61
52
  end
62
53
  EOT
63
54
  end
55
+
56
+ include AdapterIntegrationTests
64
57
  end
@@ -1,24 +1,3 @@
1
- require 'spec/autorun'
2
-
3
1
  require File.expand_path('../../../global_helper', __FILE__)
4
-
5
- module ExampleMethods
6
- def eigen(object)
7
- class << object; self; end
8
- end
9
- end
10
-
11
- module ExampleGroupMethods
12
- def macro(name, &implementation)
13
- (class << self; self; end).class_eval do
14
- define_method(name, &implementation)
15
- end
16
- end
17
- end
18
-
19
- Spec::Runner.configure do |c|
20
- c.include ExampleMethods
21
- c.extend ExampleGroupMethods
22
- end
23
-
24
- Dir[ File.expand_path('../shared/*.rb', __FILE__) ].each {|fn| require fn }
2
+ RR::Test.setup_test_suite(:rspec_1)
3
+ require File.expand_path('../helper', __FILE__)
@@ -1,30 +1,28 @@
1
1
  require File.expand_path('../../spec_helper', __FILE__)
2
2
  require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
3
- require File.expand_path('../../../common/rails_integration_test', __FILE__)
3
+ require File.expand_path('../../../common/rails_integration_tests', __FILE__)
4
4
 
5
- describe 'Integration between TestUnit 1 and Rails' do
6
- include AdapterIntegrationTests
7
- include IntegrationWithRails
5
+ describe 'Integration with Test::Unit 1 and Rails 2' do
6
+ def adapter_name
7
+ 'test_unit_1_rails_2'
8
+ end
9
+
10
+ def test_framework_path
11
+ 'test/unit'
12
+ end
8
13
 
9
- def bootstrap
14
+ def before_require_test_framework
10
15
  <<-EOT
11
16
  RAILS_ROOT = File.expand_path(__FILE__)
12
- require 'test/unit'
13
-
14
- require 'rubygems'
15
17
  require 'rack'
16
18
  require 'active_support/all'
17
19
  require 'action_controller'
18
20
  require 'active_support/test_case'
19
-
20
- require 'rr'
21
21
  EOT
22
22
  end
23
23
 
24
24
  def error_test
25
- <<-EOT
26
- #{bootstrap}
27
-
25
+ with_bootstrap <<-EOT
28
26
  class FooTest < ActiveSupport::TestCase
29
27
  def test_foo
30
28
  object = Object.new
@@ -35,9 +33,7 @@ describe 'Integration between TestUnit 1 and Rails' do
35
33
  end
36
34
 
37
35
  def include_adapter_test
38
- <<-EOT
39
- #{bootstrap}
40
-
36
+ with_bootstrap <<-EOT
41
37
  class ActiveSupport::TestCase
42
38
  include RR::Adapters::TestUnit
43
39
  end
@@ -51,4 +47,7 @@ describe 'Integration between TestUnit 1 and Rails' do
51
47
  end
52
48
  EOT
53
49
  end
50
+
51
+ include AdapterIntegrationTests
52
+ include RailsIntegrationTests
54
53
  end
@@ -0,0 +1,57 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+ require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
3
+ require File.expand_path('../../../common/rails_integration_tests', __FILE__)
4
+
5
+ describe 'Integration with Test::Unit 2.4.x and Rails 2' do
6
+ def adapter_name
7
+ 'test_unit_2_rails_2'
8
+ end
9
+
10
+ def test_framework_path
11
+ 'test/unit'
12
+ end
13
+
14
+ def before_require_test_framework
15
+ <<-EOT
16
+ RAILS_ROOT = File.expand_path(__FILE__)
17
+ require 'rack'
18
+ require 'active_support/all'
19
+ require 'action_controller'
20
+ require 'active_support/test_case'
21
+ EOT
22
+ end
23
+
24
+ def error_test
25
+ with_bootstrap <<-EOT
26
+ class ActiveSupport::TestCase
27
+ include RR::Adapters::TestUnit
28
+ end
29
+
30
+ class FooTest < ActiveSupport::TestCase
31
+ def test_foo
32
+ object = Object.new
33
+ mock(object).foo
34
+ end
35
+ end
36
+ EOT
37
+ end
38
+
39
+ def include_adapter_where_rr_included_before_test_framework_test
40
+ with_bootstrap <<-EOT, :include_rr_before_test_framework => true
41
+ class ActiveSupport::TestCase
42
+ include RR::Adapters::TestUnit
43
+ end
44
+
45
+ class FooTest < ActiveSupport::TestCase
46
+ def test_foo
47
+ object = Object.new
48
+ mock(object).foo
49
+ object.foo
50
+ end
51
+ end
52
+ EOT
53
+ end
54
+
55
+ include AdapterIntegrationTests
56
+ include RailsIntegrationTests
57
+ end
@@ -0,0 +1,3 @@
1
+ require File.expand_path('../../../global_helper', __FILE__)
2
+ RR::Test.setup_test_suite(:rspec_1_rails_2)
3
+ require File.expand_path('../../rspec_1/helper', __FILE__)
@@ -0,0 +1,27 @@
1
+ require 'rspec/core'
2
+ require 'rspec/expectations'
3
+ require 'rspec/autorun'
4
+
5
+ require 'rr'
6
+
7
+ module ExampleMethods
8
+ def eigen(object)
9
+ class << object; self; end
10
+ end
11
+ end
12
+
13
+ module ExampleGroupMethods
14
+ def macro(name, &implementation)
15
+ (class << self; self; end).class_eval do
16
+ define_method(name, &implementation)
17
+ end
18
+ end
19
+ end
20
+
21
+ RSpec.configure do |c|
22
+ c.include ExampleMethods
23
+ c.extend ExampleGroupMethods
24
+ end
25
+
26
+ Dir[ File.expand_path('../shared/*.rb', __FILE__) ].each {|fn| require fn }
27
+ Dir[ File.expand_path('../support/**/*.rb', __FILE__) ].each {|fn| require fn }
@@ -1,15 +1,17 @@
1
1
  require File.expand_path('../../spec_helper', __FILE__)
2
2
  require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
3
3
 
4
- describe 'MiniTest 4 integration' do
4
+ describe 'Integration with MiniTest 4' do
5
5
  def adapter_name
6
6
  'minitest_4'
7
7
  end
8
8
 
9
- def error_test
10
- <<-EOT
11
- #{bootstrap}
9
+ def test_framework_path
10
+ 'minitest/autorun'
11
+ end
12
12
 
13
+ def error_test
14
+ with_bootstrap <<-EOT
13
15
  class FooTest < MiniTest::Unit::TestCase
14
16
  def test_foo
15
17
  object = Object.new
@@ -20,9 +22,7 @@ describe 'MiniTest 4 integration' do
20
22
  end
21
23
 
22
24
  def include_adapter_test
23
- <<-EOT
24
- #{bootstrap}
25
-
25
+ with_bootstrap <<-EOT
26
26
  class MiniTest::Unit::TestCase
27
27
  include RR::Adapters::MiniTest
28
28
  end
@@ -38,9 +38,7 @@ describe 'MiniTest 4 integration' do
38
38
  end
39
39
 
40
40
  def include_adapter_where_rr_included_before_test_framework_test
41
- <<-EOT
42
- #{bootstrap :include_rr_before => true}
43
-
41
+ with_bootstrap <<-EOT, :include_rr_before_test_framework => true
44
42
  class MiniTest::Unit::TestCase
45
43
  include RR::Adapters::MiniTest
46
44
  end
@@ -56,12 +54,4 @@ describe 'MiniTest 4 integration' do
56
54
  end
57
55
 
58
56
  include AdapterIntegrationTests
59
-
60
- def adapter_name
61
- 'minitest_4'
62
- end
63
-
64
- def test_framework_path
65
- 'minitest/autorun'
66
- end
67
57
  end