Class: Transpec::Syntax::MethodStub::AllowRecordBuilder

Inherits:
RecordBuilder
  • Object
show all
Defined in:
lib/transpec/syntax/method_stub.rb

Instance Method Summary collapse

Methods inherited from RecordBuilder

build, #build, param_names

Instance Method Details

#new_syntaxObject



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/transpec/syntax/method_stub.rb', line 185

def new_syntax
  syntax = method_stub.any_instance? ? 'allow_any_instance_of(Klass)' : 'allow(obj)'
  syntax << '.to '

  case conversion_type
  when :allow_to_receive
    syntax << 'receive(:message)'
    syntax << '.and_return(value)' if method_stub.hash_arg?
    syntax << '.and_call_original' if method_stub.unstub?
  when :allow_to_receive_messages
    syntax << 'receive_messages(:message => value)'
  when :allow_to_receive_message_chain
    syntax << 'receive_message_chain(:message1, :message2)'
  end

  syntax
end

#old_syntaxObject



174
175
176
177
178
179
180
181
182
183
# File 'lib/transpec/syntax/method_stub.rb', line 174

def old_syntax
  syntax = method_stub.any_instance? ? 'Klass.any_instance' : 'obj'
  syntax << ".#{method_stub.method_name}"

  if method_stub.method_name == :stub_chain
    syntax << '(:message1, :message2)'
  else
    syntax << (method_stub.hash_arg? ? '(:message => value)' : '(:message)')
  end
end