[rspec-users] NOOB question RSPEC

Federico Brubacher fbrubacher at gmail.com
Mon May 14 22:39:03 EDT 2007


Hi all !!

I have this code:
require 'account'

describe Account, "when first created" do
  before do
    @account = Account.new
  end

  it "should have a balance of $0" do
    @account.balance.should eql(Money.new(0, :dollars))
  end

  after do
    @account = nil
  end
end

How can I pass the @account.balance.should eql(Money.new(0, :dollars))
spec. From my understanding you .eql? in ruby is true if the object
are the same (reference points to same object) or if one inherits the
other.

I thought of using this code for Account :

class Account
  attr_accessor :balance
  def initialize
    self.balance = Money.new(0, :dollars)
  end
end

class Money < Account
  attr_accessor :amount, :currency
  def initialize(amount, currency)
    @amount = amount
    @currency = currency
  end
end

But still can make it work. It does not pass the spec.
Thanks !
-- 
Federico Brubacher
www.fbrubacher.com

Colonial Duty Free Shop
www.colonial.com.uy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070514/a6d01241/attachment.html 


More information about the rspec-users mailing list