spec/money/formatting_spec.rb in money-6.0.0.pre2 vs spec/money/formatting_spec.rb in money-6.0.0.pre3
- old
+ new
@@ -80,11 +80,13 @@
describe "#format" do
context "Locale :ja" do
before { @_locale = I18n.locale; I18n.locale = :ja }
it "formats Japanese currency in Japanese properly" do
- Money.new(1000, "JPY").format.should == "1,000円"
+ money = Money.new(1000, "JPY")
+ money.format.should == "1,000円"
+ money.format(:symbol => false).should == "1,000"
end
after { I18n.locale = @_locale }
end
@@ -131,11 +133,11 @@
# Brazilian Real
one_thousand["BRL"].should == "R$ 1.000,00"
# Other
- one_thousand["SEK"].should == "1.000,00 kr"
+ one_thousand["SEK"].should == "1 000,00 kr"
one_thousand["GHC"].should == "₵1,000.00"
end
it "inserts commas into the result if the amount is sufficiently large" do
Money.us_dollar(1_000_000_000_12).format.should == "$1,000,000,000.12"
@@ -263,10 +265,13 @@
specify "(:symbol => "", nil or false) returns the amount without a symbol" do
money = Money.new(100, "GBP")
money.format(:symbol => "").should == "1.00"
money.format(:symbol => nil).should == "1.00"
money.format(:symbol => false).should == "1.00"
+
+ money = Money.new(100, "JPY")
+ money.format(:symbol => false).should == "100"
end
it "defaults :symbol to true" do
money = Money.new(100)
money.format.should == "$1.00"
@@ -401,9 +406,37 @@
Money.euro(1_234_567_12).format(:symbol_position => :after, :symbol_after_without_space => false).should == "1.234.567,12 €"
end
it "defaults to false" do
Money.euro(1_234_567_12).format(:symbol_position => :after).should == "1.234.567,12 €"
+ end
+ end
+
+ describe ":sign_positive option" do
+ specify "(:sign_positive => true, :sign_before_symbol => true) works as documented" do
+ Money.us_dollar( 0).format(:sign_positive => true, :sign_before_symbol => true).should == "$0.00"
+ Money.us_dollar( 100000).format(:sign_positive => true, :sign_before_symbol => true).should == "+$1,000.00"
+ Money.us_dollar(-100000).format(:sign_positive => true, :sign_before_symbol => true).should == "-$1,000.00"
+ end
+
+ specify "(:sign_positive => true, :sign_before_symbol => false) works as documented" do
+ Money.us_dollar( 0).format(:sign_positive => true, :sign_before_symbol => false).should == "$0.00"
+ Money.us_dollar( 100000).format(:sign_positive => true, :sign_before_symbol => false).should == "$+1,000.00"
+ Money.us_dollar( 100000).format(:sign_positive => true, :sign_before_symbol => nil).should == "$+1,000.00"
+ Money.us_dollar(-100000).format(:sign_positive => true, :sign_before_symbol => false).should == "$-1,000.00"
+ Money.us_dollar(-100000).format(:sign_positive => true, :sign_before_symbol => nil).should == "$-1,000.00"
+ end
+
+ specify "(:sign_positive => false, :sign_before_symbol => true) works as documented" do
+ Money.us_dollar( 100000).format(:sign_positive => false, :sign_before_symbol => true).should == "$1,000.00"
+ Money.us_dollar(-100000).format(:sign_positive => false, :sign_before_symbol => true).should == "-$1,000.00"
+ end
+
+ specify "(:sign_positive => false, :sign_before_symbol => false) works as documented" do
+ Money.us_dollar( 100000).format(:sign_positive => false, :sign_before_symbol => false).should == "$1,000.00"
+ Money.us_dollar( 100000).format(:sign_positive => false, :sign_before_symbol => nil).should == "$1,000.00"
+ Money.us_dollar(-100000).format(:sign_positive => false, :sign_before_symbol => false).should == "$-1,000.00"
+ Money.us_dollar(-100000).format(:sign_positive => false, :sign_before_symbol => nil).should == "$-1,000.00"
end
end
context "when the monetary value is 0" do
let(:money) { Money.us_dollar(0) }