[rspec-users] how to wrtie this test?(test true but change when refactor)

David Chelimsky dchelimsky at gmail.com
Mon Sep 6 22:11:45 EDT 2010

On Sep 6, 2010, at 8:37 PM, Zhenning Guan wrote:

> David Chelimsky wrote:
>> I'm having a hard time understanding what you're trying to do here. Can 
>> you please post the full before and after code and spec listing in a 
>> gist or pastie?
>> http://gist.github.com
>> http://pastie.org
> the before just mock a user. and user request to withdraw money from 
> he's bank account, after that, we record his action like 'david withdraw 
> $10' in bankbook.
> the problem above is I expect one bankbook 'david withdraw $10' but 
> create two 'david withdraw $10'.in database, just because the I use last 
> api to receive last record.
> @ning.bankbooks.last.action.should == 'withdraw'
> I guess I should do a count check like
>  lambda{ withdrawal.process!}.should change {Bankbook.count}.by(1)

By "before and after" I meant what the code looked like before you made the change you want to make, and what it looked like after the change.

More information about the rspec-users mailing list