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

Zhenning Guan lists at ruby-forum.com
Mon Sep 6 22:28:54 EDT 2010


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
    bankbook = bankbooks.build
    bankbook.withdraw
end
--

hope I clear my thought.
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list