dolla_dolla_bill 0.0.1 → 0.0.2
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/lib/dolla_dolla_bill.rb +10 -3
- data/lib/dolla_dolla_bill/version.rb +1 -1
- data/spec/dolla_dolla_bill_spec.rb +9 -0
- data/spec/spec_helper.rb +2 -2
- metadata +2 -2
data/lib/dolla_dolla_bill.rb
CHANGED
@@ -16,10 +16,17 @@ module DollaDollaBill
|
|
16
16
|
end
|
17
17
|
|
18
18
|
define_method("#{name}=") do |value|
|
19
|
-
|
19
|
+
if value.nil?
|
20
|
+
cents_value = nil
|
21
|
+
currency_value = nil
|
22
|
+
else
|
23
|
+
value = value.to_money
|
24
|
+
cents_value = value.cents
|
25
|
+
currency_value = value.currency_as_string
|
26
|
+
end
|
20
27
|
|
21
|
-
send(cents_field_writer,
|
22
|
-
send(currency_field_writer,
|
28
|
+
send(cents_field_writer, cents_value)
|
29
|
+
send(currency_field_writer, currency_value)
|
23
30
|
end
|
24
31
|
|
25
32
|
self.class.send(:define_method, "lowest_#{name}") do
|
@@ -72,6 +72,15 @@ describe DollaDollaBill do
|
|
72
72
|
money.price_currency.should eql 'USD'
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
context 'when set to nil' do
|
77
|
+
before { money.price = nil }
|
78
|
+
|
79
|
+
it 'sets the attributes to nil' do
|
80
|
+
money.price_in_cents.should be_nil
|
81
|
+
money.price_currency.should be_nil
|
82
|
+
end
|
83
|
+
end
|
75
84
|
end
|
76
85
|
|
77
86
|
describe '.lowest_money' do
|
data/spec/spec_helper.rb
CHANGED
@@ -5,7 +5,7 @@ require 'dolla_dolla_bill'
|
|
5
5
|
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
|
6
6
|
|
7
7
|
RSpec.configure do |config|
|
8
|
-
config.before(:
|
8
|
+
config.before(:suite) do
|
9
9
|
SQLite3::Database.new 'tmp/test.db'
|
10
10
|
|
11
11
|
ActiveRecord::Base.establish_connection(
|
@@ -29,7 +29,7 @@ RSpec.configure do |config|
|
|
29
29
|
ActiveRecord::Base.connection.execute 'DELETE FROM exotic_dancers'
|
30
30
|
end
|
31
31
|
|
32
|
-
config.after(:
|
32
|
+
config.after(:suite) do
|
33
33
|
`rm -f ./tmp/test.db`
|
34
34
|
end
|
35
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dolla_dolla_bill
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-10-
|
13
|
+
date: 2012-10-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: money
|