has_money 0.1.2 → 0.2.0

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.0
data/has_money.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{has_money}
8
- s.version = "0.1.2"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Greg Bell}, %q{Sam Vincent}, %q{Philippe Creux}]
12
- s.date = %q{2011-08-19}
12
+ s.date = %q{2011-09-09}
13
13
  s.description = %q{Parsing the various ways people enter dollar amounts so you don't have to. Store values in cents as integer.}
14
14
  s.email = %q{sam.vincent@mac.com}
15
15
  s.extra_rdoc_files = [
data/lib/has_money.rb CHANGED
@@ -24,7 +24,7 @@ module HasMoney
24
24
 
25
25
  def calculate_dollars_from_cents(cents)
26
26
  return nil if cents.nil? || cents == ''
27
- (BigDecimal(cents.to_s) / 100).to_f
27
+ "%.2f" % (BigDecimal(cents.to_s) / 100).to_f
28
28
  end
29
29
 
30
30
  def calculate_cents_from_dollars(dollars)
@@ -1,4 +1,4 @@
1
-
1
+ require 'active_record'
2
2
  require File.expand_path(File.dirname(__FILE__) + '/../lib/has_money')
3
3
 
4
4
  describe HasMoney do
@@ -32,7 +32,7 @@ describe HasMoney do
32
32
  end
33
33
 
34
34
  it "should return the amount in dollars" do
35
- @product.price_in_dollars.should == 29.99
35
+ @product.price_in_dollars.should == '29.99'
36
36
  end
37
37
 
38
38
  it "should set the amount in dollars with a float" do
@@ -95,6 +95,11 @@ describe HasMoney do
95
95
  @product.price.should == nil
96
96
  end
97
97
 
98
+ it "should return string formatted to two decimal places" do
99
+ @product.price_in_dollars = '99'
100
+ @product.price_in_dollars.should == '99.00'
101
+ end
102
+
98
103
  it "should return nil if the attribute is nil" do
99
104
  @product.price = nil
100
105
  @product.price_in_dollars.should == nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_money
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-08-19 00:00:00.000000000Z
14
+ date: 2011-09-09 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
18
- requirement: &70107766657440 !ruby/object:Gem::Requirement
18
+ requirement: &70239510410400 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,7 +23,7 @@ dependencies:
23
23
  version: 1.2.9
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: *70107766657440
26
+ version_requirements: *70239510410400
27
27
  description: Parsing the various ways people enter dollar amounts so you don't have
28
28
  to. Store values in cents as integer.
29
29
  email: sam.vincent@mac.com