Class: Transpec::Syntax::ShouldReceive::ExpectBaseRecord

Inherits:
Record
  • Object
show all
Defined in:
lib/transpec/syntax/should_receive.rb

Direct Known Subclasses

AllowRecord, ExpectRecord

Instance Method Summary collapse

Methods inherited from Record

#==, #hash, #to_s

Constructor Details

#initialize(should_receive, negative_form_of_to) ⇒ ExpectBaseRecord

Returns a new instance of ExpectBaseRecord.



164
165
166
167
# File 'lib/transpec/syntax/should_receive.rb', line 164

def initialize(should_receive, negative_form_of_to)
  @should_receive = should_receive
  @negative_form_of_to = negative_form_of_to
end

Instance Method Details

#converted_syntaxObject



182
183
184
185
186
187
188
189
190
# File 'lib/transpec/syntax/should_receive.rb', line 182

def 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

#original_syntaxObject



173
174
175
176
177
178
179
180
# File 'lib/transpec/syntax/should_receive.rb', line 173

def original_syntax
  syntax = if @should_receive.any_instance?
             'Klass.any_instance.'
           else
             'obj.'
           end
  syntax << "#{@should_receive.method_name}(:message)"
end

#syntax_nameObject



169
170
171
# File 'lib/transpec/syntax/should_receive.rb', line 169

def syntax_name
  fail NotImplementedError
end