Read more

You can use any RSpec matcher to match arguments of method calls

Henning Koch
October 17, 2011Software engineer at makandra GmbH

RSpec lets you define the arguments with which you expect a method to be invoked:

subject.should_receive(:say).with('hello')
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

Sometimes you don't care about the exact arguments. For such cases RSpec comes with argument constraints Show archive.org snapshot like anything or hash_including:

subject.should_receive(:update_attributes).with(hash_including(:message => 'hi world'))

You can go even further and use any RSpec matcher to match arguments:

subject.should_receive(:say).with(instance_of(String))
Posted by Henning Koch to makandra dev (2011-10-17 16:01)