dolla_dolla_bill 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,10 +16,17 @@ module DollaDollaBill
16
16
  end
17
17
 
18
18
  define_method("#{name}=") do |value|
19
- value = value.to_money
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, value.cents)
22
- send(currency_field_writer, value.currency_as_string)
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
@@ -1,3 +1,3 @@
1
1
  module DollaDollaBill
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -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
@@ -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(:all) do
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(:all) do
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.1
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-06 00:00:00.000000000 Z
13
+ date: 2012-10-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: money