Class: RR::DoubleDefinitions::DoubleDefinitionCreate

Inherits:
Object
  • Object
show all
Includes:
StrategySetupMethods, Strategies::StrategyMethods, Space::Reader
Defined in:
lib/rr/double_definitions/double_definition_create.rb

Overview

:nodoc

Direct Known Subclasses

ChildDoubleDefinitionCreate

Defined Under Namespace

Modules: StrategySetupMethods Classes: DoubleDefinitionCreateError

Constant Summary

NO_SUBJECT =
Object.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Strategies::StrategyMethods

#any_instance_of!, #dont_allow!, #instance_of!, #mock!, #proxy!, #strong!, #stub!

Methods included from StrategySetupMethods

#no_subject?

Methods included from Space::Reader

#space

Constructor Details

#initializeDoubleDefinitionCreate



27
28
29
30
31
# File 'lib/rr/double_definitions/double_definition_create.rb', line 27

def initialize
  @verification_strategy = Strategies::Verification::Stub.new(self)
  @implementation_strategy = Strategies::Implementation::Reimplementation.new(self)
  @double_injection_strategy = self.class.default_double_injection_strategy.call(self)
end

Instance Attribute Details

#double_injection_strategyObject (readonly)

Returns the value of attribute double_injection_strategy



22
23
24
# File 'lib/rr/double_definitions/double_definition_create.rb', line 22

def double_injection_strategy
  @double_injection_strategy
end

#implementation_strategyObject (readonly)

Returns the value of attribute implementation_strategy



22
23
24
# File 'lib/rr/double_definitions/double_definition_create.rb', line 22

def implementation_strategy
  @implementation_strategy
end

#subjectObject (readonly)

Returns the value of attribute subject



22
23
24
# File 'lib/rr/double_definitions/double_definition_create.rb', line 22

def subject
  @subject
end

#verification_strategyObject (readonly)

Returns the value of attribute verification_strategy



22
23
24
# File 'lib/rr/double_definitions/double_definition_create.rb', line 22

def verification_strategy
  @verification_strategy
end

Instance Method Details

#call(method_name, *args, &handler) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/rr/double_definitions/double_definition_create.rb', line 33

def call(method_name, *args, &handler)
  definition = DoubleDefinition.new(self)
  verification_strategy.call(definition, method_name, args, handler)
  implementation_strategy.call(definition, method_name, args, handler)
  double_injection_strategy.call(definition, method_name, args, handler)
  definition
end

#dont_allow(subject = NO_SUBJECT, method_name = nil, &definition_eval_block) ⇒ Object



118
119
120
# File 'lib/rr/double_definitions/double_definition_create.rb', line 118

def dont_allow(subject=NO_SUBJECT, method_name=nil, &definition_eval_block)
  self.add_verification_strategy(::RR::DoubleDefinitions::Strategies::Verification::DontAllow, subject, method_name, &definition_eval_block)
end

#instance_of(subject = NO_SUBJECT, method_name = nil, &definition_eval_block) ⇒ Object Also known as: any_instance_of, all_instances_of

DoubleInjection Strategies



132
133
134
# File 'lib/rr/double_definitions/double_definition_create.rb', line 132

def instance_of(subject=NO_SUBJECT, method_name=nil, &definition_eval_block)
  self.add_double_injection_strategy(::RR::DoubleDefinitions::Strategies::DoubleInjection::AnyInstanceOf, subject, method_name, &definition_eval_block)
end

#method_nameObject



45
46
47
# File 'lib/rr/double_definitions/double_definition_create.rb', line 45

def method_name
  @verification_strategy.method_name
end

#mock(subject = NO_SUBJECT, method_name = nil, &definition_eval_block) ⇒ Object



110
111
112
# File 'lib/rr/double_definitions/double_definition_create.rb', line 110

def mock(subject=NO_SUBJECT, method_name=nil, &definition_eval_block)
  self.add_verification_strategy(::RR::DoubleDefinitions::Strategies::Verification::Mock, subject, method_name, &definition_eval_block)
end

#proxy(subject = NO_SUBJECT, method_name = nil, &definition_eval_block) ⇒ Object

Implementation Strategies



123
124
125
# File 'lib/rr/double_definitions/double_definition_create.rb', line 123

def proxy(subject=NO_SUBJECT, method_name=nil, &definition_eval_block)
  self.add_implementation_strategy(::RR::DoubleDefinitions::Strategies::Implementation::Proxy, subject, method_name, &definition_eval_block)
end

#root_subjectObject



41
42
43
# File 'lib/rr/double_definitions/double_definition_create.rb', line 41

def root_subject
  subject
end

#strong(subject = NO_SUBJECT, method_name = nil, &definition_eval_block) ⇒ Object



127
128
129
# File 'lib/rr/double_definitions/double_definition_create.rb', line 127

def strong(subject=NO_SUBJECT, method_name=nil, &definition_eval_block)
  self.add_implementation_strategy(::RR::DoubleDefinitions::Strategies::Implementation::StronglyTypedReimplementation, subject, method_name, &definition_eval_block)
end

#stub(subject = NO_SUBJECT, method_name = nil, &definition_eval_block) ⇒ Object



114
115
116
# File 'lib/rr/double_definitions/double_definition_create.rb', line 114

def stub(subject=NO_SUBJECT, method_name=nil, &definition_eval_block)
  self.add_verification_strategy(::RR::DoubleDefinitions::Strategies::Verification::Stub, subject, method_name, &definition_eval_block)
end