[rspec-users] there should be one test or two?

Matt Wynne matt at mattwynne.net
Fri Aug 27 11:42:55 EDT 2010


Hi Zhenning,

One assertion per test [1] is a good rule of thumb, but don't get too hung up about it.

[1] http://blog.jayfields.com/2007/06/testing-one-assertion-per-test.html

On 27 Aug 2010, at 06:43, Zhenning Guan wrote:

> in real world, when user deposit money into their bank, bank have money
> and can check deposit record. so what would it be in rspec?
> 
> it 'should be deposit $10'
>  user.bank.deposit(10)
>  user.bank.deposit.saving.should == 10
> end
> 
> about test , should be deposit $10 is clear? maybe 'should deposit $10
> success'?
> 
> and when deposit, we should have a deposit record. added another test?
> 
> it 'should be a deposit record when deposit $10'
>  user.bank.deposit(10)
>  user.deposit_record.should == #something.
> end
> 
> or just mixed it in one test?
> 
> it 'should be deposit $10'
>  user.bank.deposit(10)
>  user.bank.deposit.saving.should == 10
>  user.deposit_record.should == #something.
> end
> -- 
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

cheers,
Matt

http://blog.mattwynne.net
+44(0)7974 430184



More information about the rspec-users mailing list