rr 1.0.4 → 1.0.5.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/CHANGES.md +376 -0
- data/Gemfile +7 -10
- data/README.md +822 -0
- data/Rakefile +24 -78
- data/VERSION +1 -0
- data/lib/rr.rb +3 -0
- data/lib/rr/adapters/minitest.rb +6 -0
- data/lib/rr/adapters/rr_methods.rb +6 -10
- data/lib/rr/adapters/rspec.rb +3 -0
- data/lib/rr/adapters/rspec2.rb +30 -0
- data/lib/rr/adapters/test_unit.rb +2 -0
- data/lib/rr/double.rb +3 -2
- data/lib/rr/double_definitions/child_double_definition_create.rb +3 -2
- data/lib/rr/double_definitions/double_definition.rb +15 -13
- data/lib/rr/double_definitions/double_definition_create.rb +9 -5
- data/lib/rr/double_definitions/double_injections/any_instance_of.rb +3 -2
- data/lib/rr/double_definitions/strategies/strategy.rb +5 -4
- data/lib/rr/double_definitions/strategies/strategy_methods.rb +6 -8
- data/lib/rr/double_definitions/strategies/verification/mock.rb +3 -3
- data/lib/rr/double_matches.rb +2 -1
- data/lib/rr/expectations/argument_equality_expectation.rb +2 -2
- data/lib/rr/expectations/times_called_expectation.rb +2 -2
- data/lib/rr/injections/double_injection.rb +12 -11
- data/lib/rr/injections/injection.rb +2 -2
- data/lib/rr/injections/method_missing_injection.rb +21 -7
- data/lib/rr/injections/singleton_method_added_injection.rb +3 -1
- data/lib/rr/method_dispatches/base_method_dispatch.rb +1 -1
- data/lib/rr/method_dispatches/method_dispatch.rb +2 -1
- data/lib/rr/method_dispatches/method_missing_dispatch.rb +2 -1
- data/lib/rr/proc_from_block.rb +8 -4
- data/lib/rr/space.rb +3 -2
- data/lib/rr/times_called_matchers/times_called_matcher.rb +2 -2
- data/lib/rr/version.rb +5 -0
- data/lib/rr/wildcard_matchers/boolean.rb +2 -2
- data/spec/runner.rb +41 -0
- metadata +45 -133
- data/.gitignore +0 -10
- data/.runrc +0 -3
- data/.rvmrc +0 -2
- data/CHANGES +0 -266
- data/Gemfile.lock +0 -31
- data/README.rdoc +0 -392
- data/benchmarks/rr_benchmark.rb +0 -32
- data/benchmarks/rspec_benchmark.rb +0 -14
- data/doc/0.6.0.release.markdown +0 -81
- data/doc/todo.txt +0 -0
- data/introducting_rr.txt +0 -206
- data/rr.gemspec +0 -37
- data/spec/api/any_instance_of/all_instances_of_spec.rb +0 -12
- data/spec/api/any_instance_of/any_instance_of_spec.rb +0 -47
- data/spec/api/any_instance_of/instance_of_spec.rb +0 -12
- data/spec/api/dont_allow/dont_allow_after_stub_spec.rb +0 -14
- data/spec/api/mock/mock_spec.rb +0 -193
- data/spec/api/proxy/proxy_spec.rb +0 -86
- data/spec/api/spy/spy_spec.rb +0 -49
- data/spec/api/strong/strong_spec.rb +0 -87
- data/spec/api/stub/stub_spec.rb +0 -152
- data/spec/core_spec_suite.rb +0 -19
- data/spec/environment_fixture_setup.rb +0 -8
- data/spec/minitest_spec_suite.rb +0 -21
- data/spec/proc_from_block_spec.rb +0 -14
- data/spec/rr/adapters/rr_methods_argument_matcher_spec.rb +0 -67
- data/spec/rr/adapters/rr_methods_creator_spec.rb +0 -137
- data/spec/rr/adapters/rr_methods_space_spec.rb +0 -98
- data/spec/rr/adapters/rr_methods_spec_helper.rb +0 -11
- data/spec/rr/adapters/rr_methods_times_matcher_spec.rb +0 -13
- data/spec/rr/double_definitions/child_double_definition_creator_spec.rb +0 -112
- data/spec/rr/double_definitions/double_definition_create_blank_slate_spec.rb +0 -91
- data/spec/rr/double_definitions/double_definition_create_spec.rb +0 -443
- data/spec/rr/double_injection/double_injection_spec.rb +0 -546
- data/spec/rr/double_injection/double_injection_verify_spec.rb +0 -29
- data/spec/rr/errors/rr_error_spec.rb +0 -67
- data/spec/rr/expectations/any_argument_expectation_spec.rb +0 -47
- data/spec/rr/expectations/anything_argument_equality_expectation_spec.rb +0 -14
- data/spec/rr/expectations/argument_equality_expectation_spec.rb +0 -135
- data/spec/rr/expectations/boolean_argument_equality_expectation_spec.rb +0 -34
- data/spec/rr/expectations/hash_including_argument_equality_expectation_spec.rb +0 -82
- data/spec/rr/expectations/hash_including_spec.rb +0 -17
- data/spec/rr/expectations/satisfy_argument_equality_expectation_spec.rb +0 -59
- data/spec/rr/expectations/satisfy_spec.rb +0 -14
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_any_times_spec.rb +0 -22
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb +0 -37
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_most_spec.rb +0 -43
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +0 -15
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_integer_spec.rb +0 -58
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_proc_spec.rb +0 -35
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_range_spec.rb +0 -39
- data/spec/rr/minitest/minitest_integration_test.rb +0 -59
- data/spec/rr/minitest/test_helper.rb +0 -7
- data/spec/rr/rspec/invocation_matcher_spec.rb +0 -279
- data/spec/rr/rspec/rspec_adapter_spec.rb +0 -63
- data/spec/rr/rspec/rspec_backtrace_tweaking_spec.rb +0 -31
- data/spec/rr/rspec/rspec_backtrace_tweaking_spec_fixture.rb +0 -11
- data/spec/rr/rspec/rspec_usage_spec.rb +0 -86
- data/spec/rr/space/hash_with_object_id_key_spec.rb +0 -88
- data/spec/rr/space/space_spec.rb +0 -596
- data/spec/rr/test_unit/test_helper.rb +0 -7
- data/spec/rr/test_unit/test_unit_backtrace_test.rb +0 -36
- data/spec/rr/test_unit/test_unit_integration_test.rb +0 -59
- data/spec/rr/times_called_matchers/any_times_matcher_spec.rb +0 -47
- data/spec/rr/times_called_matchers/at_least_matcher_spec.rb +0 -55
- data/spec/rr/times_called_matchers/at_most_matcher_spec.rb +0 -70
- data/spec/rr/times_called_matchers/integer_matcher_spec.rb +0 -70
- data/spec/rr/times_called_matchers/proc_matcher_spec.rb +0 -55
- data/spec/rr/times_called_matchers/range_matcher_spec.rb +0 -76
- data/spec/rr/times_called_matchers/times_called_matcher_spec.rb +0 -118
- data/spec/rr/wildcard_matchers/anything_spec.rb +0 -24
- data/spec/rr/wildcard_matchers/boolean_spec.rb +0 -36
- data/spec/rr/wildcard_matchers/duck_type_spec.rb +0 -52
- data/spec/rr/wildcard_matchers/is_a_spec.rb +0 -32
- data/spec/rr/wildcard_matchers/numeric_spec.rb +0 -32
- data/spec/rr/wildcard_matchers/range_spec.rb +0 -35
- data/spec/rr/wildcard_matchers/regexp_spec.rb +0 -43
- data/spec/rr_spec.rb +0 -28
- data/spec/rspec_spec_suite.rb +0 -17
- data/spec/spec.opts +0 -10
- data/spec/spec_helper.rb +0 -41
- data/spec/spec_suite.rb +0 -54
- data/spec/spy_verification_spec.rb +0 -129
- data/spec/test_unit_spec_suite.rb +0 -21
data/Rakefile
CHANGED
@@ -1,88 +1,34 @@
|
|
1
|
-
require
|
2
|
-
require 'rake
|
3
|
-
require 'rake/clean'
|
4
|
-
require 'rake/testtask'
|
5
|
-
require 'rake/rdoctask'
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
6
3
|
|
7
|
-
|
8
|
-
task(:default) do
|
9
|
-
run_suite
|
10
|
-
end
|
11
|
-
|
12
|
-
desc "Runs the Rspec suite"
|
13
|
-
task(:spec) do
|
14
|
-
run_suite
|
15
|
-
end
|
4
|
+
require File.expand_path('../spec/runner', __FILE__)
|
16
5
|
|
17
|
-
|
18
|
-
dir = File.dirname(__FILE__)
|
19
|
-
system("ruby #{dir}/spec/spec_suite.rb") || raise("Spec Suite failed")
|
20
|
-
end
|
6
|
+
task :default => :spec
|
21
7
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
"selection of double techniques and a terse syntax. " <<
|
28
|
-
"http://xunitpatterns.com/Test%20Double.html"
|
29
|
-
s.email = "brian@pivotallabs.com"
|
30
|
-
s.homepage = "http://pivotallabs.com"
|
31
|
-
s.description = "RR (Double Ruby) is a double framework that features a rich " <<
|
32
|
-
"selection of double techniques and a terse syntax. " <<
|
33
|
-
"http://xunitpatterns.com/Test%20Double.html"
|
34
|
-
s.authors = ["Brian Takita"]
|
35
|
-
s.files = FileList[
|
36
|
-
'[A-Z]*',
|
37
|
-
'*.rb',
|
38
|
-
'lib/**/*.rb',
|
39
|
-
'spec/**/*.rb'
|
40
|
-
].to_a
|
41
|
-
s.test_files = Dir.glob('spec/*_spec.rb')
|
42
|
-
s.has_rdoc = true
|
43
|
-
s.extra_rdoc_files = [ "README.rdoc", "CHANGES" ]
|
44
|
-
s.rdoc_options = ["--main", "README.rdoc", "--inline-source", "--line-numbers"]
|
45
|
-
s.rubyforge_project = "pivotalrb"
|
8
|
+
desc "Runs all of the tests"
|
9
|
+
task :spec do
|
10
|
+
ARGV.clear
|
11
|
+
unless SuitesRunner.new.run
|
12
|
+
raise "Spec Suite failed"
|
46
13
|
end
|
47
|
-
rescue LoadError
|
48
|
-
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
49
14
|
end
|
50
|
-
RUBYFORGE_PACKAGE_NAME = "rr (Double Ruby)"
|
51
|
-
# The package was renamed from "rr (Double R)" to "rr (Double Ruby)".
|
52
|
-
# When this was last run, the script did not work for the new name but it did work for the old name.
|
53
|
-
# Perhaps more time was needed for the name change to propagate?
|
54
|
-
#RUBYFORGE_PACKAGE_NAME = "rr (Double R)"
|
55
|
-
|
56
|
-
# This is hacked to get around the 3 character limitation for package names on Rubyforge.
|
57
|
-
# http://rubyforge.org/tracker/index.php?func=detail&aid=27026&group_id=5&atid=102
|
58
|
-
class Jeweler
|
59
|
-
module Commands
|
60
|
-
class ReleaseToRubyforge
|
61
|
-
def run
|
62
|
-
raise NoRubyForgeProjectInGemspecError unless @gemspec.rubyforge_project
|
63
15
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
output.puts "Releasing #{@gemspec.name}-#{@version} to #{@gemspec.rubyforge_project}"
|
73
|
-
begin
|
74
|
-
@rubyforge.add_release(@gemspec.rubyforge_project, RUBYFORGE_PACKAGE_NAME, @version.to_s, @gemspec_helper.gem_path)
|
75
|
-
rescue StandardError => e
|
76
|
-
case e.message
|
77
|
-
when /no <group_id> configured for <#{Regexp.escape @gemspec.rubyforge_project}>/
|
78
|
-
raise RubyForgeProjectNotConfiguredError, @gemspec.rubyforge_project
|
79
|
-
when /no <package_id> configured for <#{Regexp.escape @gemspec.name}>/i
|
80
|
-
raise MissingRubyForgePackageError, @gemspec.name
|
81
|
-
else
|
82
|
-
raise
|
83
|
-
end
|
84
|
-
end
|
16
|
+
namespace :spec do
|
17
|
+
SuitesRunner::TEST_SUITES.each do |path, class_fragment, desc|
|
18
|
+
desc "Runs all of the #{desc} tests"
|
19
|
+
task path do
|
20
|
+
ARGV.clear
|
21
|
+
require File.expand_path("../spec/suites/#{path}/runner.rb", __FILE__)
|
22
|
+
unless Object.const_get("#{class_fragment}SuiteRunner").new.run
|
23
|
+
raise "#{desc} Suite failed"
|
85
24
|
end
|
86
25
|
end
|
87
26
|
end
|
88
27
|
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'bundler'
|
31
|
+
require 'bundler/gem_tasks'
|
32
|
+
rescue LoadError
|
33
|
+
puts "Bundler isn't installed. Run `gem install bundler` to get it."
|
34
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.5.rc1
|
data/lib/rr.rb
CHANGED
@@ -83,9 +83,12 @@ require "#{dir}/rr/spy_verification_proxy"
|
|
83
83
|
require "#{dir}/rr/spy_verification"
|
84
84
|
|
85
85
|
require "#{dir}/rr/adapters/rspec"
|
86
|
+
require "#{dir}/rr/adapters/rspec2"
|
86
87
|
require "#{dir}/rr/adapters/test_unit"
|
87
88
|
require "#{dir}/rr/adapters/minitest"
|
88
89
|
|
90
|
+
require "#{dir}/rr/version"
|
91
|
+
|
89
92
|
module RR
|
90
93
|
class << self
|
91
94
|
include Adapters::RRMethods
|
data/lib/rr/adapters/minitest.rb
CHANGED
@@ -2,6 +2,7 @@ module RR
|
|
2
2
|
module Adapters
|
3
3
|
module MiniTest
|
4
4
|
include RRMethods
|
5
|
+
|
5
6
|
def self.included(mod)
|
6
7
|
RR.trim_backtrace = true
|
7
8
|
mod.class_eval do
|
@@ -16,6 +17,11 @@ module RR
|
|
16
17
|
alias_method :teardown_without_rr, :teardown
|
17
18
|
def teardown_with_rr
|
18
19
|
RR.verify
|
20
|
+
rescue RR::Errors::RRError => rr_error
|
21
|
+
assertion = ::MiniTest::Assertion.new(rr_error.message)
|
22
|
+
assertion.set_backtrace(rr_error.backtrace)
|
23
|
+
raise assertion
|
24
|
+
ensure
|
19
25
|
teardown_without_rr
|
20
26
|
end
|
21
27
|
alias_method :teardown, :teardown_with_rr
|
@@ -2,6 +2,7 @@ module RR
|
|
2
2
|
module Adapters
|
3
3
|
module RRMethods
|
4
4
|
include ::RR::DoubleDefinitions::Strategies::StrategyMethods
|
5
|
+
|
5
6
|
def mock(subject=DoubleDefinitions::DoubleDefinitionCreate::NO_SUBJECT, method_name=nil, &definition_eval_block)
|
6
7
|
double_definition_create = DoubleDefinitions::DoubleDefinitionCreate.new
|
7
8
|
double_definition_create.mock(subject, method_name, &definition_eval_block)
|
@@ -31,8 +32,10 @@ module RR
|
|
31
32
|
double_definition_create = DoubleDefinitions::DoubleDefinitionCreate.new
|
32
33
|
double_definition_create.instance_of(subject, method_name, &definition_eval_block)
|
33
34
|
end
|
34
|
-
|
35
|
-
|
35
|
+
|
36
|
+
def any_instance_of(*args, &block)
|
37
|
+
RR::DoubleDefinitions::DoubleInjections::AnyInstanceOf.call(*args, &block)
|
38
|
+
end
|
36
39
|
|
37
40
|
# Verifies all the DoubleInjection objects have met their
|
38
41
|
# TimesCalledExpectations.
|
@@ -127,19 +130,12 @@ module RR
|
|
127
130
|
RR::SpyVerificationProxy.new(subject)
|
128
131
|
end
|
129
132
|
|
130
|
-
def new_instance_of(*args, &block)
|
131
|
-
RR::DoubleDefinitions::DoubleInjections::NewInstanceOf.call(*args, &block)
|
132
|
-
end
|
133
|
-
|
134
|
-
def any_instance_of(*args, &block)
|
135
|
-
RR::DoubleDefinitions::DoubleInjections::AnyInstanceOf.call(*args, &block)
|
136
|
-
end
|
137
|
-
|
138
133
|
instance_methods.each do |name|
|
139
134
|
alias_method "rr_#{name}", name
|
140
135
|
end
|
141
136
|
end
|
142
137
|
end
|
138
|
+
|
143
139
|
module Extensions
|
144
140
|
InstanceMethods = Adapters::RRMethods
|
145
141
|
end
|
data/lib/rr/adapters/rspec.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
module RR
|
2
|
+
module Adapters
|
3
|
+
module RSpec2
|
4
|
+
def self.included(mod)
|
5
|
+
patterns = RSpec.configuration.backtrace_clean_patterns
|
6
|
+
unless patterns.include?(RR::Errors::BACKTRACE_IDENTIFIER)
|
7
|
+
patterns.push(RR::Errors::BACKTRACE_IDENTIFIER)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
include RRMethods
|
12
|
+
|
13
|
+
def setup_mocks_for_rspec
|
14
|
+
RR.reset
|
15
|
+
end
|
16
|
+
|
17
|
+
def verify_mocks_for_rspec
|
18
|
+
RR.verify
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown_mocks_for_rspec
|
22
|
+
RR.reset
|
23
|
+
end
|
24
|
+
|
25
|
+
def have_received(method = nil)
|
26
|
+
RR::Adapters::Rspec::InvocationMatcher.new(method)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -2,8 +2,10 @@ module RR
|
|
2
2
|
module Adapters
|
3
3
|
module TestUnit
|
4
4
|
include RRMethods
|
5
|
+
|
5
6
|
def self.included(mod)
|
6
7
|
RR.trim_backtrace = true
|
8
|
+
|
7
9
|
mod.class_eval do
|
8
10
|
unless instance_methods.detect {|method_name| method_name.to_sym == :setup_with_rr}
|
9
11
|
alias_method :setup_without_rr, :setup
|
data/lib/rr/double.rb
CHANGED
@@ -17,6 +17,7 @@ module RR
|
|
17
17
|
end)
|
18
18
|
|
19
19
|
attr_reader :times_called, :double_injection, :definition, :times_called_expectation
|
20
|
+
|
20
21
|
include Space::Reader
|
21
22
|
|
22
23
|
def initialize(double_injection, definition)
|
@@ -94,7 +95,7 @@ module RR
|
|
94
95
|
definition.implementation_is_original_method?
|
95
96
|
end
|
96
97
|
|
97
|
-
|
98
|
+
protected
|
98
99
|
def ordered?
|
99
100
|
definition.ordered?
|
100
101
|
end
|
@@ -151,4 +152,4 @@ module RR
|
|
151
152
|
definition.argument_expectation
|
152
153
|
end
|
153
154
|
end
|
154
|
-
end
|
155
|
+
end
|
@@ -2,6 +2,7 @@ module RR
|
|
2
2
|
module DoubleDefinitions
|
3
3
|
class ChildDoubleDefinitionCreate < DoubleDefinitionCreate # :nodoc
|
4
4
|
attr_reader :parent_double_definition
|
5
|
+
|
5
6
|
def initialize(parent_double_definition)
|
6
7
|
@parent_double_definition = parent_double_definition
|
7
8
|
super()
|
@@ -15,11 +16,11 @@ module RR
|
|
15
16
|
raise NoMethodError
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
+
protected
|
19
20
|
def add_strategy(subject, method_name, definition_eval_block, &block)
|
20
21
|
super do
|
21
22
|
block.call
|
22
|
-
parent_double_definition.implemented_by(lambda {|*args|subject})
|
23
|
+
parent_double_definition.implemented_by(lambda {|*args| subject })
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
@@ -2,6 +2,7 @@ module RR
|
|
2
2
|
module DoubleDefinitions
|
3
3
|
class DoubleDefinition #:nodoc:
|
4
4
|
ORIGINAL_METHOD = Object.new
|
5
|
+
|
5
6
|
attr_accessor(
|
6
7
|
:argument_expectation,
|
7
8
|
:times_matcher,
|
@@ -25,7 +26,7 @@ module RR
|
|
25
26
|
@verbose = false
|
26
27
|
@verify_method_signature = false
|
27
28
|
end
|
28
|
-
|
29
|
+
|
29
30
|
def subject
|
30
31
|
double_definition_create.subject
|
31
32
|
end
|
@@ -33,14 +34,14 @@ module RR
|
|
33
34
|
def root_subject
|
34
35
|
double_definition_create.root_subject
|
35
36
|
end
|
36
|
-
|
37
|
+
|
37
38
|
module ArgumentDefinitionConstructionMethods
|
38
39
|
# Double#with sets the expectation that the Double will receive
|
39
40
|
# the passed in arguments.
|
40
41
|
#
|
41
42
|
# Passing in a block sets the return value.
|
42
43
|
#
|
43
|
-
# mock(subject).method_name.with(1, 2) {:return_value}
|
44
|
+
# mock(subject).method_name.with(1, 2) {:return_value}
|
44
45
|
def with(*args, &return_value_block)
|
45
46
|
@argument_expectation = Expectations::ArgumentEqualityExpectation.new(*args)
|
46
47
|
install_method_callback return_value_block
|
@@ -69,7 +70,7 @@ module RR
|
|
69
70
|
@argument_expectation = Expectations::ArgumentEqualityExpectation.new()
|
70
71
|
install_method_callback return_value_block
|
71
72
|
self
|
72
|
-
end
|
73
|
+
end
|
73
74
|
end
|
74
75
|
include ArgumentDefinitionConstructionMethods
|
75
76
|
|
@@ -102,7 +103,7 @@ module RR
|
|
102
103
|
#
|
103
104
|
# Passing in a block sets the return value.
|
104
105
|
#
|
105
|
-
# mock(subject).method_name.twice {:return_value}
|
106
|
+
# mock(subject).method_name.twice {:return_value}
|
106
107
|
def twice(&return_value_block)
|
107
108
|
@times_matcher = TimesCalledMatchers::IntegerMatcher.new(2)
|
108
109
|
install_method_callback return_value_block
|
@@ -128,7 +129,7 @@ module RR
|
|
128
129
|
#
|
129
130
|
# Passing in a block sets the return value.
|
130
131
|
#
|
131
|
-
# mock(subject).method_name.at_most(4) {:return_value}
|
132
|
+
# mock(subject).method_name.at_most(4) {:return_value}
|
132
133
|
def at_most(number, &return_value_block)
|
133
134
|
@times_matcher = TimesCalledMatchers::AtMostMatcher.new(number)
|
134
135
|
install_method_callback return_value_block
|
@@ -141,7 +142,7 @@ module RR
|
|
141
142
|
#
|
142
143
|
# Passing in a block sets the return value.
|
143
144
|
#
|
144
|
-
# mock(subject).method_name.any_number_of_times
|
145
|
+
# mock(subject).method_name.any_number_of_times
|
145
146
|
def any_number_of_times(&return_value_block)
|
146
147
|
@times_matcher = TimesCalledMatchers::AnyTimesMatcher.new
|
147
148
|
install_method_callback return_value_block
|
@@ -154,7 +155,7 @@ module RR
|
|
154
155
|
#
|
155
156
|
# Passing in a block sets the return value.
|
156
157
|
#
|
157
|
-
# mock(subject).method_name.times(4) {:return_value}
|
158
|
+
# mock(subject).method_name.times(4) {:return_value}
|
158
159
|
def times(matcher_value, &return_value_block)
|
159
160
|
@times_matcher = TimesCalledMatchers::TimesCalledMatcher.create(matcher_value)
|
160
161
|
install_method_callback return_value_block
|
@@ -269,8 +270,8 @@ module RR
|
|
269
270
|
self
|
270
271
|
end
|
271
272
|
alias_method :strong, :verify_method_signature
|
272
|
-
|
273
|
-
|
273
|
+
|
274
|
+
protected
|
274
275
|
def install_method_callback(block)
|
275
276
|
if block
|
276
277
|
if implementation_is_original_method?
|
@@ -323,14 +324,15 @@ module RR
|
|
323
324
|
def verify_method_signature?
|
324
325
|
!!@verify_method_signature
|
325
326
|
end
|
326
|
-
alias_method :strong?, :verify_method_signature?
|
327
|
+
alias_method :strong?, :verify_method_signature?
|
327
328
|
|
328
|
-
|
329
|
+
protected
|
329
330
|
def implementation_strategy
|
330
331
|
double_definition_create.implementation_strategy
|
331
332
|
end
|
332
333
|
end
|
333
334
|
include StateQueryMethods
|
335
|
+
|
334
336
|
include ::RR::DoubleDefinitions::Strategies::StrategyMethods
|
335
337
|
|
336
338
|
def mock(subject=DoubleDefinitionCreate::NO_SUBJECT, method_name=nil, &definition_eval_block)
|
@@ -362,4 +364,4 @@ module RR
|
|
362
364
|
end
|
363
365
|
end
|
364
366
|
end
|
365
|
-
end
|
367
|
+
end
|
@@ -51,7 +51,7 @@ module RR
|
|
51
51
|
subject.__id__ === NO_SUBJECT.__id__
|
52
52
|
end
|
53
53
|
|
54
|
-
|
54
|
+
protected
|
55
55
|
def add_verification_strategy(verification_strategy_class, subject=NO_SUBJECT, method_name=nil, &definition_eval_block)
|
56
56
|
add_strategy(subject, method_name, definition_eval_block) do
|
57
57
|
self.verification_strategy = verification_strategy_class.new(self)
|
@@ -105,8 +105,10 @@ module RR
|
|
105
105
|
class DoubleDefinitionCreateError < Errors::RRError
|
106
106
|
end
|
107
107
|
|
108
|
-
|
108
|
+
## Verification Strategies
|
109
|
+
|
109
110
|
include ::RR::DoubleDefinitions::Strategies::StrategyMethods
|
111
|
+
|
110
112
|
def mock(subject=NO_SUBJECT, method_name=nil, &definition_eval_block)
|
111
113
|
self.add_verification_strategy(::RR::DoubleDefinitions::Strategies::Verification::Mock, subject, method_name, &definition_eval_block)
|
112
114
|
end
|
@@ -119,7 +121,8 @@ module RR
|
|
119
121
|
self.add_verification_strategy(::RR::DoubleDefinitions::Strategies::Verification::DontAllow, subject, method_name, &definition_eval_block)
|
120
122
|
end
|
121
123
|
|
122
|
-
|
124
|
+
## Implementation Strategies
|
125
|
+
|
123
126
|
def proxy(subject=NO_SUBJECT, method_name=nil, &definition_eval_block)
|
124
127
|
self.add_implementation_strategy(::RR::DoubleDefinitions::Strategies::Implementation::Proxy, subject, method_name, &definition_eval_block)
|
125
128
|
end
|
@@ -128,7 +131,8 @@ module RR
|
|
128
131
|
self.add_implementation_strategy(::RR::DoubleDefinitions::Strategies::Implementation::StronglyTypedReimplementation, subject, method_name, &definition_eval_block)
|
129
132
|
end
|
130
133
|
|
131
|
-
|
134
|
+
## DoubleInjection Strategies
|
135
|
+
|
132
136
|
def instance_of(subject=NO_SUBJECT, method_name=nil, &definition_eval_block)
|
133
137
|
self.add_double_injection_strategy(::RR::DoubleDefinitions::Strategies::DoubleInjection::AnyInstanceOf, subject, method_name, &definition_eval_block)
|
134
138
|
end
|
@@ -136,4 +140,4 @@ module RR
|
|
136
140
|
alias_method :all_instances_of, :instance_of
|
137
141
|
end
|
138
142
|
end
|
139
|
-
end
|
143
|
+
end
|