rr 1.1.2 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +5 -5
  2. data/Appraisals +3 -43
  3. data/CHANGES.md +93 -0
  4. data/CREDITS.md +5 -0
  5. data/Gemfile +1 -17
  6. data/README.md +29 -32
  7. data/Rakefile +42 -40
  8. data/doc/02_syntax_comparison.md +1 -0
  9. data/lib/rr/class_instance_method_defined.rb +1 -1
  10. data/lib/rr/core_ext/array.rb +2 -0
  11. data/lib/rr/core_ext/hash.rb +2 -0
  12. data/lib/rr/deprecations.rb +97 -0
  13. data/lib/rr/double.rb +28 -10
  14. data/lib/rr/double_definitions/double_definition.rb +39 -16
  15. data/lib/rr/double_definitions/double_definition_create.rb +5 -5
  16. data/lib/rr/double_definitions/double_definition_create_blank_slate.rb +10 -4
  17. data/lib/rr/double_definitions/double_injections/any_instance_of.rb +1 -1
  18. data/lib/rr/double_definitions/double_injections/instance.rb +2 -2
  19. data/lib/rr/double_definitions/strategies/strategy.rb +27 -8
  20. data/lib/rr/double_definitions/strategies/verification/mock.rb +8 -2
  21. data/lib/rr/double_matches.rb +4 -3
  22. data/lib/rr/dsl.rb +152 -0
  23. data/lib/rr/expectations/any_argument_expectation.rb +4 -4
  24. data/lib/rr/expectations/argument_equality_expectation.rb +43 -5
  25. data/lib/rr/injections/double_injection.rb +85 -26
  26. data/lib/rr/injections/method_missing_injection.rb +37 -6
  27. data/lib/rr/integrations/minitest_4.rb +1 -1
  28. data/lib/rr/integrations/minitest_4_active_support.rb +1 -1
  29. data/lib/rr/integrations/rspec/invocation_matcher.rb +0 -8
  30. data/lib/rr/integrations/rspec_2.rb +20 -2
  31. data/lib/rr/keyword_arguments.rb +15 -0
  32. data/lib/rr/method_dispatches/base_method_dispatch.rb +22 -5
  33. data/lib/rr/method_dispatches/method_dispatch.rb +21 -10
  34. data/lib/rr/method_dispatches/method_missing_dispatch.rb +14 -5
  35. data/lib/rr/recorded_call.rb +35 -0
  36. data/lib/rr/recorded_calls.rb +23 -9
  37. data/lib/rr/space.rb +15 -5
  38. data/lib/rr/spy_verification.rb +13 -5
  39. data/lib/rr/version.rb +1 -1
  40. data/lib/rr/wildcard_matchers.rb +10 -10
  41. data/lib/rr/without_autohook.rb +7 -14
  42. data/rr.gemspec +8 -3
  43. data/spec/defines_spec_suite_tasks.rb +12 -0
  44. data/spec/global_helper.rb +5 -0
  45. data/spec/spec_suite_configuration.rb +1 -7
  46. data/spec/suites.yml +0 -14
  47. data/spec/suites/rspec_2/functional/any_instance_of_spec.rb +133 -33
  48. data/spec/suites/rspec_2/functional/dont_allow_spec.rb +13 -8
  49. data/spec/suites/rspec_2/functional/mock_bang_spec.rb +20 -0
  50. data/spec/suites/rspec_2/functional/mock_instance_of_spec.rb +14 -0
  51. data/spec/suites/rspec_2/functional/mock_instance_of_strong_spec.rb +15 -0
  52. data/spec/suites/rspec_2/functional/mock_proxy_instance_of_spec.rb +15 -0
  53. data/spec/suites/rspec_2/functional/mock_proxy_spec.rb +14 -0
  54. data/spec/suites/rspec_2/functional/mock_spec.rb +8 -232
  55. data/spec/suites/rspec_2/functional/mock_strong_spec.rb +14 -0
  56. data/spec/suites/rspec_2/functional/received_spec.rb +16 -0
  57. data/spec/suites/rspec_2/functional/spy_spec.rb +89 -28
  58. data/spec/suites/rspec_2/functional/stub_bang_spec.rb +20 -0
  59. data/spec/suites/rspec_2/functional/stub_instance_of_spec.rb +15 -0
  60. data/spec/suites/rspec_2/functional/stub_instance_of_strong_spec.rb +15 -0
  61. data/spec/suites/rspec_2/functional/stub_proxy_instance_of_spec.rb +16 -0
  62. data/spec/suites/rspec_2/functional/stub_proxy_spec.rb +45 -0
  63. data/spec/suites/rspec_2/functional/stub_spec.rb +42 -161
  64. data/spec/suites/rspec_2/functional/stub_strong_spec.rb +15 -0
  65. data/spec/suites/rspec_2/helper.rb +2 -2
  66. data/spec/suites/rspec_2/support/mixins/double_definition_creator_helpers.rb +173 -0
  67. data/spec/suites/rspec_2/support/mixins/mock_definition_creator_helpers.rb +45 -0
  68. data/spec/suites/rspec_2/support/mixins/proxy_definition_creator_helpers.rb +33 -0
  69. data/spec/suites/rspec_2/support/mixins/stub_creator_helpers.rb +43 -0
  70. data/spec/suites/rspec_2/support/mixins/stub_definition_creator_helpers.rb +45 -0
  71. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/argument_expectations_with_never_called_qualifier.rb +39 -0
  72. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/argument_expectations_with_times_called_qualifier.rb +50 -0
  73. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/argument_expectations_without_qualifiers.rb +131 -0
  74. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/dont_allow.rb +148 -0
  75. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_instance_of.rb +26 -0
  76. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_instance_of_strong.rb +28 -0
  77. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_proxy.rb +11 -0
  78. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_strong.rb +37 -0
  79. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mocking.rb +107 -0
  80. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_instance_of.rb +32 -0
  81. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_instance_of_strong.rb +39 -0
  82. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_proxy.rb +11 -0
  83. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_strong.rb +37 -0
  84. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stubbing.rb +57 -0
  85. data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/array_flatten_bug.rb +35 -0
  86. data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/block_form.rb +31 -0
  87. data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/comparing_arity.rb +63 -0
  88. data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/object_is_proxy.rb +43 -0
  89. data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/sequential_invocations.rb +26 -0
  90. data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/setting_implementation.rb +51 -0
  91. data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/yields.rb +81 -0
  92. data/spec/suites/rspec_2/unit/core_ext/enumerable_spec.rb +0 -28
  93. data/spec/suites/rspec_2/unit/deprecations_spec.rb +27 -0
  94. data/spec/suites/rspec_2/unit/double_definitions/double_definition_create_spec.rb +18 -18
  95. data/spec/suites/rspec_2/unit/dsl/double_creators_spec.rb +133 -0
  96. data/spec/suites/rspec_2/unit/dsl/space_spec.rb +99 -0
  97. data/spec/suites/rspec_2/unit/dsl/wildcard_matchers_spec.rb +67 -0
  98. data/spec/suites/rspec_2/unit/expectations/any_argument_expectation_spec.rb +9 -9
  99. data/spec/suites/rspec_2/unit/expectations/argument_equality_expectation_spec.rb +21 -21
  100. data/spec/suites/rspec_2/unit/expectations/boolean_argument_equality_expectation_spec.rb +4 -4
  101. data/spec/suites/rspec_2/unit/expectations/hash_including_argument_equality_expectation_spec.rb +31 -21
  102. data/spec/suites/rspec_2/unit/injections/double_injection/double_injection_spec.rb +0 -12
  103. data/spec/suites/rspec_2/unit/integrations/rspec_spec.rb +4 -19
  104. data/spec/suites/rspec_2/unit/space_spec.rb +7 -4
  105. data/spec/suites/rspec_2/unit/spy_verification_spec.rb +1 -1
  106. data/spec/support/adapter.rb +1 -1
  107. data/spec/support/adapter_tests/rspec.rb +19 -15
  108. data/spec/support/project/generator.rb +0 -4
  109. metadata +112 -57
  110. data/gemfiles/ruby_18_rspec_1.gemfile +0 -14
  111. data/gemfiles/ruby_18_rspec_1.gemfile.lock +0 -38
  112. data/gemfiles/ruby_18_rspec_1_rails_2.gemfile +0 -18
  113. data/gemfiles/ruby_18_rspec_1_rails_2.gemfile.lock +0 -64
  114. data/gemfiles/ruby_19_rspec_2_rails_3.gemfile +0 -15
  115. data/gemfiles/ruby_19_rspec_2_rails_3.gemfile.lock +0 -123
  116. data/lib/rr/adapters.rb +0 -34
  117. data/lib/rr/adapters/rr_methods.rb +0 -142
  118. data/lib/rr/integrations/rspec_1.rb +0 -46
  119. data/lib/rr/integrations/test_unit_1.rb +0 -63
  120. data/lib/rr/integrations/test_unit_2.rb +0 -17
  121. data/lib/rr/integrations/test_unit_200.rb +0 -27
  122. data/lib/rr/integrations/test_unit_200_active_support.rb +0 -25
  123. data/lib/rr/integrations/test_unit_2_active_support.rb +0 -38
  124. data/lib/rr/proc_from_block.rb +0 -11
  125. data/spec/suites/rspec_1/helper.rb +0 -24
  126. data/spec/suites/rspec_1/integration/rspec_1_spec.rb +0 -93
  127. data/spec/suites/rspec_1/integration/test_unit_1_spec.rb +0 -102
  128. data/spec/suites/rspec_1/integration/test_unit_2_spec.rb +0 -109
  129. data/spec/suites/rspec_1/spec_helper.rb +0 -3
  130. data/spec/suites/rspec_1_rails_2/integration/astc_rails_2_spec.rb +0 -141
  131. data/spec/suites/rspec_1_rails_2/integration/rspec_1_rails_2_spec.rb +0 -132
  132. data/spec/suites/rspec_1_rails_2/integration/test_unit_1_rails_2_spec.rb +0 -141
  133. data/spec/suites/rspec_1_rails_2/integration/test_unit_2_rails_2_spec.rb +0 -148
  134. data/spec/suites/rspec_1_rails_2/spec_helper.rb +0 -3
  135. data/spec/suites/rspec_2/functional/dsl_spec.rb +0 -13
  136. data/spec/suites/rspec_2/functional/instance_of_spec.rb +0 -14
  137. data/spec/suites/rspec_2/functional/proxy_spec.rb +0 -136
  138. data/spec/suites/rspec_2/functional/strong_spec.rb +0 -79
  139. data/spec/suites/rspec_2/integration/rspec_2_spec.rb +0 -133
  140. data/spec/suites/rspec_2/integration/test_unit_200_spec.rb +0 -102
  141. data/spec/suites/rspec_2/integration/test_unit_2_spec.rb +0 -109
  142. data/spec/suites/rspec_2/unit/adapters/rr_methods/double_creators_spec.rb +0 -135
  143. data/spec/suites/rspec_2/unit/adapters/rr_methods/space_spec.rb +0 -101
  144. data/spec/suites/rspec_2/unit/adapters/rr_methods/wildcard_matchers_spec.rb +0 -69
  145. data/spec/suites/rspec_2/unit/proc_from_block_spec.rb +0 -14
  146. data/spec/suites/rspec_2_rails_3/integration/astc_rails_3_spec.rb +0 -141
  147. data/spec/suites/rspec_2_rails_3/integration/minitest_4_rails_3_spec.rb +0 -148
  148. data/spec/suites/rspec_2_rails_3/integration/rspec_2_rails_3_spec.rb +0 -172
  149. data/spec/suites/rspec_2_rails_3/integration/test_unit_200_rails_3_spec.rb +0 -141
  150. data/spec/suites/rspec_2_rails_3/integration/test_unit_2_rails_3_spec.rb +0 -148
  151. data/spec/suites/rspec_2_rails_3/spec_helper.rb +0 -3
  152. data/spec/suites/rspec_2_rails_4/integration/astc_rails_4_spec.rb +0 -142
  153. data/spec/suites/rspec_2_rails_4/integration/minitest_4_rails_4_spec.rb +0 -149
  154. data/spec/suites/rspec_2_rails_4/integration/rspec_2_rails_4_spec.rb +0 -173
  155. data/spec/suites/rspec_2_rails_4/integration/test_unit_200_rails_4_spec.rb +0 -142
  156. data/spec/suites/rspec_2_rails_4/integration/test_unit_2_rails_4_spec.rb +0 -149
  157. data/spec/suites/rspec_2_rails_4/spec_helper.rb +0 -3
@@ -3,15 +3,19 @@ module RR
3
3
  class MethodDispatch < BaseMethodDispatch
4
4
  attr_reader :double_injection, :subject
5
5
 
6
- def initialize(double_injection, subject, args, block)
7
- @double_injection, @subject, @args, @block = double_injection, subject, args, block
6
+ def initialize(double_injection, subject, args, kwargs, block)
7
+ @double_injection = double_injection
8
+ @subject = subject
9
+ @args = args
10
+ @kwargs = kwargs
11
+ @block = block
8
12
  @double = find_double_to_attempt
9
13
  end
10
14
 
11
15
  def call
12
- space.record_call(subject, method_name, args, block)
16
+ space.record_call(subject, method_name, args, kwargs, block)
13
17
  if double
14
- double.method_call(args)
18
+ double.method_call(args, kwargs)
15
19
  call_yields
16
20
  return_value_1 = call_implementation
17
21
  return_value_2 = extract_subject_from_return_value(return_value_1)
@@ -27,11 +31,19 @@ module RR
27
31
 
28
32
  def call_original_method
29
33
  if subject_has_original_method?
30
- subject.__send__(original_method_alias_name, *args, &block)
34
+ if KeywordArguments.fully_supported?
35
+ subject.__send__(original_method_alias_name, *args, **kwargs, &block)
36
+ else
37
+ subject.__send__(original_method_alias_name, *args, &block)
38
+ end
31
39
  elsif subject_has_original_method_missing?
32
40
  call_original_method_missing
33
41
  else
34
- subject.__send__(:method_missing, method_name, *args, &block)
42
+ if KeywordArguments.fully_supported?
43
+ subject.__send__(:method_missing, method_name, *args, **kwargs, &block)
44
+ else
45
+ subject.__send__(:method_missing, method_name, *args, &block)
46
+ end
35
47
  end
36
48
  end
37
49
 
@@ -41,11 +53,10 @@ module RR
41
53
  call_original_method
42
54
  else
43
55
  if implementation
44
- if implementation.is_a?(Method)
45
- implementation.call(*args, &block)
56
+ if KeywordArguments.fully_supported?
57
+ implementation.call(*args, **kwargs, &block)
46
58
  else
47
- call_args = block ? args + [ProcFromBlock.new(&block)] : args
48
- implementation.call(*call_args)
59
+ implementation.call(*args, &block)
49
60
  end
50
61
  else
51
62
  nil
@@ -9,8 +9,13 @@ module RR
9
9
 
10
10
  attr_reader :subject, :subject_class, :method_name
11
11
 
12
- def initialize(subject, subject_class, method_name, args, block)
13
- @subject, @subject_class, @method_name, @args, @block = subject, subject_class, method_name, args, block
12
+ def initialize(subject, subject_class, method_name, args, kwargs, block)
13
+ @subject = subject
14
+ @subject_class = subject_class
15
+ @method_name = method_name
16
+ @args = args
17
+ @kwargs = kwargs
18
+ @block = block
14
19
  end
15
20
 
16
21
  def call
@@ -40,14 +45,18 @@ module RR
40
45
  protected
41
46
  def call_implementation
42
47
  if implementation_is_original_method?
43
- space.record_call(subject, method_name, args, block)
44
- double.method_call(args)
48
+ space.record_call(subject, method_name, args, kwargs, block)
49
+ double.method_call(args, kwargs)
45
50
  call_original_method
46
51
  else
47
52
  if double_injection = Injections::DoubleInjection.find(subject_class, method_name)
48
53
  double_injection.bind_method
49
54
  # The DoubleInjection takes care of calling double.method_call
50
- subject.__send__(method_name, *args, &block)
55
+ if KeywordArguments.fully_supported?
56
+ subject.__send__(method_name, *args, **kwargs, &block)
57
+ else
58
+ subject.__send__(method_name, *args, &block)
59
+ end
51
60
  else
52
61
  nil
53
62
  end
@@ -0,0 +1,35 @@
1
+ module RR
2
+ class RecordedCall < Struct.new(:subject,
3
+ :method_name,
4
+ :arguments,
5
+ :keyword_arguments,
6
+ :block)
7
+ def inspect
8
+ '[%s, %s, %s, %s, %s]' % [
9
+ subject_to_s,
10
+ method_name.inspect,
11
+ arguments.inspect,
12
+ keyword_arguments.inspect,
13
+ block.inspect
14
+ ]
15
+ end
16
+
17
+ def ==(other)
18
+ other.is_a?(self.class) &&
19
+ subject == other.subject &&
20
+ method_name == other.method_name &&
21
+ arguments == other.arguments &&
22
+ keyword_arguments == other.keyword_arguments
23
+ end
24
+
25
+ private
26
+
27
+ def subject_to_s
28
+ if subject.respond_to?(:__rr__original_to_s, true)
29
+ subject.__rr__original_to_s
30
+ else
31
+ subject.to_s
32
+ end
33
+ end
34
+ end
35
+ end
@@ -9,13 +9,21 @@ module RR
9
9
 
10
10
  attr_reader :recorded_calls
11
11
 
12
+ def [](index)
13
+ @recorded_calls[index]
14
+ end
15
+
12
16
  def clear
13
17
  self.ordered_index = 0
14
18
  recorded_calls.clear
15
19
  end
16
20
 
17
- def <<(recorded_call)
18
- recorded_calls << recorded_call
21
+ def add(subject, method_name, arguments, keyword_arguments, block)
22
+ recorded_calls << RecordedCall.new(subject,
23
+ method_name,
24
+ arguments,
25
+ keyword_arguments,
26
+ block)
19
27
  end
20
28
 
21
29
  def any?(&block)
@@ -43,9 +51,9 @@ module RR
43
51
  unless Injections::DoubleInjection.exists_by_subject?(spy_verification.subject, spy_verification.method_name)
44
52
  RR::Errors.build_error(RR::Errors::SpyVerificationErrors::DoubleInjectionNotFoundError,
45
53
  "A Double Injection for the subject and method call:\n" <<
46
- "#{spy_verification.subject.inspect}\n" <<
54
+ "#{spy_verification.subject_inspect}\n" <<
47
55
  "#{spy_verification.method_name}\ndoes not exist in:\n" <<
48
- "\t#{recorded_calls.map {|call| call.inspect}.join("\n\t")}"
56
+ "\t#{recorded_calls.map {|call| call.inspect }.join("\n\t")}"
49
57
  )
50
58
  end
51
59
  end
@@ -77,22 +85,28 @@ module RR
77
85
 
78
86
  def match_double_injection(spy_verification)
79
87
  lambda do |recorded_call|
80
- recorded_call[0] == spy_verification.subject &&
81
- recorded_call[1] == spy_verification.method_name
88
+ recorded_call.subject == spy_verification.subject &&
89
+ recorded_call.method_name == spy_verification.method_name
82
90
  end
83
91
  end
84
92
 
85
93
  def match_argument_expectation(spy_verification)
86
94
  lambda do |recorded_call|
87
- spy_verification.argument_expectation.exact_match?(*recorded_call[2]) ||
88
- spy_verification.argument_expectation.wildcard_match?(*recorded_call[2])
95
+ expectation = spy_verification.argument_expectation
96
+ arguments = recorded_call.arguments
97
+ keyword_arguments = recorded_call.keyword_arguments
98
+ expectation.exact_match?(arguments, keyword_arguments) ||
99
+ expectation.wildcard_match?(arguments, keyword_arguments)
89
100
  end
90
101
  end
91
102
 
92
103
  def invocation_count_error(spy_verification, matching_recorded_calls)
104
+ method_name = spy_verification.method_name
105
+ arguments = spy_verification.argument_expectation.expected_arguments
106
+ keyword_arguments = spy_verification.argument_expectation.expected_keyword_arguments
93
107
  RR::Errors.build_error(RR::Errors::SpyVerificationErrors::InvocationCountError,
94
108
  "On subject #{spy_verification.subject.inspect}\n" <<
95
- "Expected #{Double.formatted_name(spy_verification.method_name, spy_verification.argument_expectation.expected_arguments)}\n" <<
109
+ "Expected #{Double.formatted_name(method_name, arguments, keyword_arguments)}\n" <<
96
110
  "to be called #{spy_verification.times_matcher.expected_times_message},\n" <<
97
111
  "but was called #{matching_recorded_calls.size} times.\n" <<
98
112
  "All of the method calls related to Doubles are:\n" <<
data/lib/rr/space.rb CHANGED
@@ -13,9 +13,15 @@ module RR
13
13
  end
14
14
  attr_writer :instance
15
15
 
16
- protected
17
- def method_missing(method_name, *args, &block)
18
- instance.__send__(method_name, *args, &block)
16
+ protected
17
+ if KeywordArguments.fully_supported?
18
+ def method_missing(method_name, *args, **kwargs, &block)
19
+ instance.__send__(method_name, *args, **kwargs, &block)
20
+ end
21
+ else
22
+ def method_missing(method_name, *args, &block)
23
+ instance.__send__(method_name, *args, &block)
24
+ end
19
25
  end
20
26
  end
21
27
 
@@ -79,8 +85,12 @@ module RR
79
85
  Injections::DoubleInjection.reset_double(class << subject; self; end, method_name)
80
86
  end
81
87
 
82
- def record_call(subject, method_name, arguments, block)
83
- @recorded_calls << [subject, method_name, arguments, block]
88
+ def record_call(subject, method_name, arguments, keyword_arguments, block)
89
+ @recorded_calls.add(subject,
90
+ method_name,
91
+ arguments,
92
+ keyword_arguments,
93
+ block)
84
94
  end
85
95
 
86
96
  def blank_slate_whitelist
@@ -13,12 +13,12 @@ module RR
13
13
 
14
14
  include RR::DoubleDefinitions::DoubleDefinition::TimesDefinitionConstructionMethods
15
15
  include RR::DoubleDefinitions::DoubleDefinition::ArgumentDefinitionConstructionMethods
16
-
16
+
17
17
  def ordered
18
18
  @ordered = true
19
19
  self
20
20
  end
21
-
21
+
22
22
  def ordered?
23
23
  @ordered
24
24
  end
@@ -32,7 +32,15 @@ module RR
32
32
  call
33
33
  end
34
34
  end
35
-
35
+
36
+ def subject_inspect
37
+ if subject.respond_to?(:__rr__original_inspect, true)
38
+ subject.__rr__original_inspect
39
+ else
40
+ subject.inspect
41
+ end
42
+ end
43
+
36
44
  protected
37
45
  attr_writer :times_matcher
38
46
 
@@ -40,9 +48,9 @@ module RR
40
48
  # with_no_args and with actually set @argument_expectation
41
49
  args.empty? ? with_no_args : with(*args)
42
50
  end
43
-
51
+
44
52
  def install_method_callback(return_value_block)
45
53
  # Do nothing. This is to support DefinitionConstructionMethods
46
54
  end
47
55
  end
48
- end
56
+ end
data/lib/rr/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module RR
2
- VERSION = '1.1.2'.freeze
2
+ VERSION = '3.0.2'.freeze
3
3
  def self.version; VERSION; end
4
4
  end
@@ -12,7 +12,7 @@ divisible by a certain integer. In use, it might look like this:
12
12
 
13
13
  mock(BananaGrabber).bunch_bananas(divisible_by(5))
14
14
 
15
- To implement this, we need a class RR::WildcardMatchers::DivisibleBy with
15
+ To implement this, we need a class RR::WildcardMatchers::DivisibleBy with
16
16
  these instance methods:
17
17
 
18
18
  * ==(other)
@@ -38,7 +38,7 @@ might look like this:
38
38
  DivisibleBy#==(other) should return true if other is a wildcard matcher that
39
39
  matches the same things as self, so a natural way to write DivisibleBy#== is:
40
40
 
41
-
41
+
42
42
  class RR::WildcardMatchers::DivisibleBy
43
43
  def ==(other)
44
44
  # Ensure that other is actually a DivisibleBy
@@ -86,7 +86,7 @@ false otherwise. In the case of DivisibleBy, wildcard_matches? reads:
86
86
  # If other isn't a number, how can it be divisible by anything?
87
87
  return false unless other.is_a?(Numeric)
88
88
 
89
- # If other is in fact divisible by expected_divisor, then
89
+ # If other is in fact divisible by expected_divisor, then
90
90
  # other modulo expected_divisor should be 0.
91
91
 
92
92
  other % expected_divisor == 0
@@ -105,10 +105,10 @@ But that's less expressive than the original:
105
105
  mock(BananaGrabber).bunch_bananas(divisible_by(5))
106
106
 
107
107
  To be able to use the convenient divisible_by matcher rather than the uglier
108
- DivisibleBy.new version, re-open the module RR::Adapters::RRMethods and
109
- define divisible_by there as a simple wrapper around DivisibleBy.new:
108
+ DivisibleBy.new version, re-open the module RR::DSL and define divisible_by
109
+ there as a simple wrapper around DivisibleBy.new:
110
110
 
111
- module RR::Adapters::RRMethods
111
+ module RR::DSL
112
112
  def divisible_by(expected_divisor)
113
113
  RR::WildcardMatchers::DivisibleBy.new(expected_divisor)
114
114
  end
@@ -134,19 +134,19 @@ Here's all the code for DivisibleBy in one place for easy reference:
134
134
  def inspect
135
135
  "integer divisible by #{expected.divisor}"
136
136
  end
137
-
137
+
138
138
  def wildcard_matches?(other)
139
139
  # If other isn't a number, how can it be divisible by anything?
140
140
  return false unless other.is_a?(Numeric)
141
141
 
142
- # If other is in fact divisible by expected_divisor, then
142
+ # If other is in fact divisible by expected_divisor, then
143
143
  # other modulo expected_divisor should be 0.
144
144
 
145
145
  other % expected_divisor == 0
146
146
  end
147
147
  end
148
-
149
- module RR::Adapters::RRMethods
148
+
149
+ module RR::DSL
150
150
  def divisible_by(expected_divisor)
151
151
  RR::WildcardMatchers::DivisibleBy.new(expected_divisor)
152
152
  end
@@ -6,6 +6,8 @@ require 'rr/core_ext/array'
6
6
  require 'rr/core_ext/range'
7
7
  require 'rr/core_ext/regexp'
8
8
 
9
+ require 'rr/keyword_arguments'
10
+
9
11
  require 'rr/class_instance_method_defined'
10
12
  require 'rr/blank_slate'
11
13
 
@@ -36,7 +38,7 @@ require 'rr/double_definitions/strategies/implementation/proxy'
36
38
  require 'rr/double_definitions/strategies/double_injection/double_injection_strategy'
37
39
  require 'rr/double_definitions/strategies/double_injection/instance'
38
40
  require 'rr/double_definitions/strategies/double_injection/any_instance_of'
39
- require 'rr/adapters/rr_methods'
41
+ require 'rr/dsl'
40
42
  require 'rr/double_definitions/double_injections/instance'
41
43
  require 'rr/double_definitions/double_injections/any_instance_of'
42
44
  require 'rr/double_definitions/double_definition'
@@ -49,8 +51,8 @@ require 'rr/method_dispatches/base_method_dispatch'
49
51
  require 'rr/method_dispatches/method_dispatch'
50
52
  require 'rr/method_dispatches/method_missing_dispatch'
51
53
  require 'rr/hash_with_object_id_key'
54
+ require 'rr/recorded_call'
52
55
  require 'rr/recorded_calls'
53
- require 'rr/proc_from_block'
54
56
 
55
57
  require 'rr/double_definitions/double_definition_create_blank_slate'
56
58
  require 'rr/double_definitions/double_definition_create'
@@ -88,24 +90,19 @@ require 'rr/spy_verification'
88
90
  require 'rr/integrations'
89
91
  require 'rr/integrations/decorator'
90
92
  require 'rr/integrations/rspec/invocation_matcher'
91
- require 'rr/integrations/rspec_1'
92
93
  require 'rr/integrations/rspec_2'
93
94
  require 'rr/integrations/minitest_4'
94
95
  require 'rr/integrations/minitest_4_active_support'
95
96
  require 'rr/integrations/minitest'
96
97
  require 'rr/integrations/minitest_active_support'
97
- require 'rr/integrations/test_unit_1'
98
- require 'rr/integrations/test_unit_200'
99
- require 'rr/integrations/test_unit_200_active_support'
100
- require 'rr/integrations/test_unit_2'
101
- require 'rr/integrations/test_unit_2_active_support'
102
- require 'rr/adapters'
98
+
99
+ require 'rr/deprecations'
103
100
 
104
101
  require 'rr/version'
105
102
 
106
103
  module RR
107
104
  class << self
108
- include Adapters::RRMethods
105
+ include DSL
109
106
 
110
107
  (RR::Space.instance_methods - Object.instance_methods).each do |method_name|
111
108
  class_eval((<<-METHOD), __FILE__, __LINE__ + 1)
@@ -117,10 +114,6 @@ module RR
117
114
 
118
115
  attr_accessor :debug
119
116
  alias_method :debug?, :debug
120
-
121
- def ruby_18?
122
- RUBY_VERSION =~ /^1\.8/
123
- end
124
117
  end
125
118
  end
126
119
 
data/rr.gemspec CHANGED
@@ -6,11 +6,11 @@ require File.expand_path('../lib/rr/version', __FILE__)
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = 'rr'
8
8
  gem.version = RR.version
9
- gem.authors = ['Brian Takita', 'Elliot Winkler']
10
- gem.email = ['elliot.winkler@gmail.com']
9
+ gem.authors = ['Kouhei Sutou', 'Brian Takita', 'Elliot Winkler']
10
+ gem.email = ['kou@cozmixng.org']
11
11
  gem.description = 'RR is a test double framework that features a rich selection of double techniques and a terse syntax.'
12
12
  gem.summary = 'RR is a test double framework that features a rich selection of double techniques and a terse syntax.'
13
- gem.homepage = 'http://rr.github.com/rr'
13
+ gem.homepage = 'https://rr.github.io/rr'
14
14
  gem.license = 'MIT'
15
15
 
16
16
  gem.files = FileList[
@@ -29,4 +29,9 @@ Gem::Specification.new do |gem|
29
29
  ].to_a
30
30
 
31
31
  gem.require_paths = ['lib']
32
+
33
+ gem.add_development_dependency("bundler")
34
+ gem.add_development_dependency("rake")
35
+ gem.add_development_dependency("test-unit")
36
+ gem.add_development_dependency("test-unit-rr")
32
37
  end
@@ -33,6 +33,18 @@ class DefinesSpecSuiteTasks
33
33
  end
34
34
  end
35
35
  end
36
+
37
+ require 'rspec/core/rake_task'
38
+
39
+ desc "Run the unit tests"
40
+ RSpec::Core::RakeTask.new(:unit) do |t|
41
+ t.pattern = 'spec/suites/rspec_2/unit/**/*_spec.rb'
42
+ end
43
+
44
+ desc "Run the functional (API) tests"
45
+ RSpec::Core::RakeTask.new(:functional) do |t|
46
+ t.pattern = 'spec/suites/rspec_2/functional/**/*_spec.rb'
47
+ end
36
48
  end
37
49
 
38
50
  namespace :travis do