lib/rr/double_creator.rb in rr-0.4.2 vs lib/rr/double_creator.rb in rr-0.4.3
- old
+ new
@@ -48,11 +48,11 @@
# end
def mock(subject=NO_SUBJECT_ARG, method_name=nil, &definition)
strategy_error! if @strategy
@strategy = :mock
return self if subject.__id__ === NO_SUBJECT_ARG.__id__
- RR::Space.scenario_method_proxy(self, subject, method_name, &definition)
+ RR::Space.double_method_proxy(self, subject, method_name, &definition)
end
# This method sets the Double to have a stub strategy. A stub strategy
# sets the default state of the Double to expect the method call
# with any arguments any number of times. The Double's
@@ -83,11 +83,11 @@
# end
def stub(subject=NO_SUBJECT_ARG, method_name=nil, &definition)
strategy_error! if @strategy
@strategy = :stub
return self if subject.__id__ === NO_SUBJECT_ARG.__id__
- RR::Space.scenario_method_proxy(self, subject, method_name, &definition)
+ RR::Space.double_method_proxy(self, subject, method_name, &definition)
end
# This method sets the Double to have a dont_allow strategy.
# A dont_allow strategy sets the default state of the Double
# to expect never to be called. The Double's expectations can be
@@ -107,11 +107,11 @@
def dont_allow(subject=NO_SUBJECT_ARG, method_name=nil, &definition)
strategy_error! if @strategy
proxy_when_dont_allow_error! if @proxy
@strategy = :dont_allow
return self if subject.__id__ === NO_SUBJECT_ARG.__id__
- RR::Space.scenario_method_proxy(self, subject, method_name, &definition)
+ RR::Space.double_method_proxy(self, subject, method_name, &definition)
end
alias_method :do_not_allow, :dont_allow
alias_method :dont_call, :dont_allow
alias_method :do_not_call, :dont_allow
@@ -162,11 +162,11 @@
# end
def proxy(subject=NO_SUBJECT_ARG, method_name=nil, &definition)
proxy_when_dont_allow_error! if @strategy == :dont_allow
@proxy = true
return self if subject.__id__ === NO_SUBJECT_ARG.__id__
- RR::Space.scenario_method_proxy(self, subject, method_name, &definition)
+ RR::Space.double_method_proxy(self, subject, method_name, &definition)
end
alias_method :probe, :proxy
# Calling instance_of will cause all instances of the passed in Class
# to have the Double defined.
@@ -181,46 +181,46 @@
# end
def instance_of(subject=NO_SUBJECT_ARG, method_name=nil, &definition)
@instance_of = true
return self if subject === NO_SUBJECT_ARG
raise ArgumentError, "instance_of only accepts class objects" unless subject.is_a?(Class)
- RR::Space.scenario_method_proxy(self, subject, method_name, &definition)
+ RR::Space.double_method_proxy(self, subject, method_name, &definition)
end
def create!(subject, method_name, *args, &handler)
@args = args
@handler = handler
if @instance_of
setup_class_probing_instances(subject, method_name)
else
- setup_scenario(subject, method_name)
+ setup_double(subject, method_name)
end
transform!
@definition
end
protected
- def setup_scenario(subject, method_name)
+ def setup_double(subject, method_name)
@double_insertion = @space.double_insertion(subject, method_name)
- @scenario = @space.scenario(@double_insertion)
- @definition = @scenario.definition
+ @double = @space.double(@double_insertion)
+ @definition = @double.definition
end
def setup_class_probing_instances(subject, method_name)
class_double = @space.double_insertion(subject, :new)
- class_scenario = @space.scenario(class_double)
+ class_double = @space.double(class_double)
instance_method_name = method_name
- @definition = @space.scenario_definition
+ @definition = @space.double_definition
class_handler = proc do |return_value|
double_insertion = @space.double_insertion(return_value, instance_method_name)
- @space.scenario(double_insertion, @definition)
+ @space.double(double_insertion, @definition)
return_value
end
builder = DoubleDefinitionBuilder.new(
- class_scenario.definition,
+ class_double.definition,
[],
class_handler
)
builder.stub!
builder.proxy!