Rspec stubbing method for only specific arguments

You can add a default stub for the fire! method which will call original implementation:

boss.stub(:fire!).and_call_original
boss.stub(:fire!).with(employee1).and_return(true)

Rspec 3 Syntax (@pk-nb)

allow(boss).to receive(:fire!).and_call_original
allow(boss).to receive(:fire!).with(employee1).and_return(true)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)