wowecon 0.1.1 → 0.1.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.
@@ -13,9 +13,15 @@ module Wowecon
13
13
  self.silver = f[1][0,2].to_i
14
14
  self.copper = f[1][2,2].to_i
15
15
  elsif value.class == Hash
16
- self.gold = value[:gold]
17
- self.silver = value[:silver]
18
- self.copper = value[:copper]
16
+ if value.key?(:gold) and value.key?(:silver) and value.key?(:copper)
17
+ self.gold = value[:gold]
18
+ self.silver = value[:silver]
19
+ self.copper = value[:copper]
20
+ else
21
+ self.gold = 0
22
+ self.silver = 0
23
+ self.copper = 0
24
+ end
19
25
  end
20
26
  end
21
27
 
@@ -24,6 +24,11 @@ describe Wowecon::Currency do
24
24
  (@currency.should respond_to :to_f) && @currency.to_f.should == 1420.091
25
25
  end
26
26
 
27
+ it "returns a currency value of zero if initialised with an invalid hash" do
28
+ zero = Wowecon::Currency.new({:error => "price not found"})
29
+ zero.to_f.should == 0 && zero.to_hash.should == {:gold => 0, :silver => 0, :copper => 0}
30
+ end
31
+
27
32
  it "can create a string representation of the currency value" do
28
33
  @currency.to_s.should == "1,420g 9s 10c"
29
34
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: wowecon
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ben Darlow
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-01 00:00:00 +01:00
13
+ date: 2011-07-04 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency