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

David Chelimsky dchelimsky at gmail.com
Tue Sep 7 06:44:58 EDT 2010


On Sep 6, 2010, at 9:28 PM, Zhenning Guan wrote:

> David Chelimsky wrote:
>> 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.
> 
> 
> sorry I misunderstood your word.
> 
> 
> 
> def process!
>  #transaction block
>    bankbook = self.bankbooks.build
>    bankbook = user.bank.bankbooks.build
>    bankbook.withdraw
>  #end
> end
> 
> that's the before code.and I change it to.
> 
> def process!
>  #transaction block
>   bank.withdraw
>  #end
> end
> 
> because I have been miss the create banbooks in bank model withdraw 
> method.
> code like
> --
> # bank model
> def xxxx

Is this withdraw instead of xxxx?

>    bankbook = bankbooks.build
>    bankbook.withdraw
> end
> --
> 
> hope I clear my thought.

In your original post you said you were getting two bankbook items after the change. Do you want one or two? And where is the 2nd one coming from?


More information about the rspec-users mailing list