spec/money/formatting_spec.rb in money-5.1.1 vs spec/money/formatting_spec.rb in money-6.0.0.pre

- old
+ new

@@ -165,14 +165,20 @@ it "respects :subunit_to_unit currency property" do Money.new(10_00, "BHD").format(:no_cents => true).should == "ب.د1" end it "inserts thousand separators if symbol contains decimal mark and no_cents is true" do - Money.new(100000000, "AMD").format(no_cents: true).should == "1,000,000 դր." - Money.new(100000000, "USD").format(no_cents: true).should == "$1,000,000" - Money.new(100000000, "RUB").format(no_cents: true).should == "1.000.000 р." + Money.new(100000000, "AMD").format(:no_cents => true).should == "1,000,000 դր." + Money.new(100000000, "USD").format(:no_cents => true).should == "$1,000,000" + Money.new(100000000, "RUB").format(:no_cents => true).should == "1.000.000 р." end + + it "doesn't incorrectly format HTML" do + money = ::Money.new(1999, "RUB") + output = money.format(:html => true, :no_cents => true) + output.should == "19 &#x0440;&#x0443;&#x0431;" + end end describe ":no_cents_if_whole option" do specify "(:no_cents_if_whole => true) works as documented" do Money.new(10000, "VUV").format(:no_cents_if_whole => true, :symbol => false).should == "10,000" @@ -292,10 +298,14 @@ describe ":south_asian_number_formatting delimiter" do before(:each) do Money::Currency.register(JSON.parse(INDIAN_BAR, :symbolize_names => true)) end + after(:each) do + Money::Currency.unregister(JSON.parse(INDIAN_BAR, :symbolize_names => true)) + end + specify "(:south_asian_number_formatting => true) works as documented" do Money.new(10000000, 'INR').format(:south_asian_number_formatting => true, :symbol => false).should == "1,00,000.00" Money.new(1000000000, 'INDIAN_BAR').format(:south_asian_number_formatting => true, :symbol => false).should == "1,00,000.0000" Money.new(10000000).format(:south_asian_number_formatting => true).should == "$1,00,000.00" end @@ -337,10 +347,18 @@ string = Money.new(570, 'DKK').format(:html => true) string.should == "5,70 kr" end end + describe ":html_wrap_symbol option" do + specify "(:html_wrap_symbol => true) works as documented" do + string = Money.ca_dollar(570).format(:html_wrap_symbol => true) + string.should == "<span class=\"currency_symbol\">$</span>5.70" + end + end + + describe ":symbol_position option" do it "inserts currency symbol before the amount when set to :before" do Money.euro(1_234_567_12).format(:symbol_position => :before).should == "€1.234.567,12" end @@ -414,9 +432,14 @@ context "custom currencies with 4 decimal places" do before :each do Money::Currency.register(JSON.parse(BAR, :symbolize_names => true)) Money::Currency.register(JSON.parse(EU4, :symbolize_names => true)) + end + + after :each do + Money::Currency.unregister(JSON.parse(BAR, :symbolize_names => true)) + Money::Currency.unregister(JSON.parse(EU4, :symbolize_names => true)) end it "respects custom subunit to unit, decimal and thousands separator" do Money.new(4, "BAR").format.should == "$0.0004" Money.new(4, "EU4").format.should == "€0,0004"