<br clear="all">Hi all !! <br> <p>I have this code: <br> require 'account' <br> </p><p>describe Account, "when first created" do <br> before do <br> @account = Account.new <br> end <br> </p><p> it "should have a balance of $0" do
<br> @account.balance.should eql(Money.new(0, :dollars)) <br> end <br> </p><p> after do <br> @account = nil <br> end <br> end <br> </p><p>How can I pass the @account.balance.should eql(Money.new(0, :dollars))
<br> spec. From my understanding you .eql? in ruby is true if the object <br> are the same (reference points to same object) or if one inherits the <br>other. <br></p><p>I thought of using this code for Account : <br></p>
<br>class Account<br> attr_accessor :balance<br> def initialize<br> self.balance = Money.new(0, :dollars)<br> end<br>end<br><br>class Money < Account<br> attr_accessor :amount, :currency<br> def initialize(amount, currency)
<br> @amount = amount<br> @currency = currency<br> end<br>end <br><p> But still can make it work. It does not pass the spec.<br> </p>Thanks ! <br>-- <br>Federico Brubacher<br><a href="http://www.fbrubacher.com">www.fbrubacher.com
</a><br><br>Colonial Duty Free Shop<br><a href="http://www.colonial.com.uy">www.colonial.com.uy</a>