wowecon 0.2.1 → 0.2.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.
@@ -46,6 +46,22 @@ module Wowecon
46
46
  def ==(other)
47
47
  @value == other.to_i
48
48
  end
49
+
50
+ def >(other)
51
+ @value > other.to_i
52
+ end
53
+
54
+ def <(other)
55
+ @value < other.to_i
56
+ end
57
+
58
+ def >=(other)
59
+ @value >= other.to_i
60
+ end
61
+
62
+ def <=(other)
63
+ @value <= other.to_i
64
+ end
49
65
 
50
66
  def nil?
51
67
  @value.nil?
@@ -3,33 +3,18 @@ require_relative "../lib/wowecon/currency.rb"
3
3
  describe Wowecon::Currency do
4
4
 
5
5
  it "can be initialised using a floating point value" do
6
- @currency = Wowecon::Currency.new(1420.091)
7
- @currency.class.should == Wowecon::Currency
6
+ currency = Wowecon::Currency.new(1420.091)
7
+ currency.class.should == Wowecon::Currency
8
8
  end
9
9
 
10
10
  it "can be initialised using a hash" do
11
- @currency = Wowecon::Currency.new({:gold => 1420, :silver => 9, :copper => 10})
12
- @currency.class.should == Wowecon::Currency
11
+ currency = Wowecon::Currency.new({:gold => 1420, :silver => 9, :copper => 10})
12
+ currency.class.should == Wowecon::Currency
13
13
  end
14
14
 
15
15
  it "can be initialised using an integer" do
16
- @currency = Wowecon::Currency.new(1420091)
17
- @currency.class.should == Wowecon::Currency
18
- end
19
-
20
- it "responds to integer" do
21
- @currency = Wowecon::Currency.new({:gold => 1420, :silver => 9, :copper => 10})
22
- (@currency.should respond_to :to_i) && @currency.to_i.should == 14200910
23
- end
24
-
25
- it "responds to hash" do
26
- @currency = Wowecon::Currency.new({:gold => 1420, :silver => 9, :copper => 10})
27
- (@currency.should respond_to :to_hash) && @currency.to_hash.should == {:gold => 1420, :silver => 9, :copper => 10}
28
- end
29
-
30
- it "responds to float" do
31
- @currency = Wowecon::Currency.new({:gold => 1420, :silver => 9, :copper => 10})
32
- (@currency.should respond_to :to_f) && @currency.to_f.should == 1420.091
16
+ currency = Wowecon::Currency.new(1420091)
17
+ currency.class.should == Wowecon::Currency
33
18
  end
34
19
 
35
20
  it "returns nil if initialised with an invalid hash" do
@@ -42,14 +27,46 @@ describe Wowecon::Currency do
42
27
  @nilcurrency.should be_nil
43
28
  end
44
29
 
45
- it "can create a string representation of the currency value" do
46
- @currency = Wowecon::Currency.new({:gold => 1420, :silver => 9, :copper => 10})
47
- @currency.to_s.should == "1,420g 9s 10c"
48
- end
49
-
50
- it "can create a HTML tag representation of the currency value" do
51
- @currency = Wowecon::Currency.new({:gold => 1420, :silver => 9, :copper => 10})
52
- @currency.to_html.should == '<var class="gold">1,420</var><var class="silver">9</var><var class="copper">10</var>'
30
+ describe "for a given valid currency" do
31
+ before do
32
+ @currency = Wowecon::Currency.new({:gold => 1420, :silver => 9, :copper => 10})
33
+ end
34
+
35
+ it "responds to integer" do
36
+ (@currency.should respond_to :to_i) and @currency.to_i.should == 14200910
37
+ end
38
+
39
+ it "responds to hash" do
40
+ (@currency.should respond_to :to_hash) and @currency.to_hash.should == {:gold => 1420, :silver => 9, :copper => 10}
41
+ end
42
+
43
+ it "responds to float" do
44
+ (@currency.should respond_to :to_f) and @currency.to_f.should == 1420.091
45
+ end
46
+
47
+ it "responds to greater than" do
48
+ (@currency.should respond_to :>) and @currency.should > 14200000
49
+ end
50
+
51
+ it "responds to less than" do
52
+ (@currency.should respond_to :<) and @currency.should < 20000000
53
+ end
54
+
55
+ it "responds to greater than/equal to" do
56
+ (@currency.should respond_to :>=) and @currency.should >= 14200000
57
+ end
58
+
59
+ it "responds to less than/equal to" do
60
+ (@currency.should respond_to :<=) and @currency.should <= 20000000
61
+ end
62
+
63
+ it "can create a string representation of the currency value" do
64
+ @currency.to_s.should == "1,420g 9s 10c"
65
+ end
66
+
67
+ it "can create a HTML tag representation of the currency value" do
68
+ @currency.to_html.should == '<var class="gold">1,420</var><var class="silver">9</var><var class="copper">10</var>'
69
+ end
53
70
  end
54
-
71
+
55
72
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: wowecon
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.1
5
+ version: 0.2.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ben Darlow