class Transpec::Syntax::MethodStub::AllowRecordBuilder

Public Instance Methods

new_syntax() click to toggle source
# 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_syntax() click to toggle source
# 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