bd_money 0.0.4 → 0.0.5

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.0.4
1
+ 0.0.5
data/bd_money.gemspec CHANGED
@@ -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.4"
8
+ s.version = "0.0.5"
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"]
@@ -158,7 +158,7 @@ class Money
158
158
  end
159
159
 
160
160
  def to_f(this_precision = precision, this_round_mode = round_mode)
161
- round_amount(this_precision, this_round_mode).to_i
161
+ round_amount(this_precision, this_round_mode).to_f
162
162
  end
163
163
 
164
164
  def to_s(this_precision = precision, this_round_mode = round_mode)
@@ -189,6 +189,30 @@ describe Money do
189
189
  it { Money.new('0').should be_zero }
190
190
  it { Money.new('0.0').should be_zero }
191
191
  end
192
+ describe "to_i" do
193
+ describe "positive" do
194
+ subject { Money.new(3.21).to_i }
195
+ it { subject.should == 3 }
196
+ it { subject.should be_a Integer }
197
+ end
198
+ describe "negative" do
199
+ subject { Money.new(-3.21).to_i }
200
+ it { subject.should == -3 }
201
+ it { subject.should be_a Integer }
202
+ end
203
+ end
204
+ describe "to_f" do
205
+ describe "positive" do
206
+ subject { Money.new(3.21).to_f }
207
+ it { subject.should == 3.21 }
208
+ it { subject.should be_a Float }
209
+ end
210
+ describe "negative" do
211
+ subject { Money.new(-3.21).to_f }
212
+ it { subject.should == -3.21 }
213
+ it { subject.should be_a Float }
214
+ end
215
+ end
192
216
  end
193
217
 
194
218
  describe "to_s" do
@@ -272,18 +296,18 @@ describe Money do
272
296
  end
273
297
 
274
298
  describe "format" do
275
- let(:amt){ '1234567.12'}
276
- let(:neg_amt){ '-1234567.12'}
277
- it {subject.formatted().should == '$ 1,234,567.12'}
278
- it {subject.formatted(:no_cents).should == '$ 1,234,567'}
279
- it {subject.formatted(:no_commas).should == '$ 1234567.12'}
280
- it {subject.formatted(:precision => 1).should == '$ 1,234,567.1'}
281
- it {subject.formatted(:no_commas, :precision => 1).should == '$ 1234567.1'}
282
- it {neg_subject.formatted().should == '$ -1,234,567.12'}
283
- it {neg_subject.formatted(:no_cents).should == '$ -1,234,567'}
284
- it {neg_subject.formatted(:no_commas).should == '$ -1234567.12'}
285
- it {neg_subject.formatted(:precision => 1).should == '$ -1,234,567.1'}
286
- it {neg_subject.formatted(:no_commas, :precision => 1).should == '$ -1234567.1'}
299
+ let(:amt) { '1234567.12' }
300
+ let(:neg_amt) { '-1234567.12' }
301
+ it { subject.formatted().should == '$ 1,234,567.12' }
302
+ it { subject.formatted(:no_cents).should == '$ 1,234,567' }
303
+ it { subject.formatted(:no_commas).should == '$ 1234567.12' }
304
+ it { subject.formatted(:precision => 1).should == '$ 1,234,567.1' }
305
+ it { subject.formatted(:no_commas, :precision => 1).should == '$ 1234567.1' }
306
+ it { neg_subject.formatted().should == '$ -1,234,567.12' }
307
+ it { neg_subject.formatted(:no_cents).should == '$ -1,234,567' }
308
+ it { neg_subject.formatted(:no_commas).should == '$ -1234567.12' }
309
+ it { neg_subject.formatted(:precision => 1).should == '$ -1,234,567.1' }
310
+ it { neg_subject.formatted(:no_commas, :precision => 1).should == '$ -1234567.1' }
287
311
  end
288
312
 
289
313
  describe "forwarded" do
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: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Adrian Madrid