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,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 integration' do
4
+ describe 'Integration with Minitest >= 5' do
5
+ def adapter_name
6
+ 'minitest'
7
+ end
8
+
5
9
  def test_framework_path
6
10
  'minitest/autorun'
7
11
  end
8
12
 
9
13
  def error_test
10
- <<-EOT
11
- #{bootstrap}
12
-
14
+ with_bootstrap <<-EOT
13
15
  class FooTest < Minitest::Test
14
16
  def test_foo
15
17
  object = Object.new
@@ -20,9 +22,7 @@ describe 'MiniTest 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::Test
27
27
  include RR::Adapters::MiniTest
28
28
  end
@@ -38,9 +38,7 @@ describe 'MiniTest 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 => true
44
42
  class Minitest::Test
45
43
  include RR::Adapters::MiniTest
46
44
  end
@@ -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 2' 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
  expect(actual).to eq actual
17
8
  end
@@ -20,14 +11,20 @@ describe 'Integration with RSpec 2' do
20
11
  expect(&block).to raise_error(error, message)
21
12
  end
22
13
 
14
+ def adapter_name
15
+ 'rspec_2'
16
+ end
17
+
18
+ def applicable_adapter_names
19
+ [:RSpec2]
20
+ end
21
+
23
22
  def test_framework_path
24
23
  'rspec/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 2' do
38
35
  end
39
36
 
40
37
  def include_adapter_test
41
- <<-EOT
42
- #{bootstrap}
43
-
38
+ with_bootstrap <<-EOT
44
39
  RSpec.configure do |c|
45
40
  c.mock_with :rr
46
41
  end
@@ -56,9 +51,7 @@ describe 'Integration with RSpec 2' 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
  RSpec.configure do |c|
63
56
  c.mock_with :rr
64
57
  end
@@ -74,9 +67,7 @@ describe 'Integration with RSpec 2' do
74
67
  end
75
68
 
76
69
  specify "it is still possible to use a custom RSpec-2 adapter" do
77
- output = run_fixture_tests <<-EOT
78
- #{bootstrap}
79
-
70
+ suite = with_bootstrap <<-EOT
80
71
  module RR
81
72
  module Adapters
82
73
  module RSpec2
@@ -120,6 +111,16 @@ describe 'Integration with RSpec 2' do
120
111
  end
121
112
  end
122
113
  EOT
114
+ output = run_fixture_tests(suite)
123
115
  all_tests_should_pass(output)
124
116
  end
117
+
118
+ include AdapterTests
119
+ instance_methods.each do |method_name|
120
+ if method_name =~ /^test_(.+)$/
121
+ it(method_name) { __send__(method_name) }
122
+ end
123
+ end
124
+
125
+ include AdapterIntegrationTests
125
126
  end
@@ -0,0 +1,57 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+ require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
3
+
4
+ describe 'Integration with Test::Unit 2.0.0' do
5
+ def adapter_name
6
+ 'test_unit_200'
7
+ end
8
+
9
+ def test_framework_path
10
+ 'test/unit'
11
+ end
12
+
13
+ def error_test
14
+ with_bootstrap <<-EOT
15
+ class FooTest < Test::Unit::TestCase
16
+ def test_foo
17
+ object = Object.new
18
+ mock(object).foo
19
+ end
20
+ end
21
+ EOT
22
+ end
23
+
24
+ def include_adapter_test
25
+ with_bootstrap <<-EOT
26
+ class Test::Unit::TestCase
27
+ include RR::Adapters::TestUnit
28
+ end
29
+
30
+ class FooTest < Test::Unit::TestCase
31
+ def test_foo
32
+ object = Object.new
33
+ mock(object).foo
34
+ object.foo
35
+ end
36
+ end
37
+ EOT
38
+ end
39
+
40
+ def include_adapter_where_rr_included_before_test_framework_test
41
+ with_bootstrap <<-EOT, :include_rr_before_test_framework => true
42
+ class Test::Unit::TestCase
43
+ include RR::Adapters::TestUnit
44
+ end
45
+
46
+ class FooTest < Test::Unit::TestCase
47
+ def test_foo
48
+ object = Object.new
49
+ mock(object).foo
50
+ object.foo
51
+ end
52
+ end
53
+ EOT
54
+ end
55
+
56
+ include AdapterIntegrationTests
57
+ end
@@ -1,17 +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 'TestUnit integration' do
5
- include AdapterIntegrationTests
4
+ describe 'Integration with Test::Unit >= 2.5' do
5
+ def adapter_name
6
+ 'test_unit_2'
7
+ end
6
8
 
7
9
  def test_framework_path
8
10
  'test/unit'
9
11
  end
10
12
 
11
13
  def error_test
12
- <<-EOT
13
- #{bootstrap}
14
-
14
+ with_bootstrap <<-EOT
15
15
  class FooTest < Test::Unit::TestCase
16
16
  def test_foo
17
17
  object = Object.new
@@ -22,9 +22,7 @@ describe 'TestUnit integration' do
22
22
  end
23
23
 
24
24
  def include_adapter_test
25
- <<-EOT
26
- #{bootstrap}
27
-
25
+ with_bootstrap <<-EOT
28
26
  class Test::Unit::TestCase
29
27
  include RR::Adapters::TestUnit
30
28
  end
@@ -40,9 +38,7 @@ describe 'TestUnit integration' do
40
38
  end
41
39
 
42
40
  def include_adapter_where_rr_included_before_test_framework_test
43
- <<-EOT
44
- #{bootstrap :include_rr_before => true}
45
-
41
+ with_bootstrap <<-EOT, :include_rr_before_test_framework => true
46
42
  class Test::Unit::TestCase
47
43
  include RR::Adapters::TestUnit
48
44
  end
@@ -56,4 +52,6 @@ describe 'TestUnit integration' do
56
52
  end
57
53
  EOT
58
54
  end
55
+
56
+ include AdapterIntegrationTests
59
57
  end
@@ -1,27 +1,3 @@
1
- require 'rspec/core'
2
- require 'rspec/expectations'
3
- require 'rspec/autorun'
4
-
5
1
  require File.expand_path('../../../global_helper', __FILE__)
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 }
2
+ RR::Test.setup_test_suite(:rspec_2)
3
+ require File.expand_path('../helper', __FILE__)
@@ -1,27 +1,25 @@
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 MiniTest 4 and Rails' do
5
+ describe 'Integration with MiniTest 4 and Rails 3' do
6
6
  def adapter_name
7
- 'minitest_4'
7
+ 'minitest_4_rails_3'
8
8
  end
9
9
 
10
- def additional_bootstrap
10
+ def test_framework_path
11
+ 'minitest/autorun'
12
+ end
13
+
14
+ def before_require_test_framework
11
15
  <<-EOT
12
16
  require 'rails'
13
17
  require 'active_support'
14
18
  EOT
15
19
  end
16
20
 
17
- def test_framework_path
18
- 'minitest/autorun'
19
- end
20
-
21
21
  def error_test
22
- <<-EOT
23
- #{bootstrap}
24
-
22
+ with_bootstrap <<-EOT
25
23
  class FooTest < ActiveSupport::TestCase
26
24
  def test_foo
27
25
  object = Object.new
@@ -32,9 +30,7 @@ describe 'Integration between MiniTest 4 and Rails' do
32
30
  end
33
31
 
34
32
  def include_adapter_test
35
- <<-EOT
36
- #{bootstrap}
37
-
33
+ with_bootstrap <<-EOT
38
34
  class ActiveSupport::TestCase
39
35
  include RR::Adapters::MiniTest
40
36
  end
@@ -50,9 +46,7 @@ describe 'Integration between MiniTest 4 and Rails' do
50
46
  end
51
47
 
52
48
  def include_adapter_where_rr_included_before_test_framework_test
53
- <<-EOT
54
- #{bootstrap :include_rr_before => true}
55
-
49
+ with_bootstrap <<-EOT, :include_rr_before_test_framework => true
56
50
  class ActiveSupport::TestCase
57
51
  include RR::Adapters::MiniTest
58
52
  end
@@ -68,5 +62,5 @@ describe 'Integration between MiniTest 4 and Rails' do
68
62
  end
69
63
 
70
64
  include AdapterIntegrationTests
71
- include IntegrationWithRails
65
+ include RailsIntegrationTests
72
66
  end
@@ -1,26 +1,25 @@
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 and Rails' do
6
- include AdapterIntegrationTests
7
- include IntegrationWithRails
8
-
9
- def additional_bootstrap
10
- <<-EOT
11
- require 'rails'
12
- require 'active_support'
13
- EOT
5
+ describe 'Integration with Test::Unit 2.0.0 and Rails 3' do
6
+ def adapter_name
7
+ 'test_unit_2_rails_3'
14
8
  end
15
9
 
16
10
  def test_framework_path
17
11
  'test/unit'
18
12
  end
19
13
 
20
- def error_test
14
+ def before_require_test_framework
21
15
  <<-EOT
22
- #{bootstrap}
16
+ require 'rails'
17
+ require 'active_support'
18
+ EOT
19
+ end
23
20
 
21
+ def error_test
22
+ with_bootstrap <<-EOT
24
23
  class FooTest < ActiveSupport::TestCase
25
24
  def test_foo
26
25
  object = Object.new
@@ -31,9 +30,7 @@ describe 'Integration between TestUnit and Rails' do
31
30
  end
32
31
 
33
32
  def include_adapter_test
34
- <<-EOT
35
- #{bootstrap}
36
-
33
+ with_bootstrap <<-EOT
37
34
  class ActiveSupport::TestCase
38
35
  include RR::Adapters::TestUnit
39
36
  end
@@ -49,9 +46,7 @@ describe 'Integration between TestUnit and Rails' do
49
46
  end
50
47
 
51
48
  def include_adapter_where_rr_included_before_test_framework_test
52
- <<-EOT
53
- #{bootstrap :include_rr_before => true}
54
-
49
+ with_bootstrap <<-EOT, :include_rr_before => true
55
50
  class ActiveSupport::TestCase
56
51
  include RR::Adapters::TestUnit
57
52
  end
@@ -65,4 +60,7 @@ describe 'Integration between TestUnit and Rails' do
65
60
  end
66
61
  EOT
67
62
  end
63
+
64
+ include AdapterIntegrationTests
65
+ include RailsIntegrationTests
68
66
  end
@@ -1,33 +1,25 @@
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 2 and Rails' do
6
- include AdapterIntegrationTests
7
- include IntegrationWithRails
5
+ describe 'Integration with Test::Unit >= 2.5 and Rails 3' do
6
+ def adapter_name
7
+ 'test_unit_2_rails_3'
8
+ end
8
9
 
9
- def bootstrap(opts={})
10
- str = ""
11
- str << <<-EOT
12
- RAILS_ROOT = File.expand_path(__FILE__)
13
- require 'rubygems'
14
- EOT
15
- str << "require 'rr'\n" if opts[:include_rr_before]
16
- str << <<-EOT
17
- require 'rack'
18
- require 'test/unit'
19
- require 'active_support/all'
20
- require 'action_controller'
21
- require 'active_support/test_case'
22
- EOT
23
- str << "require 'rr'\n" unless opts[:include_rr_before]
24
- str
10
+ def test_framework_path
11
+ 'test/unit'
25
12
  end
26
13
 
27
- def error_test
14
+ def before_require_test_framework
28
15
  <<-EOT
29
- #{bootstrap}
16
+ require 'rails'
17
+ require 'active_support'
18
+ EOT
19
+ end
30
20
 
21
+ def error_test
22
+ with_bootstrap <<-EOT
31
23
  class FooTest < ActiveSupport::TestCase
32
24
  def test_foo
33
25
  object = Object.new
@@ -38,9 +30,7 @@ describe 'Integration between TestUnit 2 and Rails' do
38
30
  end
39
31
 
40
32
  def include_adapter_test
41
- <<-EOT
42
- #{bootstrap}
43
-
33
+ with_bootstrap <<-EOT
44
34
  class ActiveSupport::TestCase
45
35
  include RR::Adapters::TestUnit
46
36
  end
@@ -56,9 +46,7 @@ describe 'Integration between TestUnit 2 and Rails' do
56
46
  end
57
47
 
58
48
  def include_adapter_where_rr_included_before_test_framework_test
59
- <<-EOT
60
- #{bootstrap :include_rr_before => true}
61
-
49
+ with_bootstrap <<-EOT, :include_rr_before => true
62
50
  class ActiveSupport::TestCase
63
51
  include RR::Adapters::TestUnit
64
52
  end
@@ -72,4 +60,7 @@ describe 'Integration between TestUnit 2 and Rails' do
72
60
  end
73
61
  EOT
74
62
  end
63
+
64
+ include AdapterIntegrationTests
65
+ include RailsIntegrationTests
75
66
  end