bd_money 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.13
1
+ 0.0.14
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bd_money}
8
- s.version = "0.0.13"
8
+ s.version = "0.0.14"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Adrian Madrid"]
@@ -190,7 +190,7 @@ class Money
190
190
 
191
191
  alias :inspect :to_s
192
192
 
193
- def to_json
193
+ def to_json(options = nil)
194
194
  to_s
195
195
  end
196
196
 
@@ -12,6 +12,11 @@ class Money
12
12
  amount
13
13
  end
14
14
 
15
+ # For better json decoding
16
+ def as_json(options = nil)
17
+ to_s
18
+ end
19
+
15
20
  end
16
21
 
17
22
  module ActiveRecord #:nodoc:
@@ -81,5 +81,14 @@ describe Money do
81
81
  it { subject.amount.amount.to_s('F').should == '300.0' }
82
82
  it { subject.apr.amount.to_s('F').should == '0.1234' }
83
83
  end
84
+
85
+ describe "should provide valid json encoding" do
86
+ subject { BetterLoanExample.new :amount => 300, :apr => 0.123456789 }
87
+ it { subject.amount.as_json.should == '300.00' }
88
+ it { subject.apr.as_json.should == '0.1234' }
89
+ it { subject.as_json.should == {"apr"=>0.1234, "amount"=>300.00} }
90
+ it { subject.to_json.should == '{"apr":0.1234,"amount":300.00}' }
91
+ end
92
+
84
93
  end
85
94
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bd_money
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 13
10
- version: 0.0.13
9
+ - 14
10
+ version: 0.0.14
11
11
  platform: ruby
12
12
  authors:
13
13
  - Adrian Madrid