rr 1.1.1.rc1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/CREDITS.md +61 -0
  3. data/VERSION +1 -1
  4. data/doc/01_test_double.md +16 -0
  5. data/doc/02_syntax_comparison.md +96 -0
  6. data/doc/03_api_overview.md +616 -0
  7. data/rr.gemspec +6 -6
  8. metadata +12 -230
  9. data/spec/global_helper.rb +0 -53
  10. data/spec/spec.opts +0 -2
  11. data/spec/suite.rb +0 -107
  12. data/spec/suites/common/adapter_integration_tests.rb +0 -160
  13. data/spec/suites/common/adapter_tests.rb +0 -43
  14. data/spec/suites/common/rails_integration_tests.rb +0 -106
  15. data/spec/suites/common/test_unit_tests.rb +0 -21
  16. data/spec/suites/minitest/integration/minitest_test.rb +0 -13
  17. data/spec/suites/minitest/test_helper.rb +0 -7
  18. data/spec/suites/minitest_4/integration/minitest_test.rb +0 -13
  19. data/spec/suites/minitest_4/test_helper.rb +0 -7
  20. data/spec/suites/rspec_1/helper.rb +0 -24
  21. data/spec/suites/rspec_1/integration/rspec_1_spec.rb +0 -77
  22. data/spec/suites/rspec_1/integration/test_unit_1_spec.rb +0 -41
  23. data/spec/suites/rspec_1/integration/test_unit_2_spec.rb +0 -57
  24. data/spec/suites/rspec_1/spec_helper.rb +0 -3
  25. data/spec/suites/rspec_1_rails_2/integration/test_unit_1_rails_2_spec.rb +0 -53
  26. data/spec/suites/rspec_1_rails_2/integration/test_unit_2_rails_2_spec.rb +0 -57
  27. data/spec/suites/rspec_1_rails_2/spec_helper.rb +0 -3
  28. data/spec/suites/rspec_2/functional/any_instance_of_spec.rb +0 -47
  29. data/spec/suites/rspec_2/functional/dont_allow_spec.rb +0 -12
  30. data/spec/suites/rspec_2/functional/dsl_spec.rb +0 -13
  31. data/spec/suites/rspec_2/functional/instance_of_spec.rb +0 -14
  32. data/spec/suites/rspec_2/functional/mock_spec.rb +0 -241
  33. data/spec/suites/rspec_2/functional/proxy_spec.rb +0 -136
  34. data/spec/suites/rspec_2/functional/spy_spec.rb +0 -41
  35. data/spec/suites/rspec_2/functional/strong_spec.rb +0 -79
  36. data/spec/suites/rspec_2/functional/stub_spec.rb +0 -190
  37. data/spec/suites/rspec_2/functional/wildcard_matchers_spec.rb +0 -128
  38. data/spec/suites/rspec_2/helper.rb +0 -27
  39. data/spec/suites/rspec_2/integration/minitest_4_spec.rb +0 -57
  40. data/spec/suites/rspec_2/integration/minitest_spec.rb +0 -57
  41. data/spec/suites/rspec_2/integration/rspec_2_spec.rb +0 -126
  42. data/spec/suites/rspec_2/integration/test_unit_200_spec.rb +0 -57
  43. data/spec/suites/rspec_2/integration/test_unit_2_spec.rb +0 -57
  44. data/spec/suites/rspec_2/spec_helper.rb +0 -3
  45. data/spec/suites/rspec_2/support/matchers/wildcard_matcher_matchers.rb +0 -32
  46. data/spec/suites/rspec_2/support/shared_examples/space.rb +0 -13
  47. data/spec/suites/rspec_2/support/shared_examples/times_called_expectation.rb +0 -9
  48. data/spec/suites/rspec_2/unit/adapters/rr_methods/double_creators_spec.rb +0 -135
  49. data/spec/suites/rspec_2/unit/adapters/rr_methods/space_spec.rb +0 -101
  50. data/spec/suites/rspec_2/unit/adapters/rr_methods/wildcard_matchers_spec.rb +0 -69
  51. data/spec/suites/rspec_2/unit/core_ext/array_spec.rb +0 -39
  52. data/spec/suites/rspec_2/unit/core_ext/enumerable_spec.rb +0 -81
  53. data/spec/suites/rspec_2/unit/core_ext/hash_spec.rb +0 -55
  54. data/spec/suites/rspec_2/unit/core_ext/range_spec.rb +0 -41
  55. data/spec/suites/rspec_2/unit/core_ext/regexp_spec.rb +0 -41
  56. data/spec/suites/rspec_2/unit/double_definitions/child_double_definition_create_spec.rb +0 -114
  57. data/spec/suites/rspec_2/unit/double_definitions/double_definition_create_blank_slate_spec.rb +0 -93
  58. data/spec/suites/rspec_2/unit/double_definitions/double_definition_create_spec.rb +0 -446
  59. data/spec/suites/rspec_2/unit/errors/rr_error_spec.rb +0 -67
  60. data/spec/suites/rspec_2/unit/expectations/any_argument_expectation_spec.rb +0 -48
  61. data/spec/suites/rspec_2/unit/expectations/anything_argument_equality_expectation_spec.rb +0 -14
  62. data/spec/suites/rspec_2/unit/expectations/argument_equality_expectation_spec.rb +0 -135
  63. data/spec/suites/rspec_2/unit/expectations/boolean_argument_equality_expectation_spec.rb +0 -30
  64. data/spec/suites/rspec_2/unit/expectations/hash_including_argument_equality_expectation_spec.rb +0 -82
  65. data/spec/suites/rspec_2/unit/expectations/satisfy_argument_equality_expectation_spec.rb +0 -61
  66. data/spec/suites/rspec_2/unit/expectations/times_called_expectation/any_times_matcher_spec.rb +0 -22
  67. data/spec/suites/rspec_2/unit/expectations/times_called_expectation/at_least_matcher_spec.rb +0 -37
  68. data/spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb +0 -43
  69. data/spec/suites/rspec_2/unit/expectations/times_called_expectation/integer_matcher_spec.rb +0 -58
  70. data/spec/suites/rspec_2/unit/expectations/times_called_expectation/proc_matcher_spec.rb +0 -35
  71. data/spec/suites/rspec_2/unit/expectations/times_called_expectation/range_matcher_spec.rb +0 -39
  72. data/spec/suites/rspec_2/unit/hash_with_object_id_key_spec.rb +0 -88
  73. data/spec/suites/rspec_2/unit/injections/double_injection/double_injection_spec.rb +0 -545
  74. data/spec/suites/rspec_2/unit/injections/double_injection/double_injection_verify_spec.rb +0 -32
  75. data/spec/suites/rspec_2/unit/integrations/rspec/invocation_matcher_spec.rb +0 -297
  76. data/spec/suites/rspec_2/unit/integrations/rspec_spec.rb +0 -85
  77. data/spec/suites/rspec_2/unit/proc_from_block_spec.rb +0 -14
  78. data/spec/suites/rspec_2/unit/rr_spec.rb +0 -28
  79. data/spec/suites/rspec_2/unit/space_spec.rb +0 -595
  80. data/spec/suites/rspec_2/unit/spy_verification_spec.rb +0 -133
  81. data/spec/suites/rspec_2/unit/times_called_matchers/any_times_matcher_spec.rb +0 -46
  82. data/spec/suites/rspec_2/unit/times_called_matchers/at_least_matcher_spec.rb +0 -54
  83. data/spec/suites/rspec_2/unit/times_called_matchers/at_most_matcher_spec.rb +0 -69
  84. data/spec/suites/rspec_2/unit/times_called_matchers/integer_matcher_spec.rb +0 -69
  85. data/spec/suites/rspec_2/unit/times_called_matchers/proc_matcher_spec.rb +0 -54
  86. data/spec/suites/rspec_2/unit/times_called_matchers/range_matcher_spec.rb +0 -75
  87. data/spec/suites/rspec_2/unit/times_called_matchers/times_called_matcher_spec.rb +0 -117
  88. data/spec/suites/rspec_2/unit/wildcard_matchers/anything_spec.rb +0 -33
  89. data/spec/suites/rspec_2/unit/wildcard_matchers/boolean_spec.rb +0 -45
  90. data/spec/suites/rspec_2/unit/wildcard_matchers/duck_type_spec.rb +0 -64
  91. data/spec/suites/rspec_2/unit/wildcard_matchers/hash_including_spec.rb +0 -64
  92. data/spec/suites/rspec_2/unit/wildcard_matchers/is_a_spec.rb +0 -55
  93. data/spec/suites/rspec_2/unit/wildcard_matchers/numeric_spec.rb +0 -46
  94. data/spec/suites/rspec_2/unit/wildcard_matchers/satisfy_spec.rb +0 -57
  95. data/spec/suites/rspec_2_rails_3/integration/minitest_4_rails_3_spec.rb +0 -66
  96. data/spec/suites/rspec_2_rails_3/integration/test_unit_200_rails_3_spec.rb +0 -66
  97. data/spec/suites/rspec_2_rails_3/integration/test_unit_2_rails_3_spec.rb +0 -66
  98. data/spec/suites/rspec_2_rails_3/spec_helper.rb +0 -3
  99. data/spec/suites/rspec_2_rails_4/integration/minitest_4_rails_4_spec.rb +0 -66
  100. data/spec/suites/rspec_2_rails_4/integration/rspec_2_rails_4_spec.rb +0 -156
  101. data/spec/suites/rspec_2_rails_4/integration/test_unit_200_rails_4_spec.rb +0 -66
  102. data/spec/suites/rspec_2_rails_4/integration/test_unit_2_rails_4_spec.rb +0 -66
  103. data/spec/suites/rspec_2_rails_4/spec_helper.rb +0 -3
  104. data/spec/suites/test_unit_1/integration/test_unit_1_test.rb +0 -10
  105. data/spec/suites/test_unit_1/test_helper.rb +0 -10
  106. data/spec/suites/test_unit_2/integration/test_unit_2_test.rb +0 -10
  107. data/spec/suites/test_unit_2/test_helper.rb +0 -6
  108. data/spec/suites/test_unit_200/integration/test_unit_200_test.rb +0 -10
  109. data/spec/suites/test_unit_200/test_helper.rb +0 -6
  110. data/spec/suites/test_unit_200_rails_3/integration/test_unit_200_rails_3_test.rb +0 -10
  111. data/spec/suites/test_unit_200_rails_3/test_helper.rb +0 -7
  112. data/spec/suites/test_unit_200_rails_4/integration/test_unit_200_rails_4_test.rb +0 -10
  113. data/spec/suites/test_unit_200_rails_4/test_helper.rb +0 -7
  114. data/spec/suites/test_unit_2_rails_2/integration/test_unit_2_rails_2_test.rb +0 -10
  115. data/spec/suites/test_unit_2_rails_2/test_helper.rb +0 -7
  116. data/spec/suites/test_unit_2_rails_3/integration/test_unit_2_rails_3_test.rb +0 -10
  117. data/spec/suites/test_unit_2_rails_3/test_helper.rb +0 -7
  118. data/spec/suites/test_unit_2_rails_4/integration/test_unit_2_rails_4_test.rb +0 -10
  119. data/spec/suites/test_unit_2_rails_4/test_helper.rb +0 -7
@@ -1,27 +0,0 @@
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,57 +0,0 @@
1
- require File.expand_path('../../spec_helper', __FILE__)
2
- require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
3
-
4
- describe 'Integration with MiniTest 4' do
5
- def adapter_name
6
- 'minitest_4'
7
- end
8
-
9
- def test_framework_path
10
- 'minitest/autorun'
11
- end
12
-
13
- def error_test
14
- with_bootstrap <<-EOT
15
- class FooTest < MiniTest::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 MiniTest::Unit::TestCase
27
- include RR::Adapters::MiniTest
28
- end
29
-
30
- class FooTest < MiniTest::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 MiniTest::Unit::TestCase
43
- include RR::Adapters::MiniTest
44
- end
45
-
46
- class FooTest < MiniTest::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,57 +0,0 @@
1
- require File.expand_path('../../spec_helper', __FILE__)
2
- require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
3
-
4
- describe 'Integration with Minitest >= 5' do
5
- def adapter_name
6
- 'minitest'
7
- end
8
-
9
- def test_framework_path
10
- 'minitest/autorun'
11
- end
12
-
13
- def error_test
14
- with_bootstrap <<-EOT
15
- class FooTest < Minitest::Test
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 Minitest::Test
27
- include RR::Adapters::MiniTest
28
- end
29
-
30
- class FooTest < Minitest::Test
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 => true
42
- class Minitest::Test
43
- include RR::Adapters::MiniTest
44
- end
45
-
46
- class FooTest < Minitest::Test
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,126 +0,0 @@
1
- require File.expand_path('../../spec_helper', __FILE__)
2
- require File.expand_path('../../../common/adapter_tests', __FILE__)
3
- require File.expand_path('../../../common/adapter_integration_tests', __FILE__)
4
-
5
- describe 'Integration with RSpec 2' do
6
- def assert_equal(expected, actual)
7
- expect(actual).to eq actual
8
- end
9
-
10
- def assert_raise(error, message=nil, &block)
11
- expect(&block).to raise_error(error, message)
12
- end
13
-
14
- def adapter_name
15
- 'rspec_2'
16
- end
17
-
18
- def applicable_adapter_names
19
- [:RSpec2]
20
- end
21
-
22
- def test_framework_path
23
- 'rspec/autorun'
24
- end
25
-
26
- def error_test
27
- with_bootstrap <<-EOT
28
- describe 'A test' do
29
- it 'is a test' do
30
- object = Object.new
31
- mock(object).foo
32
- end
33
- end
34
- EOT
35
- end
36
-
37
- def include_adapter_test
38
- with_bootstrap <<-EOT
39
- RSpec.configure do |c|
40
- c.mock_with :rr
41
- end
42
-
43
- describe 'A test' do
44
- it 'is a test' do
45
- object = Object.new
46
- mock(object).foo
47
- object.foo
48
- end
49
- end
50
- EOT
51
- end
52
-
53
- def include_adapter_where_rr_included_before_test_framework_test
54
- with_bootstrap <<-EOT, :include_rr_before_test_framework => true
55
- RSpec.configure do |c|
56
- c.mock_with :rr
57
- end
58
-
59
- describe 'A test' do
60
- it 'is a test' do
61
- object = Object.new
62
- mock(object).foo
63
- object.foo
64
- end
65
- end
66
- EOT
67
- end
68
-
69
- specify "it is still possible to use a custom RSpec-2 adapter" do
70
- suite = with_bootstrap <<-EOT
71
- module RR
72
- module Adapters
73
- module RSpec2
74
- include RRMethods
75
-
76
- def setup_mocks_for_rspec
77
- RR.reset
78
- end
79
-
80
- def verify_mocks_for_rspec
81
- RR.verify
82
- end
83
-
84
- def teardown_mocks_for_rspec
85
- RR.reset
86
- end
87
-
88
- def have_received(method = nil)
89
- RR::Adapters::Rspec::InvocationMatcher.new(method)
90
- end
91
- end
92
- end
93
- end
94
-
95
- RSpec.configure do |c|
96
- c.mock_with RR::Adapters::RSpec2
97
- end
98
-
99
- describe 'RR' do
100
- specify 'mocks work' do
101
- object = Object.new
102
- mock(object).foo
103
- object.foo
104
- end
105
-
106
- specify 'have_received works' do
107
- object = Object.new
108
- stub(object).foo
109
- object.foo
110
- object.should have_received.foo
111
- end
112
- end
113
- EOT
114
- output = run_fixture_tests(suite)
115
- all_tests_should_pass(output)
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
126
- end
@@ -1,57 +0,0 @@
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,57 +0,0 @@
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.5' do
5
- def adapter_name
6
- 'test_unit_2'
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,3 +0,0 @@
1
- require File.expand_path('../../../global_helper', __FILE__)
2
- RR::Test.setup_test_suite(:rspec_2)
3
- require File.expand_path('../helper', __FILE__)
@@ -1,32 +0,0 @@
1
- module WildcardMatcherMatchers
2
- extend RSpec::Matchers::DSL
3
-
4
- matcher :equal_match do |value|
5
- match { |matcher|
6
- matcher == value &&
7
- matcher.eql?(value)
8
- }
9
-
10
- failure_message_for_should {
11
- "Expected matcher to equal match #{value.inspect}, but it didn't"
12
- }
13
-
14
- failure_message_for_should_not {
15
- "Expected matcher to not equal match #{value.inspect}, but it did"
16
- }
17
- end
18
-
19
- matcher :wildcard_match do |value|
20
- match { |matcher|
21
- matcher.wildcard_match?(value)
22
- }
23
-
24
- failure_message_for_should {
25
- "Expected matcher to wildcard equal match #{value.inspect}, but it didn't"
26
- }
27
-
28
- failure_message_for_should_not {
29
- "Expected matcher to not wildcard equal match #{value.inspect}, but it did"
30
- }
31
- end
32
- end
@@ -1,13 +0,0 @@
1
- shared_examples_for "Swapped Space" do
2
- attr_reader :space, :original_space
3
-
4
- before do
5
- @original_space = RR::Space.instance
6
- RR::Space.instance = RR::Space.new
7
- @space = RR::Space.instance
8
- end
9
-
10
- after do
11
- RR::Space.instance = @original_space
12
- end
13
- end
@@ -1,9 +0,0 @@
1
- shared_examples_for "RR::Expectations::TimesCalledExpectation" do
2
- include_examples "Swapped Space"
3
-
4
- subject { Object.new }
5
-
6
- def raises_expectation_error(&block)
7
- expect { block.call }.to raise_error(RR::Errors::TimesCalledError)
8
- end
9
- end