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

- (DoubleDefinitionCreate) initialize



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

- (Object) double_injection_strategy (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

- (Object) implementation_strategy (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

- (Object) subject (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

- (Object) verification_strategy (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

- (Object) call(method_name, *args, &handler)



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

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



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

- (Object) instance_of(subject = NO_SUBJECT, method_name = nil, &definition_eval_block) 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

- (Object) method_name



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

def method_name
  @verification_strategy.method_name
end

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



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

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

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

- (Object) root_subject



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

def root_subject
  subject
end

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



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

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



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