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 collapse

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

Returns a new instance of DoubleDefinitionCreate.



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, kwargs, &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, kwargs, &handler)
  definition = DoubleDefinition.new(self)
  verification_strategy.call(definition, method_name, args, kwargs, handler)
  implementation_strategy.call(definition, method_name, args, kwargs, handler)
  double_injection_strategy.call(definition, method_name, args, kwargs, handler)
  definition
end

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



120
121
122
# File 'lib/rr/double_definitions/double_definition_create.rb', line 120

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



136
137
138
# File 'lib/rr/double_definitions/double_definition_create.rb', line 136

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



112
113
114
# File 'lib/rr/double_definitions/double_definition_create.rb', line 112

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



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

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



130
131
132
# File 'lib/rr/double_definitions/double_definition_create.rb', line 130

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



116
117
118
# File 'lib/rr/double_definitions/double_definition_create.rb', line 116

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