Class: Transpec::Syntax::ShouldReceive::ExpectBaseRecord
- Defined in:
- lib/transpec/syntax/should_receive.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Record
Record::OVERRIDDE_FORBIDDEN_METHODS
Instance Attribute Summary
Attributes inherited from Record
#annotation, #converted_syntax_type, #original_syntax_type
Instance Method Summary collapse
- #build_converted_syntax ⇒ Object
- #build_original_syntax ⇒ Object
-
#initialize(should_receive, negative_form_of_to) ⇒ ExpectBaseRecord
constructor
A new instance of ExpectBaseRecord.
- #syntax_name ⇒ Object
Methods inherited from Record
#==, #converted_syntax, #hash, #original_syntax, #to_s
Constructor Details
#initialize(should_receive, negative_form_of_to) ⇒ ExpectBaseRecord
Returns a new instance of ExpectBaseRecord.
166 167 168 169 |
# File 'lib/transpec/syntax/should_receive.rb', line 166 def initialize(should_receive, negative_form_of_to) @should_receive = should_receive @negative_form_of_to = negative_form_of_to end |
Instance Method Details
#build_converted_syntax ⇒ Object
184 185 186 187 188 189 190 191 192 |
# File 'lib/transpec/syntax/should_receive.rb', line 184 def build_converted_syntax syntax = if @should_receive.any_instance? "#{syntax_name}_any_instance_of(Klass)." else "#{syntax_name}(obj)." end syntax << (@should_receive.positive? ? 'to' : @negative_form_of_to) syntax << ' receive(:message)' end |
#build_original_syntax ⇒ Object
175 176 177 178 179 180 181 182 |
# File 'lib/transpec/syntax/should_receive.rb', line 175 def build_original_syntax syntax = if @should_receive.any_instance? 'Klass.any_instance.' else 'obj.' end syntax << "#{@should_receive.method_name}(:message)" end |
#syntax_name ⇒ Object
171 172 173 |
# File 'lib/transpec/syntax/should_receive.rb', line 171 def syntax_name fail NotImplementedError end |