bd_money 0.0.12 → 0.0.13
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 +1 -1
- data/bd_money.gemspec +2 -2
- data/lib/bd_money/bd_money.rb +4 -0
- data/spec/bd_money_spec.rb +34 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.13
|
data/bd_money.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bd_money}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.13"
|
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"]
|
12
|
-
s.date = %q{2012-
|
12
|
+
s.date = %q{2012-06-18}
|
13
13
|
s.description = %q{This library makes it easier to deal with Money values, storing them as BigDecimal to avoid floating-point math errors.}
|
14
14
|
s.email = %q{aemadrid@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/bd_money/bd_money.rb
CHANGED
data/spec/bd_money_spec.rb
CHANGED
@@ -313,6 +313,40 @@ describe Money do
|
|
313
313
|
end
|
314
314
|
end
|
315
315
|
|
316
|
+
describe "to_json" do
|
317
|
+
describe "no decimals" do
|
318
|
+
let(:amt) { '3' }
|
319
|
+
it { subject.to_json.should == "#{amt}.00" }
|
320
|
+
end
|
321
|
+
describe "one decimal" do
|
322
|
+
let(:amt) { '3.5' }
|
323
|
+
it { subject.to_json.should == "#{amt}0" }
|
324
|
+
end
|
325
|
+
describe "two decimals" do
|
326
|
+
let(:amt) { '3.53' }
|
327
|
+
it { subject.to_json.should == amt }
|
328
|
+
end
|
329
|
+
describe "three decimals" do
|
330
|
+
let(:amt) { '3.534' }
|
331
|
+
it { subject.to_json.should == amt[0, 4] }
|
332
|
+
end
|
333
|
+
describe "four decimals" do
|
334
|
+
let(:amt) { '3.5343' }
|
335
|
+
it { subject.to_json.should == amt[0, 4] }
|
336
|
+
end
|
337
|
+
describe "five decimals" do
|
338
|
+
let(:amt) { '3.53434' }
|
339
|
+
it { subject.to_json.should == amt[0, 4] }
|
340
|
+
end
|
341
|
+
describe "six decimals" do
|
342
|
+
let(:amt) { '3.534343' }
|
343
|
+
it { subject.to_json.should == amt[0, 4] }
|
344
|
+
end
|
345
|
+
describe "not a number" do
|
346
|
+
it { nan_subject.to_json.should == "NaN" }
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
316
350
|
describe "to_big_decimal" do
|
317
351
|
let(:bd_amt) { BigDecimal.new(amt) }
|
318
352
|
it { bd_amt.should == subject.to_big_decimal }
|
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:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 13
|
10
|
+
version: 0.0.13
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Adrian Madrid
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-06-18 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|