mongoid_money_field 4.0.7 → 4.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13fd2be521b2ea8721b0531787b531f57f3d7467
4
- data.tar.gz: 3de18d51cfc1ce923353f25e68cabc840bf4c927
3
+ metadata.gz: 98301ef0d0c01eda3e2dfbb588e4b23649399c39
4
+ data.tar.gz: 253619673f52ee7d97c6a6efcb5e4a8e1315eade
5
5
  SHA512:
6
- metadata.gz: 3d8f6dc6e7c7c7ca33a7dd84855b633f69a303535f34e7bfc3d34b381a4cbd2fdd33f08f7ef153375ed2fba7f0f0e3ceb1106fc2ce9c2bfa709a7766f6e032f9
7
- data.tar.gz: 0e02e71d00c15d529ea6011278e960312d18d6d94713ea55c07ec9bed5155a77b279231950b234220170509ef8a83ed22f3b6d036043ee90c39943b660b236e7
6
+ metadata.gz: c809646376f3f0fb429df3dd700f8f378a77b3e82eb6e36cb3de61302727538470cbbdd6871848c4425a0dcf01165b16ef988fd49209130cf6f7c2d2682e51b3
7
+ data.tar.gz: 98f7746d6548bb709c25c5ae48841c19a50271158f0bb889a3afdf838b8ed28f0cdc5e4ef5d15e8dfb7b1dae28f387769417ea532bc4bde5257c0501b2806836
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.0.0-p353
1
+ 2.1.2
data/.travis.yml CHANGED
@@ -4,5 +4,8 @@ services: mongodb
4
4
  rvm:
5
5
  - 1.9.3
6
6
  - 2.0.0
7
- - 2.1.1
7
+ - 2.1.2
8
+
9
+ notifications:
10
+ email: false
8
11
 
@@ -1,3 +1,3 @@
1
1
  module MongoidMoneyField
2
- VERSION = "4.0.7"
2
+ VERSION = "4.0.8"
3
3
  end
@@ -18,9 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency "mongoid", ">= 3.0.0"
22
- spec.add_runtime_dependency "monetize"
23
- spec.add_runtime_dependency "money", "~> 6.1.0.beta1"
21
+ spec.add_dependency "mongoid", [">= 3.0", "< 4.1"]
22
+ spec.add_dependency "monetize"
23
+ spec.add_dependency "money", "~> 6.1.1"
24
24
 
25
25
  spec.add_development_dependency "rake"
26
26
  spec.add_development_dependency "bundler"
@@ -30,3 +30,4 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "database_cleaner"
31
31
  spec.add_development_dependency "mongoid-rspec"
32
32
  end
33
+
data/spec/model_spec.rb CHANGED
@@ -3,6 +3,6 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe DummyMoney do
6
- it { should allow_mass_assignment_of(:description) }
7
- it { should allow_mass_assignment_of(:price) }
6
+ it { is_expected.to allow_mass_assignment_of(:description) }
7
+ it { is_expected.to allow_mass_assignment_of(:price) }
8
8
  end
@@ -3,121 +3,121 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Money3Compat do
6
- it { should allow_mass_assignment_of(:description) }
7
- it { should allow_mass_assignment_of(:price) }
6
+ it { is_expected.to allow_mass_assignment_of(:description) }
7
+ it { is_expected.to allow_mass_assignment_of(:price) }
8
8
 
9
9
  it 'correctly reads old fields data' do
10
10
  Money3.create!(price_currency: 'GBP', price_cents: '12000')
11
- Money3Compat.first.price.cents.should eq 12000
12
- Money3Compat.first.price.currency.iso_code.should eq 'GBP'
11
+ expect(Money3Compat.first.price.cents).to eq 12000
12
+ expect(Money3Compat.first.price.currency.iso_code).to eq 'GBP'
13
13
  end
14
14
 
15
15
  it 'correctly works after save' do
16
16
  Money3.create!(price_currency: 'GBP', price_cents: '12000')
17
- Money3Compat.first.save.should be_true
17
+ expect(Money3Compat.first.save).to be_truthy
18
18
 
19
- Money3Compat.first.price.cents.should eq 12000
20
- Money3Compat.first.price.currency.iso_code.should eq 'GBP'
19
+ expect(Money3Compat.first.price.cents).to eq 12000
20
+ expect(Money3Compat.first.price.currency.iso_code).to eq 'GBP'
21
21
  end
22
22
 
23
23
  it 'correctly migrates data' do
24
24
  Money3.create!(price_currency: 'GBP', price_cents: '12000')
25
25
 
26
- Money3.first.read_attribute(:price_currency).should_not be_nil
27
- Money3.first.read_attribute(:price_cents).should_not be_nil
26
+ expect(Money3.first.read_attribute(:price_currency)).not_to be_nil
27
+ expect(Money3.first.read_attribute(:price_cents)).not_to be_nil
28
28
 
29
- Money3.first.read_attribute(:price_currency).should eq 'GBP'
30
- Money3.first.read_attribute(:price_cents).should eq 12000
29
+ expect(Money3.first.read_attribute(:price_currency)).to eq 'GBP'
30
+ expect(Money3.first.read_attribute(:price_cents)).to eq 12000
31
31
 
32
32
  Money3Compat.migrate_from_money_field_3!(:price)
33
33
 
34
- Money3Compat.first.price.cents.should eq 12000
35
- Money3Compat.first.price.currency.iso_code.should eq 'GBP'
34
+ expect(Money3Compat.first.price.cents).to eq 12000
35
+ expect(Money3Compat.first.price.currency.iso_code).to eq 'GBP'
36
36
 
37
- Money3.first.read_attribute(:price_currency).should be_nil
38
- Money3.first.read_attribute(:price_cents).should be_nil
37
+ expect(Money3.first.read_attribute(:price_currency)).to be_nil
38
+ expect(Money3.first.read_attribute(:price_cents)).to be_nil
39
39
 
40
- Money3Compat.first.read_attribute(:price_currency).should be_nil
41
- Money3Compat.first.read_attribute(:price_cents).should be_nil
40
+ expect(Money3Compat.first.read_attribute(:price_currency)).to be_nil
41
+ expect(Money3Compat.first.read_attribute(:price_cents)).to be_nil
42
42
 
43
43
  f = Money3Compat.first
44
44
  f.price = '32.00 GBP'
45
- f.save.should be_true
45
+ expect(f.save).to be_truthy
46
46
 
47
- Money3Compat.first.price.cents.should eq 3200
48
- Money3Compat.first.price.currency.iso_code.should eq 'GBP'
47
+ expect(Money3Compat.first.price.cents).to eq 3200
48
+ expect(Money3Compat.first.price.currency.iso_code).to eq 'GBP'
49
49
  end
50
50
 
51
51
  describe 'with fixed currency' do
52
52
  it 'correctly reads old' do
53
53
  Money3.create!(price_with_fix_cents: '12000')
54
- Money3Compat.first.price_with_fix.cents.should eq 12000
55
- Money3Compat.first.price_with_fix.currency.iso_code.should eq 'GBP'
54
+ expect(Money3Compat.first.price_with_fix.cents).to eq 12000
55
+ expect(Money3Compat.first.price_with_fix.currency.iso_code).to eq 'GBP'
56
56
  end
57
57
 
58
58
  it 'correctly works after save' do
59
59
  Money3.create!(price_with_fix_cents: '12000')
60
- Money3Compat.first.save.should be_true
61
- Money3Compat.first.price_with_fix.cents.should eq 12000
62
- Money3Compat.first.price_with_fix.currency.iso_code.should eq 'GBP'
60
+ expect(Money3Compat.first.save).to be_truthy
61
+ expect(Money3Compat.first.price_with_fix.cents).to eq 12000
62
+ expect(Money3Compat.first.price_with_fix.currency.iso_code).to eq 'GBP'
63
63
  end
64
64
 
65
65
  it 'correctly migrates data' do
66
66
  Money3.create!(price_with_fix_cents: '12000')
67
67
  Money3Compat.migrate_from_money_field_3!(:price_with_fix)
68
68
 
69
- Money3Compat.first.read_attribute(:price_with_fix_currency).should be_nil
70
- Money3Compat.first.read_attribute(:price_with_fix_cents).should be_nil
69
+ expect(Money3Compat.first.read_attribute(:price_with_fix_currency)).to be_nil
70
+ expect(Money3Compat.first.read_attribute(:price_with_fix_cents)).to be_nil
71
71
 
72
- Money3Compat.first.price_with_fix.cents.should eq 12000
73
- Money3Compat.first.price_with_fix.currency.iso_code.should eq 'GBP'
72
+ expect(Money3Compat.first.price_with_fix.cents).to eq 12000
73
+ expect(Money3Compat.first.price_with_fix.currency.iso_code).to eq 'GBP'
74
74
  end
75
75
  end
76
76
 
77
77
  describe 'with no default' do
78
78
  it 'correctly reads old' do
79
79
  Money3.create!(price_no_default_currency: 'GBP', price_no_default_cents: '12000')
80
- Money3Compat.first.price_no_default.cents.should eq 12000
81
- Money3Compat.first.price_no_default.currency.iso_code.should eq 'GBP'
80
+ expect(Money3Compat.first.price_no_default.cents).to eq 12000
81
+ expect(Money3Compat.first.price_no_default.currency.iso_code).to eq 'GBP'
82
82
  end
83
83
 
84
84
  it 'correctly works after save' do
85
85
  Money3.create!(price_no_default_currency: 'GBP', price_no_default_cents: '12000')
86
- Money3Compat.first.save.should be_true
87
- Money3Compat.first.price_no_default.cents.should eq 12000
88
- Money3Compat.first.price_no_default.currency.iso_code.should eq 'GBP'
86
+ expect(Money3Compat.first.save).to be_truthy
87
+ expect(Money3Compat.first.price_no_default.cents).to eq 12000
88
+ expect(Money3Compat.first.price_no_default.currency.iso_code).to eq 'GBP'
89
89
  end
90
90
 
91
91
  it 'correctly migrates data' do
92
92
  Money3.create!(price_no_default_currency: 'GBP', price_no_default_cents: '12000')
93
93
  Money3Compat.migrate_from_money_field_3!(:price_no_default)
94
94
 
95
- Money3Compat.first.read_attribute(:price_no_default_currency).should be_nil
96
- Money3Compat.first.read_attribute(:price_no_default_cents).should be_nil
95
+ expect(Money3Compat.first.read_attribute(:price_no_default_currency)).to be_nil
96
+ expect(Money3Compat.first.read_attribute(:price_no_default_cents)).to be_nil
97
97
 
98
- Money3Compat.first.price_no_default.cents.should eq 12000
99
- Money3Compat.first.price_no_default.currency.iso_code.should eq 'GBP'
98
+ expect(Money3Compat.first.price_no_default.cents).to eq 12000
99
+ expect(Money3Compat.first.price_no_default.currency.iso_code).to eq 'GBP'
100
100
  end
101
101
 
102
102
  it 'correctly migrates data with no currency' do
103
103
  Money3.create!(price_no_default_cents: '12000')
104
104
  Money3Compat.migrate_from_money_field_3!(:price_no_default)
105
105
 
106
- Money3Compat.first.read_attribute(:price_no_default_currency).should be_nil
107
- Money3Compat.first.read_attribute(:price_no_default_cents).should be_nil
106
+ expect(Money3Compat.first.read_attribute(:price_no_default_currency)).to be_nil
107
+ expect(Money3Compat.first.read_attribute(:price_no_default_cents)).to be_nil
108
108
 
109
- Money3Compat.first.price_no_default.cents.should eq 12000
110
- Money3Compat.first.price_no_default.currency.iso_code.should eq 'RUB'
109
+ expect(Money3Compat.first.price_no_default.cents).to eq 12000
110
+ expect(Money3Compat.first.price_no_default.currency.iso_code).to eq 'RUB'
111
111
  end
112
112
 
113
113
  it 'correctly migrates data with no cents' do
114
114
  Money3.create!()
115
115
  Money3Compat.migrate_from_money_field_3!(:price_no_default)
116
116
 
117
- Money3Compat.first.read_attribute(:price_no_default_currency).should be_nil
118
- Money3Compat.first.read_attribute(:price_no_default_cents).should be_nil
117
+ expect(Money3Compat.first.read_attribute(:price_no_default_currency)).to be_nil
118
+ expect(Money3Compat.first.read_attribute(:price_no_default_cents)).to be_nil
119
119
 
120
- Money3Compat.first.price_no_default.should be_nil
120
+ expect(Money3Compat.first.price_no_default).to be_nil
121
121
  end
122
122
  end
123
123
  end
data/spec/money3_spec.rb CHANGED
@@ -8,24 +8,24 @@ describe Mongoid::MoneyField do
8
8
  it 'should be valid to save when field is filled in' do
9
9
  dummy = DummyMoneyRequired.new
10
10
  dummy.price = '$10'
11
- dummy.should be_valid
12
- dummy.save.should eq true
11
+ expect(dummy).to be_valid
12
+ expect(dummy.save).to eq true
13
13
  end
14
14
 
15
15
  it 'should be not valid to save when field is not filled in' do
16
16
  dummy = DummyMoneyRequired.new
17
- dummy.should_not be_valid
18
- dummy.errors.count.should eq 1
19
- dummy.errors.messages[:price][0].should eq "can't be blank"
20
- dummy.save.should eq false
17
+ expect(dummy).not_to be_valid
18
+ expect(dummy.errors.count).to eq 1
19
+ expect(dummy.errors.messages[:price][0]).to eq "can't be blank"
20
+ expect(dummy.save).to eq false
21
21
  end
22
22
 
23
23
  it 'should be valid to save when field is filled in but currency is not' do
24
24
  dummy = DummyMoneyRequired.new
25
25
  dummy.price_cents = 123
26
- dummy.should be_valid
27
- dummy.save.should eq true
28
- dummy.price_currency.should eq Money.default_currency.iso_code
26
+ expect(dummy).to be_valid
27
+ expect(dummy.save).to eq true
28
+ expect(dummy.price_currency).to eq Money.default_currency.iso_code
29
29
  end
30
30
  end
31
31
 
@@ -33,35 +33,35 @@ describe Mongoid::MoneyField do
33
33
  it 'should raise the error when value consists non digits' do
34
34
  dummy = DummyNotANumber.new
35
35
  dummy.price = 'incorrect1'
36
- dummy.should_not be_valid
37
- dummy.errors.count.should eq 1
38
- dummy.errors.messages[:price][0].should eq "is not a number"
39
- dummy.save.should eq false
36
+ expect(dummy).not_to be_valid
37
+ expect(dummy.errors.count).to eq 1
38
+ expect(dummy.errors.messages[:price][0]).to eq "is not a number"
39
+ expect(dummy.save).to eq false
40
40
  end
41
41
 
42
42
  it 'should raise the error when value consists more then one decimal separator' do
43
43
  dummy = DummyNotANumber.new
44
44
  dummy.price = '121,212,22'
45
- dummy.should_not be_valid
46
- dummy.errors.count.should eq 1
47
- dummy.errors.messages[:price][0].should eq "is not a number"
48
- dummy.save.should eq false
45
+ expect(dummy).not_to be_valid
46
+ expect(dummy.errors.count).to eq 1
47
+ expect(dummy.errors.messages[:price][0]).to eq "is not a number"
48
+ expect(dummy.save).to eq false
49
49
  end
50
50
 
51
51
  it 'should raise the error when value is not present' do
52
52
  dummy = DummyNotANumber.new
53
- dummy.should_not be_valid
54
- dummy.errors.count.should eq 1
55
- dummy.errors.messages[:price][0].should eq "is not a number"
56
- dummy.save.should eq false
53
+ expect(dummy).not_to be_valid
54
+ expect(dummy.errors.count).to eq 1
55
+ expect(dummy.errors.messages[:price][0]).to eq "is not a number"
56
+ expect(dummy.save).to eq false
57
57
  end
58
58
 
59
59
  it 'should raise the error when value is not present' do
60
60
  dummy = DummyNotANumber.new( price: '' )
61
- dummy.should_not be_valid
62
- dummy.errors.count.should eq 1
63
- dummy.errors.messages[:price][0].should eq "is not a number"
64
- dummy.save.should eq false
61
+ expect(dummy).not_to be_valid
62
+ expect(dummy.errors.count).to eq 1
63
+ expect(dummy.errors.messages[:price][0]).to eq "is not a number"
64
+ expect(dummy.save).to eq false
65
65
  end
66
66
  end
67
67
 
@@ -69,65 +69,65 @@ describe Mongoid::MoneyField do
69
69
  it 'should raise the error when value consists non digits' do
70
70
  dummy = DummyNotANumber.new
71
71
  dummy.price_plain = 'incorrect1'
72
- dummy.should_not be_valid
73
- dummy.errors.count.should eq 1
74
- dummy.errors.messages[:price][0].should eq "is not a number"
75
- dummy.save.should eq false
72
+ expect(dummy).not_to be_valid
73
+ expect(dummy.errors.count).to eq 1
74
+ expect(dummy.errors.messages[:price][0]).to eq "is not a number"
75
+ expect(dummy.save).to eq false
76
76
  end
77
77
 
78
78
  it 'should raise the error when value consists more then one decimal separator' do
79
79
  dummy = DummyNotANumber.new
80
80
  dummy.price_plain = '121,212,22'
81
- dummy.should_not be_valid
82
- dummy.errors.count.should eq 1
83
- dummy.errors.messages[:price][0].should eq "is not a number"
84
- dummy.save.should eq false
81
+ expect(dummy).not_to be_valid
82
+ expect(dummy.errors.count).to eq 1
83
+ expect(dummy.errors.messages[:price][0]).to eq "is not a number"
84
+ expect(dummy.save).to eq false
85
85
  end
86
86
  end
87
87
 
88
88
  describe 'when value should be a positive number' do
89
89
  it 'should raise the error when value lesser than 1' do
90
90
  dummy = DummyPositiveNumber.new( price: '-10' )
91
- dummy.should_not be_valid
92
- dummy.errors.count.should eq 1
93
- dummy.errors.messages[:price][0].should eq "must be greater than 1"
94
- dummy.save.should eq false
95
- dummy.price_cents.should eq -1000
91
+ expect(dummy).not_to be_valid
92
+ expect(dummy.errors.count).to eq 1
93
+ expect(dummy.errors.messages[:price][0]).to eq "must be greater than 1"
94
+ expect(dummy.save).to eq false
95
+ expect(dummy.price_cents).to eq -1000
96
96
  end
97
97
 
98
98
  it 'should raise the error when value lesser than 1' do
99
99
  dummy = DummyPositiveNumber.new( price: '0' )
100
- dummy.should_not be_valid
101
- dummy.errors.count.should eq 1
102
- dummy.errors.messages[:price][0].should eq "must be greater than 1"
103
- dummy.save.should eq false
100
+ expect(dummy).not_to be_valid
101
+ expect(dummy.errors.count).to eq 1
102
+ expect(dummy.errors.messages[:price][0]).to eq "must be greater than 1"
103
+ expect(dummy.save).to eq false
104
104
  end
105
105
 
106
106
  it 'should be ok when value is greater than 1' do
107
107
  dummy = DummyPositiveNumber.new( price: '10' )
108
- dummy.should be_valid
109
- dummy.save.should eq true
108
+ expect(dummy).to be_valid
109
+ expect(dummy.save).to eq true
110
110
  end
111
111
 
112
112
  it 'should be ok when value is not present' do
113
113
  dummy = DummyPositiveNumber.new( price: '' )
114
- dummy.should be_valid
115
- dummy.save.should eq true
114
+ expect(dummy).to be_valid
115
+ expect(dummy.save).to eq true
116
116
  end
117
117
  end
118
118
 
119
119
  describe 'when both default currency and fixed currency is specified' do
120
120
  it 'should use fixed currency instead of default' do
121
121
  DummyOverrideDefaultCurrency.create!(price: '1.23')
122
- DummyOverrideDefaultCurrency.first.price.currency.iso_code.should eq 'GBP'
122
+ expect(DummyOverrideDefaultCurrency.first.price.currency.iso_code).to eq 'GBP'
123
123
  end
124
124
  end
125
125
 
126
126
  describe 'when default currency is specified' do
127
127
  it 'should use it instead of Money.default_currency' do
128
128
  DummyWithDefaultCurrency.create!(price: '1.23')
129
- DummyWithDefaultCurrency.first.price.currency.iso_code.should eq 'EUR'
130
- Money.default_currency.iso_code.should eq 'RUB'
129
+ expect(DummyWithDefaultCurrency.first.price.currency.iso_code).to eq 'EUR'
130
+ expect(Money.default_currency.iso_code).to eq 'RUB'
131
131
  end
132
132
  end
133
133
 
@@ -135,32 +135,32 @@ describe Mongoid::MoneyField do
135
135
  it 'should be persisted normally when set as dollars' do
136
136
  dummy = DummyMoney.new
137
137
  dummy.price = '$10'
138
- dummy.save.should eq true
138
+ expect(dummy.save).to eq true
139
139
  end
140
140
 
141
141
  it 'should be persisted normally when set as cents' do
142
142
  dummy = DummyMoney.new
143
143
  dummy.price = '$9.99'
144
- dummy.save.should eq true
144
+ expect(dummy.save).to eq true
145
145
  end
146
146
 
147
147
  it 'should be persisted normally when set as Money' do
148
148
  dummy = DummyMoney.new
149
149
  dummy.price = Monetize.parse(1.23)
150
- dummy.save.should eq true
150
+ expect(dummy.save).to eq true
151
151
  end
152
152
 
153
153
  it 'should be possible to set value to nil' do
154
154
  dummy = DummyMoney.new
155
155
  dummy.price = Monetize.parse(1.23)
156
- dummy.save.should eq true
156
+ expect(dummy.save).to eq true
157
157
 
158
158
  dummy = DummyMoney.first
159
- dummy.price.should eq Monetize.parse(1.23)
159
+ expect(dummy.price).to eq Monetize.parse(1.23)
160
160
  dummy.price = nil
161
- dummy.save.should eq true
161
+ expect(dummy.save).to eq true
162
162
  dummy = DummyMoney.first
163
- dummy.price.should be_nil
163
+ expect(dummy.price).to be_nil
164
164
  end
165
165
  end
166
166
 
@@ -171,7 +171,7 @@ describe Mongoid::MoneyField do
171
171
 
172
172
  it 'should have a Money value that matches the money value that was initially persisted' do
173
173
  dummy = DummyMoney.first
174
- dummy.price.should eq Monetize.parse('9.99')
174
+ expect(dummy.price).to eq Monetize.parse('9.99')
175
175
  end
176
176
  end
177
177
 
@@ -184,7 +184,7 @@ describe Mongoid::MoneyField do
184
184
 
185
185
  it 'should have a Money value that matches the money value that was initially persisted' do
186
186
  dummy = DummyMoney.first
187
- dummy.price.cents.should eq 123
187
+ expect(dummy.price.cents).to eq 123
188
188
  end
189
189
  end
190
190
 
@@ -195,50 +195,50 @@ describe Mongoid::MoneyField do
195
195
 
196
196
  it 'should have a Money value that matches the money value that was initially persisted' do
197
197
  dummy = DummyMoney.first
198
- dummy.price.cents.should eq 123
198
+ expect(dummy.price.cents).to eq 123
199
199
  end
200
200
  end
201
201
 
202
202
  describe 'when accessing a document from the datastore with a Money datatype and empty value' do
203
203
  it 'should be nil' do
204
204
  dummy = DummyMoneyWithoutDefault.new
205
- dummy.save.should eq true
206
- DummyMoneyWithoutDefault.first.price.should be_nil
205
+ expect(dummy.save).to eq true
206
+ expect(DummyMoneyWithoutDefault.first.price).to be_nil
207
207
  end
208
208
 
209
209
  it 'should be 0 when used with default' do
210
210
  dummy = DummyMoney.new
211
- dummy.save.should eq true
212
- DummyMoney.first.price.cents.should eq 0
211
+ expect(dummy.save).to eq true
212
+ expect(DummyMoney.first.price.cents).to eq 0
213
213
  end
214
214
 
215
215
  it 'should set money to default currency if money is given without it' do
216
216
  dummy = DummyMoneyWithDefault.new
217
- dummy.save.should eq true
217
+ expect(dummy.save).to eq true
218
218
  dummy = DummyMoneyWithDefault.first
219
- dummy.price.currency.iso_code.should eq Money.default_currency.iso_code
220
- dummy.price.cents.should eq 100
219
+ expect(dummy.price.currency.iso_code).to eq Money.default_currency.iso_code
220
+ expect(dummy.price.cents).to eq 100
221
221
  end
222
222
 
223
223
  it 'should set money to default currency if money is given without it on a document with multiple money fields' do
224
224
  dummy = DummyPrices.new
225
- dummy.save.should eq true
225
+ expect(dummy.save).to eq true
226
226
  dummy = DummyPrices.first
227
- dummy.price.currency.iso_code.should eq Money.default_currency.iso_code
228
- dummy.price.cents.should eq 100
227
+ expect(dummy.price.currency.iso_code).to eq Money.default_currency.iso_code
228
+ expect(dummy.price.cents).to eq 100
229
229
 
230
- dummy.price2.should be_nil
230
+ expect(dummy.price2).to be_nil
231
231
 
232
- dummy.price1.cents.should eq 0
232
+ expect(dummy.price1.cents).to eq 0
233
233
  end
234
234
 
235
235
 
236
236
  it 'should set money to correct currency if money is given with it' do
237
237
  dummy = DummyMoneyWithDefaultWithCurrency.new
238
- dummy.save.should eq true
238
+ expect(dummy.save).to eq true
239
239
  dummy = DummyMoneyWithDefaultWithCurrency.first
240
- dummy.price.currency.iso_code.should eq 'GBP'
241
- dummy.price.cents.should eq 100
240
+ expect(dummy.price.currency.iso_code).to eq 'GBP'
241
+ expect(dummy.price.cents).to eq 100
242
242
  end
243
243
  end
244
244
 
@@ -246,17 +246,17 @@ describe Mongoid::MoneyField do
246
246
  it 'should have correct currency when value is set to 5$' do
247
247
  DummyMoneyWithFixedCurrency.create!(price: '5$')
248
248
  dummy = DummyMoneyWithFixedCurrency.first
249
- dummy.price.currency.iso_code.should eq 'GBP'
250
- dummy.price.cents.should eq 500
251
- dummy.price.should eq Monetize.parse('5 GBP')
249
+ expect(dummy.price.currency.iso_code).to eq 'GBP'
250
+ expect(dummy.price.cents).to eq 500
251
+ expect(dummy.price).to eq Monetize.parse('5 GBP')
252
252
  end
253
253
 
254
254
  it 'should have correct currency when value is set to 100 RUB' do
255
255
  DummyMoneyWithFixedCurrency.create!(price: '100 RUB')
256
256
  dummy = DummyMoneyWithFixedCurrency.first
257
- dummy.price.currency.iso_code.should eq 'GBP'
258
- dummy.price.cents.should eq 100_00
259
- dummy.price.should eq Monetize.parse('100 GBP')
257
+ expect(dummy.price.currency.iso_code).to eq 'GBP'
258
+ expect(dummy.price.cents).to eq 100_00
259
+ expect(dummy.price).to eq Monetize.parse('100 GBP')
260
260
  end
261
261
  end
262
262
 
@@ -264,17 +264,17 @@ describe Mongoid::MoneyField do
264
264
  it 'should handle RUB' do
265
265
  DummyMoney.create(description: "Test", price: '1.23 RUB')
266
266
  dummy = DummyMoney.first
267
- dummy.price.currency.iso_code.should eq 'RUB'
268
- dummy.price.cents.should eq 123
269
- dummy.price.should eq Monetize.parse('1.23 RUB')
267
+ expect(dummy.price.currency.iso_code).to eq 'RUB'
268
+ expect(dummy.price.cents).to eq 123
269
+ expect(dummy.price).to eq Monetize.parse('1.23 RUB')
270
270
  end
271
271
 
272
272
  it 'should handle $' do
273
273
  DummyMoney.create(description: "Test", price: '1.23 USD')
274
274
  dummy = DummyMoney.first
275
- dummy.price.currency.iso_code.should eq 'USD'
276
- dummy.price.cents.should eq 123
277
- dummy.price.should eq Monetize.parse('1.23 USD')
275
+ expect(dummy.price.currency.iso_code).to eq 'USD'
276
+ expect(dummy.price.cents).to eq 123
277
+ expect(dummy.price).to eq Monetize.parse('1.23 USD')
278
278
  end
279
279
  end
280
280
 
@@ -285,17 +285,17 @@ describe Mongoid::MoneyField do
285
285
 
286
286
  it 'should be nil' do
287
287
  dummy = DummyMoney.first
288
- dummy.price.should be_nil
288
+ expect(dummy.price).to be_nil
289
289
  end
290
290
 
291
291
  it 'should be updated correctly' do
292
292
  dummy = DummyMoney.first
293
- dummy.price.should be_nil
293
+ expect(dummy.price).to be_nil
294
294
  dummy.price = '1.23 USD'
295
- dummy.save.should eq true
295
+ expect(dummy.save).to eq true
296
296
  dummy = DummyMoney.first
297
- dummy.price.currency.iso_code.should eq 'USD'
298
- dummy.price.cents.should eq 123
297
+ expect(dummy.price.currency.iso_code).to eq 'USD'
298
+ expect(dummy.price.cents).to eq 123
299
299
  end
300
300
  end
301
301
 
@@ -312,12 +312,12 @@ describe Mongoid::MoneyField do
312
312
 
313
313
  it 'should have correct value for first item' do
314
314
  o = DummyOrder.first
315
- o.dummy_line_items.first.price.should eq Monetize.parse('12.99')
315
+ expect(o.dummy_line_items.first.price).to eq Monetize.parse('12.99')
316
316
  end
317
317
 
318
318
  it 'should have correct value for first item' do
319
319
  o = DummyOrder.first
320
- o.dummy_line_items.last.price.should eq Monetize.parse('14.99')
320
+ expect(o.dummy_line_items.last.price).to eq Monetize.parse('14.99')
321
321
  end
322
322
  end
323
323
 
@@ -328,15 +328,15 @@ describe Mongoid::MoneyField do
328
328
 
329
329
  it 'should have correct Money value for field 1' do
330
330
  dummy = DummyPrices.first
331
- dummy.price1.should eq Monetize.parse('1.23')
331
+ expect(dummy.price1).to eq Monetize.parse('1.23')
332
332
  end
333
333
  it 'should have correct Money value for field 2' do
334
334
  dummy = DummyPrices.first
335
- dummy.price2.should eq Monetize.parse('2.33')
335
+ expect(dummy.price2).to eq Monetize.parse('2.33')
336
336
  end
337
337
  it 'should have correct Money value for field 3' do
338
338
  dummy = DummyPrices.first
339
- dummy.price3.should eq Monetize.parse('1')
339
+ expect(dummy.price3).to eq Monetize.parse('1')
340
340
  end
341
341
  end
342
342
  end
data/spec/money_spec.rb CHANGED
@@ -8,16 +8,16 @@ describe Mongoid::MoneyField do
8
8
  it 'should be valid to save when field is filled in' do
9
9
  dummy = DummyMoneyRequired.new
10
10
  dummy.price = '$10'
11
- dummy.should be_valid
12
- dummy.save.should eq true
11
+ expect(dummy).to be_valid
12
+ expect(dummy.save).to eq true
13
13
  end
14
14
 
15
15
  it 'should be not valid to save when field is not filled in' do
16
16
  dummy = DummyMoneyRequired.new
17
- dummy.should_not be_valid
18
- dummy.errors.count.should eq 1
19
- dummy.errors.messages[:price][0].should eq "can't be blank"
20
- dummy.save.should eq false
17
+ expect(dummy).not_to be_valid
18
+ expect(dummy.errors.count).to eq 1
19
+ expect(dummy.errors.messages[:price][0]).to eq "can't be blank"
20
+ expect(dummy.save).to eq false
21
21
  end
22
22
  end
23
23
 
@@ -25,35 +25,35 @@ describe Mongoid::MoneyField do
25
25
  it 'should raise the error when value consists non digits' do
26
26
  dummy = DummyNotANumber.new
27
27
  dummy.price = 'incorrect1'
28
- dummy.should_not be_valid
29
- dummy.errors.count.should eq 1
30
- dummy.errors.messages[:price][0].should eq "is not a number"
31
- dummy.save.should eq false
28
+ expect(dummy).not_to be_valid
29
+ expect(dummy.errors.count).to eq 1
30
+ expect(dummy.errors.messages[:price][0]).to eq "is not a number"
31
+ expect(dummy.save).to eq false
32
32
  end
33
33
 
34
34
  it 'should raise the error when value consists more then one decimal separator' do
35
35
  dummy = DummyNotANumber.new
36
36
  dummy.price = '121,212,22'
37
- dummy.should_not be_valid
38
- dummy.errors.count.should eq 1
39
- dummy.errors.messages[:price][0].should eq "is not a number"
40
- dummy.save.should eq false
37
+ expect(dummy).not_to be_valid
38
+ expect(dummy.errors.count).to eq 1
39
+ expect(dummy.errors.messages[:price][0]).to eq "is not a number"
40
+ expect(dummy.save).to eq false
41
41
  end
42
42
 
43
43
  it 'should raise the error when value is not present' do
44
44
  dummy = DummyNotANumber.new
45
- dummy.should_not be_valid
46
- dummy.errors.count.should eq 1
47
- dummy.errors.messages[:price][0].should eq "is not a number"
48
- dummy.save.should eq false
45
+ expect(dummy).not_to be_valid
46
+ expect(dummy.errors.count).to eq 1
47
+ expect(dummy.errors.messages[:price][0]).to eq "is not a number"
48
+ expect(dummy.save).to eq false
49
49
  end
50
50
 
51
51
  it 'should raise the error when value is not present' do
52
52
  dummy = DummyNotANumber.new(price: '')
53
- dummy.should_not be_valid
54
- dummy.errors.count.should eq 1
55
- dummy.errors.messages[:price][0].should eq "is not a number"
56
- dummy.save.should eq false
53
+ expect(dummy).not_to be_valid
54
+ expect(dummy.errors.count).to eq 1
55
+ expect(dummy.errors.messages[:price][0]).to eq "is not a number"
56
+ expect(dummy.save).to eq false
57
57
  end
58
58
  end
59
59
 
@@ -61,79 +61,79 @@ describe Mongoid::MoneyField do
61
61
  it 'should raise the error when value consists non digits' do
62
62
  dummy = DummyNotANumber.new
63
63
  dummy.price = 'incorrect1'
64
- dummy.should_not be_valid
65
- dummy.errors.count.should eq 1
66
- dummy.errors.messages[:price][0].should eq "is not a number"
67
- dummy.save.should eq false
64
+ expect(dummy).not_to be_valid
65
+ expect(dummy.errors.count).to eq 1
66
+ expect(dummy.errors.messages[:price][0]).to eq "is not a number"
67
+ expect(dummy.save).to eq false
68
68
  end
69
69
 
70
70
  it 'should raise the error when value consists more then one decimal separator' do
71
71
  dummy = DummyNotANumber.new
72
72
  dummy.price = '121,212,22'
73
- dummy.should_not be_valid
74
- dummy.errors.count.should eq 1
75
- dummy.errors.messages[:price][0].should eq "is not a number"
76
- dummy.save.should eq false
73
+ expect(dummy).not_to be_valid
74
+ expect(dummy.errors.count).to eq 1
75
+ expect(dummy.errors.messages[:price][0]).to eq "is not a number"
76
+ expect(dummy.save).to eq false
77
77
  end
78
78
  end
79
79
 
80
80
  describe 'when value should be a positive number' do
81
81
  it 'should raise the error when value lesser than 1' do
82
82
  dummy = DummyPositiveNumber.new(price: '-10')
83
- dummy.should_not be_valid
84
- dummy.errors.count.should eq 1
85
- dummy.errors.messages[:price][0].should eq "must be greater than 1"
86
- dummy.save.should eq false
87
- dummy.price_cents.should eq -1000
83
+ expect(dummy).not_to be_valid
84
+ expect(dummy.errors.count).to eq 1
85
+ expect(dummy.errors.messages[:price][0]).to eq "must be greater than 1"
86
+ expect(dummy.save).to eq false
87
+ expect(dummy.price_cents).to eq -1000
88
88
  end
89
89
 
90
90
  it 'should raise the error when value lesser than 1' do
91
91
  dummy = DummyPositiveNumber.new(price: '-1000')
92
- dummy.should_not be_valid
93
- dummy.errors.count.should eq 1
94
- dummy.errors.messages[:price][0].should eq "must be greater than 1"
95
- dummy.save.should eq false
92
+ expect(dummy).not_to be_valid
93
+ expect(dummy.errors.count).to eq 1
94
+ expect(dummy.errors.messages[:price][0]).to eq "must be greater than 1"
95
+ expect(dummy.save).to eq false
96
96
  end
97
97
 
98
98
  it 'should raise the error when value lesser than 1' do
99
99
  dummy = DummyPositiveNumber.new(price: '0')
100
- dummy.should_not be_valid
101
- dummy.errors.count.should eq 1
102
- dummy.errors.messages[:price][0].should eq "must be greater than 1"
103
- dummy.save.should eq false
100
+ expect(dummy).not_to be_valid
101
+ expect(dummy.errors.count).to eq 1
102
+ expect(dummy.errors.messages[:price][0]).to eq "must be greater than 1"
103
+ expect(dummy.save).to eq false
104
104
  end
105
105
 
106
106
  it 'should be ok when value is greater than 1' do
107
107
  dummy = DummyPositiveNumber.new(price: '10')
108
- dummy.should be_valid
109
- dummy.save.should eq true
108
+ expect(dummy).to be_valid
109
+ expect(dummy.save).to eq true
110
110
  end
111
111
 
112
112
  it 'should be ok when value is greater than 1' do
113
113
  dummy = DummyPositiveNumber.new(price: '1000')
114
- dummy.should be_valid
115
- dummy.save.should eq true
114
+ expect(dummy).to be_valid
115
+ expect(dummy.save).to eq true
116
116
  end
117
117
 
118
118
  it 'should be ok when value is not present' do
119
119
  dummy = DummyPositiveNumber.new(price: '')
120
- dummy.should be_valid
121
- dummy.save.should eq true
120
+ expect(dummy).to be_valid
121
+ expect(dummy.save).to eq true
122
122
  end
123
123
  end
124
124
 
125
125
  describe 'when both default currency and fixed currency is specified' do
126
126
  it 'should use fixed currency instead of default' do
127
127
  DummyOverrideDefaultCurrency.create!(price: '1.23')
128
- DummyOverrideDefaultCurrency.first.price.currency.iso_code.should eq 'GBP'
128
+ expect(DummyOverrideDefaultCurrency.first.price.currency.iso_code).to eq 'GBP'
129
129
  end
130
130
  end
131
131
 
132
132
  describe 'when default currency is specified' do
133
133
  it 'should use it instead of Money.default_currency' do
134
134
  DummyWithDefaultCurrency.create!(price: '1.23')
135
- DummyWithDefaultCurrency.first.price.currency.iso_code.should eq 'EUR'
136
- Money.default_currency.iso_code.should eq 'RUB'
135
+ expect(DummyWithDefaultCurrency.first.price.currency.iso_code).to eq 'EUR'
136
+ expect(Money.default_currency.iso_code).to eq 'RUB'
137
137
  end
138
138
  end
139
139
 
@@ -141,32 +141,32 @@ describe Mongoid::MoneyField do
141
141
  it 'should be persisted normally when set as dollars' do
142
142
  dummy = DummyMoney.new
143
143
  dummy.price = '$10'
144
- dummy.save.should eq true
144
+ expect(dummy.save).to eq true
145
145
  end
146
146
 
147
147
  it 'should be persisted normally when set as cents' do
148
148
  dummy = DummyMoney.new
149
149
  dummy.price = '$9.99'
150
- dummy.save.should eq true
150
+ expect(dummy.save).to eq true
151
151
  end
152
152
 
153
153
  it 'should be persisted normally when set as Money' do
154
154
  dummy = DummyMoney.new
155
155
  dummy.price = Monetize.parse(1.23)
156
- dummy.save.should eq true
156
+ expect(dummy.save).to eq true
157
157
  end
158
158
 
159
159
  it 'should be possible to set value to nil' do
160
160
  dummy = DummyMoney.new
161
161
  dummy.price = Monetize.parse(1.23)
162
- dummy.save.should eq true
162
+ expect(dummy.save).to eq true
163
163
 
164
164
  dummy = DummyMoney.first
165
- dummy.price.should eq Monetize.parse(1.23)
165
+ expect(dummy.price).to eq Monetize.parse(1.23)
166
166
  dummy.price = nil
167
- dummy.save.should eq true
167
+ expect(dummy.save).to eq true
168
168
  dummy = DummyMoney.first
169
- dummy.price.should be_nil
169
+ expect(dummy.price).to be_nil
170
170
  end
171
171
  end
172
172
 
@@ -177,7 +177,7 @@ describe Mongoid::MoneyField do
177
177
 
178
178
  it 'should have a Money value that matches the money value that was initially persisted' do
179
179
  dummy = DummyMoney.first
180
- dummy.price.should eq Monetize.parse('9.99')
180
+ expect(dummy.price).to eq Monetize.parse('9.99')
181
181
  end
182
182
  end
183
183
 
@@ -190,7 +190,7 @@ describe Mongoid::MoneyField do
190
190
 
191
191
  it 'should have a Money value that matches the money value that was initially persisted' do
192
192
  dummy = DummyMoney.first
193
- dummy.price.cents.should eq 123
193
+ expect(dummy.price.cents).to eq 123
194
194
  end
195
195
  end
196
196
 
@@ -201,50 +201,50 @@ describe Mongoid::MoneyField do
201
201
 
202
202
  it 'should have a Money value that matches the money value that was initially persisted' do
203
203
  dummy = DummyMoney.first
204
- dummy.price.cents.should eq 123
204
+ expect(dummy.price.cents).to eq 123
205
205
  end
206
206
  end
207
207
 
208
208
  describe 'when accessing a document from the datastore with a Money datatype and empty value' do
209
209
  it 'should be nil' do
210
210
  dummy = DummyMoneyWithoutDefault.new
211
- dummy.save.should eq true
212
- DummyMoneyWithoutDefault.first.price.should be_nil
211
+ expect(dummy.save).to eq true
212
+ expect(DummyMoneyWithoutDefault.first.price).to be_nil
213
213
  end
214
214
 
215
215
  it 'should be 0 when used with default' do
216
216
  dummy = DummyMoney.new
217
- dummy.save.should eq true
218
- DummyMoney.first.price.cents.should eq 0
217
+ expect(dummy.save).to eq true
218
+ expect(DummyMoney.first.price.cents).to eq 0
219
219
  end
220
220
 
221
221
  it 'should set money to default currency if money is given without it' do
222
222
  dummy = DummyMoneyWithDefault.new
223
- dummy.save.should eq true
223
+ expect(dummy.save).to eq true
224
224
  dummy = DummyMoneyWithDefault.first
225
- dummy.price.currency.iso_code.should eq Money.default_currency.iso_code
226
- dummy.price.cents.should eq 100
225
+ expect(dummy.price.currency.iso_code).to eq Money.default_currency.iso_code
226
+ expect(dummy.price.cents).to eq 100
227
227
  end
228
228
 
229
229
  it 'should set money to default currency if money is given without it on a document with multiple money fields' do
230
230
  dummy = DummyPrices.new
231
- dummy.save.should eq true
231
+ expect(dummy.save).to eq true
232
232
  dummy = DummyPrices.first
233
- dummy.price.currency.iso_code.should eq Money.default_currency.iso_code
234
- dummy.price.cents.should eq 100
233
+ expect(dummy.price.currency.iso_code).to eq Money.default_currency.iso_code
234
+ expect(dummy.price.cents).to eq 100
235
235
 
236
- dummy.price2.should be_nil
236
+ expect(dummy.price2).to be_nil
237
237
 
238
- dummy.price1.cents.should eq 0
238
+ expect(dummy.price1.cents).to eq 0
239
239
  end
240
240
 
241
241
 
242
242
  it 'should set money to correct currency if money is given with it' do
243
243
  dummy = DummyMoneyWithDefaultWithCurrency.new
244
- dummy.save.should eq true
244
+ expect(dummy.save).to eq true
245
245
  dummy = DummyMoneyWithDefaultWithCurrency.first
246
- dummy.price.currency.iso_code.should eq 'GBP'
247
- dummy.price.cents.should eq 100
246
+ expect(dummy.price.currency.iso_code).to eq 'GBP'
247
+ expect(dummy.price.cents).to eq 100
248
248
  end
249
249
  end
250
250
 
@@ -252,17 +252,17 @@ describe Mongoid::MoneyField do
252
252
  it 'should have correct currency when value is set to 5$' do
253
253
  DummyMoneyWithFixedCurrency.create!(price: '5$')
254
254
  dummy = DummyMoneyWithFixedCurrency.first
255
- dummy.price.currency.iso_code.should eq 'GBP'
256
- dummy.price.cents.should eq 500
257
- dummy.price.should eq Monetize.parse('5 GBP')
255
+ expect(dummy.price.currency.iso_code).to eq 'GBP'
256
+ expect(dummy.price.cents).to eq 500
257
+ expect(dummy.price).to eq Monetize.parse('5 GBP')
258
258
  end
259
259
 
260
260
  it 'should have correct currency when value is set to 100 RUB' do
261
261
  DummyMoneyWithFixedCurrency.create!(price: '100 RUB')
262
262
  dummy = DummyMoneyWithFixedCurrency.first
263
- dummy.price.currency.iso_code.should eq 'GBP'
264
- dummy.price.cents.should eq 100_00
265
- dummy.price.should eq Monetize.parse('100 GBP')
263
+ expect(dummy.price.currency.iso_code).to eq 'GBP'
264
+ expect(dummy.price.cents).to eq 100_00
265
+ expect(dummy.price).to eq Monetize.parse('100 GBP')
266
266
  end
267
267
  end
268
268
 
@@ -270,17 +270,17 @@ describe Mongoid::MoneyField do
270
270
  it 'should handle RUB' do
271
271
  DummyMoney.create(description: "Test", price: '1.23 RUB')
272
272
  dummy = DummyMoney.first
273
- dummy.price.currency.iso_code.should eq 'RUB'
274
- dummy.price.cents.should eq 123
275
- dummy.price.should eq Monetize.parse('1.23 RUB')
273
+ expect(dummy.price.currency.iso_code).to eq 'RUB'
274
+ expect(dummy.price.cents).to eq 123
275
+ expect(dummy.price).to eq Monetize.parse('1.23 RUB')
276
276
  end
277
277
 
278
278
  it 'should handle $' do
279
279
  DummyMoney.create(description: "Test", price: '1.23 USD')
280
280
  dummy = DummyMoney.first
281
- dummy.price.currency.iso_code.should eq 'USD'
282
- dummy.price.cents.should eq 123
283
- dummy.price.should eq Monetize.parse('1.23 USD')
281
+ expect(dummy.price.currency.iso_code).to eq 'USD'
282
+ expect(dummy.price.cents).to eq 123
283
+ expect(dummy.price).to eq Monetize.parse('1.23 USD')
284
284
  end
285
285
  end
286
286
 
@@ -291,25 +291,25 @@ describe Mongoid::MoneyField do
291
291
 
292
292
  it 'should be nil' do
293
293
  dummy = DummyMoney.first
294
- dummy.price.should be_nil
294
+ expect(dummy.price).to be_nil
295
295
  end
296
296
 
297
297
  it 'stays nil' do
298
298
  dummy = DummyMoney.first
299
299
  dummy.price = ''
300
- dummy.price.should be_nil
301
- dummy.save.should be_true
302
- DummyMoney.first.price.should be_nil
300
+ expect(dummy.price).to be_nil
301
+ expect(dummy.save).to be_truthy
302
+ expect(DummyMoney.first.price).to be_nil
303
303
  end
304
304
 
305
305
  it 'should be updated correctly' do
306
306
  dummy = DummyMoney.first
307
- dummy.price.should be_nil
307
+ expect(dummy.price).to be_nil
308
308
  dummy.price = '1.23 USD'
309
- dummy.save.should eq true
309
+ expect(dummy.save).to eq true
310
310
  dummy = DummyMoney.first
311
- dummy.price.currency.iso_code.should eq 'USD'
312
- dummy.price.cents.should eq 123
311
+ expect(dummy.price.currency.iso_code).to eq 'USD'
312
+ expect(dummy.price.cents).to eq 123
313
313
  end
314
314
  end
315
315
 
@@ -326,12 +326,12 @@ describe Mongoid::MoneyField do
326
326
 
327
327
  it 'should have correct value for first item' do
328
328
  o = DummyOrder.first
329
- o.dummy_line_items.first.price.should eq Monetize.parse('12.99')
329
+ expect(o.dummy_line_items.first.price).to eq Monetize.parse('12.99')
330
330
  end
331
331
 
332
332
  it 'should have correct value for first item' do
333
333
  o = DummyOrder.first
334
- o.dummy_line_items.last.price.should eq Monetize.parse('14.99')
334
+ expect(o.dummy_line_items.last.price).to eq Monetize.parse('14.99')
335
335
  end
336
336
  end
337
337
 
@@ -342,15 +342,15 @@ describe Mongoid::MoneyField do
342
342
 
343
343
  it 'should have correct Money value for field 1' do
344
344
  dummy = DummyPrices.first
345
- dummy.price1.should eq Monetize.parse('1.23')
345
+ expect(dummy.price1).to eq Monetize.parse('1.23')
346
346
  end
347
347
  it 'should have correct Money value for field 2' do
348
348
  dummy = DummyPrices.first
349
- dummy.price2.should eq Monetize.parse('2.33')
349
+ expect(dummy.price2).to eq Monetize.parse('2.33')
350
350
  end
351
351
  it 'should have correct Money value for field 3' do
352
352
  dummy = DummyPrices.first
353
- dummy.price3.should eq Monetize.parse('1')
353
+ expect(dummy.price3).to eq Monetize.parse('1')
354
354
  end
355
355
  end
356
356
  end
@@ -15,48 +15,48 @@ describe Money do
15
15
 
16
16
  context "mongoize" do
17
17
  it "mongoizes correctly a Money object to a hash of cents and currency" do
18
- priceable.price.cents.should == 100
19
- priceable.price.currency.should == Money::Currency.find('EUR')
18
+ expect(priceable.price.cents).to eq(100)
19
+ expect(priceable.price.currency).to eq(Money::Currency.find('EUR'))
20
20
  end
21
21
 
22
22
  it "mongoizes correctly a Numeric object to a hash of cents and currency" do
23
- priceable_from_num.price.cents.should == 100
24
- priceable_from_num.price.currency.should == Money.default_currency
23
+ expect(priceable_from_num.price.cents).to eq(100)
24
+ expect(priceable_from_num.price.currency).to eq(Money.default_currency)
25
25
  end
26
26
 
27
27
  it "mongoizes correctly a String object to a hash of cents and currency" do
28
- priceable_from_string.price.cents.should == 100
29
- priceable_from_string.price.currency.should == Money::Currency.find('EUR')
28
+ expect(priceable_from_string.price.cents).to eq(100)
29
+ expect(priceable_from_string.price.currency).to eq(Money::Currency.find('EUR'))
30
30
  end
31
31
 
32
32
  it "mongoizes correctly a hash of cents and currency" do
33
- priceable_from_hash.price.cents.should == 100
34
- priceable_from_hash.price.currency.should == Money::Currency.find('EUR')
33
+ expect(priceable_from_hash.price.cents).to eq(100)
34
+ expect(priceable_from_hash.price.currency).to eq(Money::Currency.find('EUR'))
35
35
  end
36
36
 
37
37
  it "mongoizes correctly a HashWithIndifferentAccess of cents and currency" do
38
- priceable_from_hash_with_indifferent_access.price.cents.should == 100
39
- priceable_from_hash_with_indifferent_access.price.currency.should == Money::Currency.find('EUR')
38
+ expect(priceable_from_hash_with_indifferent_access.price.cents).to eq(100)
39
+ expect(priceable_from_hash_with_indifferent_access.price.currency).to eq(Money::Currency.find('EUR'))
40
40
  end
41
41
  end
42
42
 
43
43
  context "demongoize" do
44
44
  subject { Priceable.first.price }
45
- it { should be_an_instance_of(Money) }
46
- it { should == Money.new(100, 'EUR') }
45
+ it { is_expected.to be_an_instance_of(Money) }
46
+ it { is_expected.to eq(Money.new(100, 'EUR')) }
47
47
  it "returns nil if a nil value was stored" do
48
48
  nil_priceable = Priceable.create(:price => nil)
49
- nil_priceable.price.should be_nil
49
+ expect(nil_priceable.price).to be_nil
50
50
  end
51
51
  it 'returns nil if an unknown value was stored' do
52
52
  zero_priceable = Priceable.create(:price => [])
53
- zero_priceable.price.should be_nil
53
+ expect(zero_priceable.price).to be_nil
54
54
  end
55
55
  end
56
56
 
57
57
  context "evolve" do
58
58
  it "transforms correctly a Money object to a Mongo friendly value" do
59
- Priceable.where(:price => Money.new(100, 'EUR')).first.should == priceable
59
+ expect(Priceable.where(:price => Money.new(100, 'EUR')).first).to eq(priceable)
60
60
  end
61
61
  end
62
62
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_money_field
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.7
4
+ version: 4.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Tv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-30 00:00:00.000000000 Z
11
+ date: 2014-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.0.0
19
+ version: '3.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '4.1'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: 3.0.0
29
+ version: '3.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4.1'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: monetize
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +50,14 @@ dependencies:
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: 6.1.0.beta1
53
+ version: 6.1.1
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: 6.1.0.beta1
60
+ version: 6.1.1
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: rake
57
63
  requirement: !ruby/object:Gem::Requirement