spec/money/money_spec.rb in nofxx-money-2.3.9 vs spec/money/money_spec.rb in nofxx-money-2.3.10

- old
+ new

@@ -189,21 +189,34 @@ end describe "Format out " do + describe "Symbols" do + before(:each) do + @one = Proc.new { |cur| Money.new(100, cur).format } + end + it { @one["BRL"].should eql "R$1,00" } + it { @one["USD"].should eql "$1.00" } + it { @one["EUR"].should eql "€1.00" } + it { @one["CAD"].should eql "$1.00" } + it { @one["HKD"].should eql "$1.00" } + it { @one["SGD"].should eql "$1.00" } + it { @one["ZWD"].should eql "Z$1.00" } + it { @one["GBP"].should eql "£1.00" } + it { @one["JPY"].should eql "¥1.00" } + end + describe "Options" do before(:each) do @cash = Money.new(2_00, "JPY") end - it { @cash.format.should eql("¥2.00") } it { @cash.format(:symbol => "R$ ").should eql("R$ 2.00") } it { @cash.format(:no_cents => true).should eql("¥2") } it { @cash.format(:no_cents => true, :symbol => "R$ ").should eql("R$ 2") } it { @cash.format(:html => true).should eql("¥2.00") } - end it { Money.new(0).format.should eql("$0.00") } it { Money.new(0).format(:display_free => true).should eql("free") } it { Money.new(0).format(:display_free => "GRATIS").should eql("GRATIS") } @@ -220,9 +233,13 @@ it { Money.new(800000000, "BRL").format.should eql("R$8.000.000,00") } it { Money.new(8000000000, "BRL").format.should eql("R$80.000.000,00") } it { Money.new(80000000000, "CAD").format.should eql("$800,000,000.00") } it { Money.new(880000000000, "GBP").format(:no_cents => true).should eql("£8,800,000,000") } it { Money.new(8800000000088, "EUR").format.should eql("€88,000,000,000.88") } + it { Money.new("10000", "BRL").format.should eql("R$100,00") } + it { Money.new("10000", "USD").format.should eql("$100.00") } + it { "10,000.00 USD".to_money.format.should eql("$10,000.00") } + it { "10,000.00 BRL".to_money.format.should eql("R$10.000,00") } it "should fail nicely if symbol can`t be found" do Money.stub!(:default_currency).and_return("XXX") Money.new(800).format.should eql("$8.00") end