eeng-money 0.0.1 → 0.1.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.
- checksums.yaml +7 -0
- data/.rbenv-version +1 -0
- data/acts_as_money.gemspec +1 -0
- data/lib/acts_as_money/money.rb +1 -1
- data/lib/acts_as_money/version.rb +1 -1
- data/test/acts_as_money/money_test.rb +17 -17
- data/test/test_helper.rb +7 -7
- metadata +28 -25
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 36d204d3f3322dd383b45d8702e83b9cd9c138af
|
4
|
+
data.tar.gz: 9680f55709361e4faee172f0ff5476842482363d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 92b6384497a0be1543f872362ae3ea1c4d480ac5db969eb3984d157dcc8a7206fb32267f2546a066aa8cf6a517c075b995529c80c84e4e1e95ab4a7722a8006b
|
7
|
+
data.tar.gz: 51f9870396baf31473c9a5f68b9d52c1128957df95a6bf5f986d70486515ead8a23034dbcca4861352178cdd4a81009fa785e86a0351da3ca41363d4194c0b4c
|
data/.rbenv-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.0
|
data/acts_as_money.gemspec
CHANGED
data/lib/acts_as_money/money.rb
CHANGED
@@ -5,50 +5,50 @@ module ActsAsMoney
|
|
5
5
|
money :price, :tax, :discount
|
6
6
|
end
|
7
7
|
|
8
|
-
class AssignmentMoneyTest < Test
|
8
|
+
class AssignmentMoneyTest < Minitest::Test
|
9
9
|
def test_rounding_new
|
10
|
-
assert_equal 19.64, Product.new(:
|
11
|
-
assert_equal 0.67, Product.new(:
|
10
|
+
assert_equal 19.64, Product.new(price: (78.55 * 0.25).to_d).price
|
11
|
+
assert_equal 0.67, Product.new(tax: 2.0/3.0).tax
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_rounding_persisted
|
15
|
-
assert_equal 0.67, Product.create(:
|
15
|
+
assert_equal 0.67, Product.create(tax: 2.0/3.0).reload.tax
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_nils
|
19
|
-
assert_nil Product.new(:
|
19
|
+
assert_nil Product.new(price: nil).price
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_other_types
|
23
|
-
assert_equal 10, Product.new(:
|
24
|
-
assert_equal 10.24, Product.new(:
|
23
|
+
assert_equal 10, Product.new(price: 10).price
|
24
|
+
assert_equal 10.24, Product.new(price: "10.235").price
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_should_use_bigdecimal
|
28
|
-
assert_equal BigDecimal, Product.new(:
|
29
|
-
assert_equal Money, Product.new(:
|
28
|
+
assert_equal BigDecimal, Product.new(price: 1).price.amount.class
|
29
|
+
assert_equal Money, Product.new(price: 1).price.class
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_should_use_scale_from_column_for_decimales_pieces
|
33
|
-
assert_equal 3, Product.new(:
|
34
|
-
assert_equal 3, Product.create(:
|
33
|
+
assert_equal 3, Product.new(discount: 2).discount.decimals
|
34
|
+
assert_equal 3, Product.create(discount: 2).reload.discount.decimals
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
class OperationsTest < Test
|
38
|
+
class OperationsTest < Minitest::Test
|
39
39
|
def test_rounding_multiplication
|
40
40
|
assert_equal 19.64, Money.new(78.55) * 0.25
|
41
41
|
assert_equal 4.28, Money.new(28.5) * 0.15
|
42
42
|
assert_equal 12.0897, Money.new(10.9906, 4) * 1.1
|
43
|
-
assert_equal 12.092, Product.new(:
|
43
|
+
assert_equal 12.092, Product.new(discount: 10.993).discount * 1.1
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_rounding_division
|
47
|
-
assert_equal 0.67, Product.new(:
|
47
|
+
assert_equal 0.67, Product.new(price: 2).price / 3.0
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_should_return_money
|
51
|
-
assert_equal Money, (Product.new(:
|
51
|
+
assert_equal Money, (Product.new(price: 1).price * 2).class
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_sum_should_return_money
|
@@ -59,7 +59,7 @@ module ActsAsMoney
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
class ComparissonTest < Test
|
62
|
+
class ComparissonTest < Minitest::Test
|
63
63
|
def test_should_be_equal
|
64
64
|
assert Money.new(1) == Money.new(1)
|
65
65
|
end
|
@@ -70,7 +70,7 @@ module ActsAsMoney
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
class ToStringTest < Test
|
73
|
+
class ToStringTest < Minitest::Test
|
74
74
|
def test_when_nil
|
75
75
|
assert_equal "$0.00", Money.new(nil).to_s
|
76
76
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require '
|
1
|
+
require 'minitest/autorun'
|
2
2
|
require 'active_record'
|
3
3
|
require "#{File.dirname(__FILE__)}/../lib/acts_as_money"
|
4
4
|
|
5
|
-
ActiveRecord::Base.establish_connection(:
|
5
|
+
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
|
6
6
|
|
7
|
-
class Test
|
7
|
+
class Minitest::Test #:nodoc:
|
8
8
|
def setup
|
9
|
-
ActiveRecord::Schema.define(:
|
9
|
+
ActiveRecord::Schema.define(version: 1) do
|
10
10
|
create_table :products do |t|
|
11
|
-
t.column :price, :decimal, :
|
12
|
-
t.column :tax, :decimal, :
|
13
|
-
t.column :discount, :decimal, :
|
11
|
+
t.column :price, :decimal, precision: 12, scale: 2
|
12
|
+
t.column :tax, :decimal, precision: 12, scale: 2
|
13
|
+
t.column :discount, :decimal, precision: 12, scale: 3
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
metadata
CHANGED
@@ -1,46 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eeng-money
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Emmanuel Nicolau
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-07-29 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activerecord
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 3.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 3.0.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: sqlite3
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
44
53
|
- !ruby/object:Gem::Version
|
45
54
|
version: '0'
|
46
55
|
description: Single currency money backed by BigDecimal
|
@@ -50,8 +59,9 @@ executables: []
|
|
50
59
|
extensions: []
|
51
60
|
extra_rdoc_files: []
|
52
61
|
files:
|
53
|
-
- .DS_Store
|
54
|
-
- .gitignore
|
62
|
+
- ".DS_Store"
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rbenv-version"
|
55
65
|
- Gemfile
|
56
66
|
- LICENSE.txt
|
57
67
|
- README.md
|
@@ -65,33 +75,26 @@ files:
|
|
65
75
|
- test/test_helper.rb
|
66
76
|
homepage: ''
|
67
77
|
licenses: []
|
78
|
+
metadata: {}
|
68
79
|
post_install_message:
|
69
80
|
rdoc_options: []
|
70
81
|
require_paths:
|
71
82
|
- lib
|
72
83
|
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
84
|
requirements:
|
75
|
-
- -
|
85
|
+
- - ">="
|
76
86
|
- !ruby/object:Gem::Version
|
77
87
|
version: '0'
|
78
|
-
segments:
|
79
|
-
- 0
|
80
|
-
hash: -1914526830248602656
|
81
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
89
|
requirements:
|
84
|
-
- -
|
90
|
+
- - ">="
|
85
91
|
- !ruby/object:Gem::Version
|
86
92
|
version: '0'
|
87
|
-
segments:
|
88
|
-
- 0
|
89
|
-
hash: -1914526830248602656
|
90
93
|
requirements: []
|
91
94
|
rubyforge_project:
|
92
|
-
rubygems_version:
|
95
|
+
rubygems_version: 2.4.1
|
93
96
|
signing_key:
|
94
|
-
specification_version:
|
97
|
+
specification_version: 4
|
95
98
|
summary: Single currency money backed by BigDecimal
|
96
99
|
test_files:
|
97
100
|
- test/.DS_Store
|