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

Zhenning Guan lists at ruby-forum.com
Mon Sep 6 21:37:29 EDT 2010

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)

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list