sevenwire-money 2.3.1 → 2.3.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/money/errors.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  class Money
2
+ class UnknownMonetaryValue < StandardError; end
2
3
  class UnknownRate < StandardError; end
3
4
  end
data/lib/money/money.rb CHANGED
@@ -55,6 +55,9 @@ class Money
55
55
  # By default, it will accept money in cents, however,
56
56
  # you can also pass millicents by specifying :units => :millicents.
57
57
  def initialize(money, *args)
58
+ raise Money::UnknownMonetaryValue, %{There is no way to turn "#{money}" into money} if !money.nil? && !money.is_a?(Numeric)
59
+
60
+ money = 0 if money.nil?
58
61
  options = args.last.is_a?(Hash) ? args.pop : {}
59
62
 
60
63
  if options[:units] == :millicents
data/money.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "money"
3
- s.version = "2.3.1"
3
+ s.version = "2.3.2"
4
4
  s.summary = "Money and MicroMoney with currency exchange support library"
5
5
  s.email = "brandon@sevenwire.com"
6
6
  s.homepage = "http://github.com/sevenwire/money"
data/test/money_spec.rb CHANGED
@@ -5,6 +5,21 @@ require 'money/currencies'
5
5
 
6
6
  describe Money do
7
7
 
8
+ it "returns 0 if nil is passed in" do
9
+ Money.new(nil).should == 0.to_money
10
+ end
11
+
12
+ it "raises Money::UnknownMonetaryValue if passed something other than nil or a Numeric" do
13
+ block = lambda { Money.new("") }
14
+ block.should raise_error(Money::UnknownMonetaryValue)
15
+
16
+ block = lambda { Money.new("asdf") }
17
+ block.should raise_error(Money::UnknownMonetaryValue)
18
+
19
+ block = lambda { Money.new("100") }
20
+ block.should raise_error(Money::UnknownMonetaryValue)
21
+ end
22
+
8
23
  it "is associated to the singleton instance of VariableExchangeBank by default" do
9
24
  Money.new(0).bank.object_id.should == Money::VariableExchangeBank.instance.object_id
10
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sevenwire-money
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Luetke