scrooge 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  require "bigdecimal"
2
2
 
3
3
  module Scrooge
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
 
6
6
  class Money
7
7
  include Comparable
@@ -76,7 +76,7 @@ module Scrooge
76
76
  end
77
77
 
78
78
  def to_s
79
- to_f.to_s
79
+ sprintf("%.2f", to_f)
80
80
  end
81
81
  end
82
82
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "scrooge"
3
- s.version = "0.1.2"
3
+ s.version = "0.1.3"
4
4
  s.date = "2010-01-28"
5
5
 
6
6
  s.description = "Class to serialize money into the database, works out of the box with ActiveRecord"
@@ -45,6 +45,16 @@ describe Money do
45
45
  end
46
46
  end
47
47
 
48
+ describe "converting to string" do
49
+ it "truncates 2 characters after the decimal point" do
50
+ (0.975).to_money.to_s.should == "0.97"
51
+ end
52
+
53
+ it "expands to two decimal places when there're less" do
54
+ 0.to_money.to_s.should == "0.00"
55
+ end
56
+ end
57
+
48
58
  describe "extending core classes" do
49
59
  it "allows to convert integers to money objects" do
50
60
  2.to_money.should == Money.new(200)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrooge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Nicol\xC3\xA1s Sanguinetti"