acvwilson-currency 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/currency.gemspec +2 -2
- data/lib/currency.rb +1 -1
- data/spec/ar_column_spec.rb +27 -46
- data/spec/ar_spec_helper.rb +4 -4
- data/spec/federal_reserve_spec.rb +6 -6
- data/spec/historical_writer_spec.rb +16 -16
- data/spec/macro_spec.rb +8 -8
- data/spec/money_spec.rb +1 -9
- data/spec/new_york_fed_spec.rb +11 -11
- data/spec/parser_spec.rb +14 -14
- data/spec/timed_cache_spec.rb +23 -23
- metadata +2 -2
data/currency.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{currency}
|
3
|
-
s.version = "0.5.
|
3
|
+
s.version = "0.5.2"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Asa Wilson"]
|
@@ -14,5 +14,5 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.rdoc_options = ["--main", "README.txt"]
|
15
15
|
s.require_paths = ["lib"]
|
16
16
|
s.rubygems_version = %q{1.2.0}
|
17
|
-
s.summary = %q{currency 0.5.
|
17
|
+
s.summary = %q{currency 0.5.2}
|
18
18
|
end
|
data/lib/currency.rb
CHANGED
@@ -131,8 +131,8 @@ require 'currency/money'
|
|
131
131
|
require 'currency/currency'
|
132
132
|
require 'currency/currency/factory'
|
133
133
|
require 'currency/money'
|
134
|
-
require 'currency/formatter'
|
135
134
|
require 'currency/parser'
|
135
|
+
require 'currency/formatter' # require this one before the parser and enjoy the weird bugs!
|
136
136
|
require 'currency/exchange'
|
137
137
|
require 'currency/exchange/rate'
|
138
138
|
require 'currency/exchange/rate/deriver'
|
data/spec/ar_column_spec.rb
CHANGED
@@ -1,76 +1,57 @@
|
|
1
|
-
# Copyright (C) 2006-2007 Kurt Stephens <ruby-currency(at)umleta.com>
|
2
|
-
# See LICENSE.txt for details.
|
3
|
-
|
4
|
-
# require 'test/ar_test_core'
|
5
|
-
# require 'currency'
|
6
|
-
#
|
7
|
-
# require 'rubygems'
|
8
|
-
# require 'active_record'
|
9
|
-
# require 'active_record/migration'
|
10
|
-
# require 'currency/active_record'
|
11
|
-
|
12
1
|
require File.dirname(__FILE__) + '/ar_spec_helper'
|
13
2
|
|
14
|
-
# module Currency
|
15
|
-
#
|
16
|
-
# class ArFieldTest < ArTestCore
|
17
3
|
|
18
|
-
|
19
|
-
|
20
|
-
|
4
|
+
##################################################
|
5
|
+
# Basic CurrenyTest AR::B class
|
6
|
+
#
|
21
7
|
|
22
|
-
|
8
|
+
# TODO: Move elsewhere, combine with other AR tests
|
23
9
|
|
24
|
-
|
25
|
-
def self.up
|
26
|
-
create_table TABLE_NAME.intern do |t|
|
27
|
-
t.column :name, :string
|
28
|
-
t.column :amount, :integer # Money
|
29
|
-
t.column :amount_currency, :string, :size => 3 # Money.currency.code
|
30
|
-
end
|
31
|
-
end
|
10
|
+
TABLE_NAME = 'currency_column_test'
|
32
11
|
|
33
|
-
|
34
|
-
|
12
|
+
class CurrencyColumnTestMigration < AR_M
|
13
|
+
def self.up
|
14
|
+
create_table TABLE_NAME.intern do |t|
|
15
|
+
t.column :name, :string
|
16
|
+
t.column :amount, :integer # Money
|
17
|
+
t.column :amount_currency, :string, :size => 3 # Money.currency.code
|
35
18
|
end
|
36
19
|
end
|
37
20
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
##################################################
|
44
|
-
|
21
|
+
def self.down
|
22
|
+
drop_table TABLE_NAME.intern
|
23
|
+
end
|
24
|
+
end
|
45
25
|
|
46
|
-
|
47
|
-
|
48
|
-
|
26
|
+
class CurrencyColumnTest < AR_B
|
27
|
+
set_table_name TABLE_NAME
|
28
|
+
attr_money :amount, :currency_column => true
|
29
|
+
end
|
49
30
|
|
50
|
-
|
31
|
+
##################################################
|
51
32
|
|
52
33
|
describe "ActiveRecord macros" do
|
53
34
|
before(:all) do
|
54
35
|
AR_B.establish_connection(database_spec)
|
55
36
|
@currency_test_migration ||= CurrencyColumnTestMigration
|
56
37
|
@currency_test ||= CurrencyColumnTest
|
57
|
-
|
38
|
+
schema_down
|
58
39
|
schema_up
|
59
40
|
end
|
60
41
|
|
61
42
|
after(:all) do
|
62
|
-
|
43
|
+
schema_down
|
63
44
|
end
|
64
45
|
|
65
|
-
it "
|
46
|
+
it "can store and retrieve money values from a DB and automagically transfomr them to Money" do
|
66
47
|
insert_records
|
67
48
|
|
68
49
|
usd = @currency_test.find(@usd.id)
|
69
|
-
usd.
|
70
|
-
|
50
|
+
usd.should == @usd
|
51
|
+
usd.object_id.should_not == @usd.object_id # not same object
|
71
52
|
|
72
53
|
cad = @currency_test.find(@cad.id)
|
73
|
-
cad.
|
74
|
-
|
54
|
+
cad.should == @cad
|
55
|
+
cad.object_id.should_not == @cad.object_id # not same object
|
75
56
|
end
|
76
57
|
end
|
data/spec/ar_spec_helper.rb
CHANGED
@@ -105,10 +105,10 @@ def assert_equal_money(a,b)
|
|
105
105
|
# Make sure a and b are not the same object.
|
106
106
|
b.object_id.should_not == a.object_id
|
107
107
|
b.id.should == a.id
|
108
|
-
a.amount.
|
109
|
-
a.amount.should be_kind_of(Money)
|
110
|
-
b.amount.
|
111
|
-
b.amount.should be_kind_of(Money)
|
108
|
+
a.amount.should_not == nil
|
109
|
+
a.amount.should be_kind_of(Currency::Money)
|
110
|
+
b.amount.should_not == nil
|
111
|
+
b.amount.should be_kind_of(Currency::Money)
|
112
112
|
# Make sure that what gets stored in the database comes back out
|
113
113
|
# when converted back to the original currency.
|
114
114
|
b.amount.rep.should == a.amount.convert(b.amount.currency).rep
|
@@ -40,12 +40,12 @@ class FederalReserveTest < TestBase
|
|
40
40
|
|
41
41
|
# yesterday = Time.now.to_date - 1
|
42
42
|
|
43
|
-
rates = Exchange::Rate::Source.default.source.raw_rates.
|
43
|
+
rates = Exchange::Rate::Source.default.source.raw_rates.should_not == nil
|
44
44
|
#assert_not_nil rates[:USD]
|
45
45
|
#assert_not_nil usd_cad = rates[:USD][:CAD]
|
46
46
|
|
47
|
-
usd = Money.new(123.45, :USD).
|
48
|
-
cad = usd.convert(:CAD).
|
47
|
+
usd = Money.new(123.45, :USD).should_not == nil
|
48
|
+
cad = usd.convert(:CAD).should_not == nil
|
49
49
|
|
50
50
|
# assert_kind_of Numeric, m = (cad.to_f / usd.to_f)
|
51
51
|
# $stderr.puts "m = #{m}"
|
@@ -56,13 +56,13 @@ class FederalReserveTest < TestBase
|
|
56
56
|
it "cad eur" do
|
57
57
|
return unless available?
|
58
58
|
|
59
|
-
rates = Exchange::Rate::Source.default.source.raw_rates.
|
59
|
+
rates = Exchange::Rate::Source.default.source.raw_rates.should_not == nil
|
60
60
|
#assert_not_nil rates[:USD]
|
61
61
|
#assert_not_nil usd_cad = rates[:USD][:CAD]
|
62
62
|
#assert_not_nil usd_eur = rates[:USD][:EUR]
|
63
63
|
|
64
|
-
cad = Money.new(123.45, :CAD).
|
65
|
-
eur = cad.convert(:EUR).
|
64
|
+
cad = Money.new(123.45, :CAD).should_not == nil
|
65
|
+
eur = cad.convert(:EUR).should_not == nil
|
66
66
|
|
67
67
|
#assert_kind_of Numeric, m = (eur.to_f / cad.to_f)
|
68
68
|
# $stderr.puts "m = #{m}"
|
@@ -49,8 +49,8 @@ class HistoricalWriterTest < ArTestBase
|
|
49
49
|
|
50
50
|
|
51
51
|
it "writer" do
|
52
|
-
src = @src.
|
53
|
-
writer = Exchange::Rate::Source::Historical::Writer.new().
|
52
|
+
src = @src.should_not == nil
|
53
|
+
writer = Exchange::Rate::Source::Historical::Writer.new().should_not == nil
|
54
54
|
writer.time_quantitizer = :current
|
55
55
|
writer.required_currencies = [ :USD, :GBP, :EUR, :CAD ]
|
56
56
|
writer.base_currencies = [ :USD ]
|
@@ -67,9 +67,9 @@ class HistoricalWriterTest < ArTestBase
|
|
67
67
|
writer = test_writer
|
68
68
|
writer.source = @src
|
69
69
|
rates = writer.write_rates
|
70
|
-
rates.
|
70
|
+
rates.should_not == nil
|
71
71
|
rates.size.should > 0
|
72
|
-
12, rates.size.
|
72
|
+
12, rates.size.should_not == nil
|
73
73
|
assert_h_rates(rates, writer)
|
74
74
|
end
|
75
75
|
|
@@ -79,7 +79,7 @@ class HistoricalWriterTest < ArTestBase
|
|
79
79
|
writer.source = @src2
|
80
80
|
return unless writer.source.available?
|
81
81
|
rates = writer.write_rates
|
82
|
-
rates.
|
82
|
+
rates.should_not == nil
|
83
83
|
rates.size.should > 0
|
84
84
|
rates.size.should == 12
|
85
85
|
assert_h_rates(rates, writer)
|
@@ -87,8 +87,8 @@ class HistoricalWriterTest < ArTestBase
|
|
87
87
|
|
88
88
|
|
89
89
|
def xxx_test_required_failure
|
90
|
-
writer = Exchange::Rate::Source::Historical::Writer.new().
|
91
|
-
src = @src.
|
90
|
+
writer = Exchange::Rate::Source::Historical::Writer.new().should_not == nil
|
91
|
+
src = @src.should_not == nil
|
92
92
|
writer.source = src
|
93
93
|
writer.required_currencies = [ :USD, :GBP, :EUR, :CAD, :ZZZ ]
|
94
94
|
writer.preferred_currencies = writer.required_currencies
|
@@ -106,33 +106,33 @@ class HistoricalWriterTest < ArTestBase
|
|
106
106
|
deriver = Exchange::Rate::Deriver.new(:source => source)
|
107
107
|
Exchange::Rate::Source.default = deriver
|
108
108
|
|
109
|
-
rates = source.get_raw_rates.
|
110
|
-
rates.empty?.
|
109
|
+
rates = source.get_raw_rates.should_not == nil
|
110
|
+
rates.empty?.should_not == true
|
111
111
|
# $stderr.puts "historical rates = #{rates.inspect}"
|
112
112
|
|
113
|
-
rates = source.get_rates.
|
114
|
-
rates.empty?.
|
113
|
+
rates = source.get_rates.should_not == nil
|
114
|
+
rates.empty?.should_not == true
|
115
115
|
# $stderr.puts "historical rates = #{rates.inspect}"
|
116
116
|
|
117
|
-
m_usd = ::Currency.Money('1234.56', :USD, :now).
|
117
|
+
m_usd = ::Currency.Money('1234.56', :USD, :now).should_not == nil
|
118
118
|
# $stderr.puts "m_usd = #{m_usd.to_s(:code => true)}"
|
119
|
-
m_eur = m_usd.convert(:EUR).
|
119
|
+
m_eur = m_usd.convert(:EUR).should_not == nil
|
120
120
|
# $stderr.puts "m_eur = #{m_eur.to_s(:code => true)}"
|
121
121
|
|
122
122
|
end
|
123
123
|
|
124
124
|
|
125
125
|
def assert_h_rates(rates, writer = nil)
|
126
|
-
hr0 = rates[0].
|
126
|
+
hr0 = rates[0].should_not == nil
|
127
127
|
rates.each do | hr |
|
128
128
|
found_hr = nil
|
129
129
|
begin
|
130
|
-
found_hr = hr.find_matching_this(:first).
|
130
|
+
found_hr = hr.find_matching_this(:first).should_not == nil
|
131
131
|
rescue Object => err
|
132
132
|
raise "#{hr.inspect}: #{err}:\n#{err.backtrace.inspect}"
|
133
133
|
end
|
134
134
|
|
135
|
-
hr0.
|
135
|
+
hr0.should_not == nil
|
136
136
|
|
137
137
|
hr.date.should == hr0.date
|
138
138
|
hr.date_0.should == hr0.date_0
|
data/spec/macro_spec.rb
CHANGED
@@ -46,7 +46,7 @@ class MacroTest < TestBase
|
|
46
46
|
|
47
47
|
it "read money" do
|
48
48
|
assert_kind_of Record, r = Record.new
|
49
|
-
r.gross = 10.00.
|
49
|
+
r.gross = 10.00.should_not == nil
|
50
50
|
r.gross.should == r.gross_money.to_f
|
51
51
|
r.currency.should == r.gross_money.currency.code
|
52
52
|
r.date.should == r.gross_money.time
|
@@ -57,7 +57,7 @@ class MacroTest < TestBase
|
|
57
57
|
|
58
58
|
it "write money rep" do
|
59
59
|
assert_kind_of Record, r = Record.new
|
60
|
-
r.gross_money = 10.00.
|
60
|
+
r.gross_money = 10.00.should_not == nil
|
61
61
|
r.gross.should == r.gross_money.to_f
|
62
62
|
r.currency.should == r.gross_money.currency.code
|
63
63
|
r.date.should == r.gross_money.time
|
@@ -69,20 +69,20 @@ class MacroTest < TestBase
|
|
69
69
|
it "money cache" do
|
70
70
|
r = test_read_money
|
71
71
|
|
72
|
-
r_gross = r.gross.
|
72
|
+
r_gross = r.gross.should_not == nil
|
73
73
|
r_gross.object_id.should == r.gross.object_id
|
74
74
|
|
75
75
|
# Cache flush
|
76
|
-
r.gross = 12.00.
|
76
|
+
r.gross = 12.00.should_not == nil
|
77
77
|
r.gross.should == r.gross_money.to_f
|
78
|
-
r_gross.object_id != r.gross.object_id.
|
78
|
+
r_gross.object_id != r.gross.object_id.should_not == nil
|
79
79
|
end
|
80
80
|
|
81
81
|
|
82
82
|
it "currency" do
|
83
83
|
r = test_read_money
|
84
84
|
|
85
|
-
r.gross_money.currency.
|
85
|
+
r.gross_money.currency.should_not == nil
|
86
86
|
r.currency.should == r.gross_money.currency.code
|
87
87
|
|
88
88
|
end
|
@@ -90,8 +90,8 @@ class MacroTest < TestBase
|
|
90
90
|
|
91
91
|
it "compute" do
|
92
92
|
assert_kind_of Record, r = Record.new
|
93
|
-
r.gross = 10.00.
|
94
|
-
r.tax = 1.50.
|
93
|
+
r.gross = 10.00.should_not == nil
|
94
|
+
r.tax = 1.50.should_not == nil
|
95
95
|
r.compute_net
|
96
96
|
|
97
97
|
r.net.should == 8.50
|
data/spec/money_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
2
|
+
# require File.dirname(__FILE__) + '/../lib/currency/formatter'
|
3
3
|
|
4
4
|
describe Currency::Money do
|
5
5
|
|
@@ -38,14 +38,6 @@ describe Currency::Money do
|
|
38
38
|
:EUR.should == m.currency.code
|
39
39
|
m.rep.should == 45990000
|
40
40
|
end
|
41
|
-
|
42
|
-
it "creates money objects from strings" do
|
43
|
-
"12.0001".money(:USD).to_s.should == "$12.0001"
|
44
|
-
# "12.000108".money(:USD).to_s(:thousands => false, :decimals => 5).should == "$12.00011"
|
45
|
-
@money = Currency::Money.new_rep(1234567890000, :USD, nil)
|
46
|
-
|
47
|
-
Currency::Money.new("12.000108").to_s(:thousands => false, :decimals => 5).should == "$12.00011"
|
48
|
-
end
|
49
41
|
end
|
50
42
|
|
51
43
|
def zero_money
|
data/spec/new_york_fed_spec.rb
CHANGED
@@ -38,12 +38,12 @@ class NewYorkFedTest < TestBase
|
|
38
38
|
it "usd cad" do
|
39
39
|
return unless available?
|
40
40
|
|
41
|
-
rates = Exchange::Rate::Source.default.source.raw_rates.
|
42
|
-
rates[:USD].
|
43
|
-
usd_cad = rates[:USD][:CAD].
|
41
|
+
rates = Exchange::Rate::Source.default.source.raw_rates.should_not == nil
|
42
|
+
rates[:USD].should_not == nil
|
43
|
+
usd_cad = rates[:USD][:CAD].should_not == nil
|
44
44
|
|
45
|
-
usd = Money.new(123.45, :USD).
|
46
|
-
cad = usd.convert(:CAD).
|
45
|
+
usd = Money.new(123.45, :USD).should_not == nil
|
46
|
+
cad = usd.convert(:CAD).should_not == nil
|
47
47
|
|
48
48
|
assert_kind_of Numeric, m = (cad.to_f / usd.to_f)
|
49
49
|
# $stderr.puts "m = #{m}"
|
@@ -54,13 +54,13 @@ class NewYorkFedTest < TestBase
|
|
54
54
|
it "cad eur" do
|
55
55
|
return unless available?
|
56
56
|
|
57
|
-
rates = Exchange::Rate::Source.default.source.raw_rates.
|
58
|
-
rates[:USD].
|
59
|
-
usd_cad = rates[:USD][:CAD].
|
60
|
-
usd_eur = rates[:USD][:EUR].
|
57
|
+
rates = Exchange::Rate::Source.default.source.raw_rates.should_not == nil
|
58
|
+
rates[:USD].should_not == nil
|
59
|
+
usd_cad = rates[:USD][:CAD].should_not == nil
|
60
|
+
usd_eur = rates[:USD][:EUR].should_not == nil
|
61
61
|
|
62
|
-
cad = Money.new(123.45, :CAD).
|
63
|
-
eur = cad.convert(:EUR).
|
62
|
+
cad = Money.new(123.45, :CAD).should_not == nil
|
63
|
+
eur = cad.convert(:EUR).should_not == nil
|
64
64
|
|
65
65
|
assert_kind_of Numeric, m = (eur.to_f / cad.to_f)
|
66
66
|
# $stderr.puts "m = #{m}"
|
data/spec/parser_spec.rb
CHANGED
@@ -39,15 +39,15 @@ class ParserTest < TestBase
|
|
39
39
|
|
40
40
|
|
41
41
|
it "misc" do
|
42
|
-
m = "123.45 USD".money + "100 CAD".
|
43
|
-
(m.rep == 200.45).
|
42
|
+
m = "123.45 USD".money + "100 CAD".should_not == nil
|
43
|
+
(m.rep == 200.45).should_not == true
|
44
44
|
end
|
45
45
|
|
46
46
|
|
47
47
|
it "round trip" do
|
48
48
|
::Currency::Currency.default = :USD
|
49
|
-
m = ::Currency::Money("1234567.89", :CAD).
|
50
|
-
m2 = ::Currency::Money(m.inspect).
|
49
|
+
m = ::Currency::Money("1234567.89", :CAD).should_not == nil
|
50
|
+
m2 = ::Currency::Money(m.inspect).should_not == nil
|
51
51
|
m2.rep.should == m.rep
|
52
52
|
m2.currency.should == m.currency
|
53
53
|
m2.time.should == nil
|
@@ -58,10 +58,10 @@ class ParserTest < TestBase
|
|
58
58
|
it "round trip time" do
|
59
59
|
::Currency::Currency.default = :USD
|
60
60
|
time = Time.now.getutc
|
61
|
-
m = ::Currency::Money("1234567.89", :CAD, time).
|
62
|
-
m.time.
|
63
|
-
m2 = ::Currency::Money(m.inspect).
|
64
|
-
m2.time.
|
61
|
+
m = ::Currency::Money("1234567.89", :CAD, time).should_not == nil
|
62
|
+
m.time.should_not == nil
|
63
|
+
m2 = ::Currency::Money(m.inspect).should_not == nil
|
64
|
+
m2.time.should_not == nil
|
65
65
|
m2.rep.should == m.rep
|
66
66
|
m2.currency.should == m.currency
|
67
67
|
m2.time.to_i.should == m.time.to_i
|
@@ -73,7 +73,7 @@ class ParserTest < TestBase
|
|
73
73
|
parser = ::Currency::Parser.new
|
74
74
|
parser.time = nil
|
75
75
|
|
76
|
-
m = parser.parse("$1234.55").
|
76
|
+
m = parser.parse("$1234.55").should_not == nil
|
77
77
|
m.time.should == nil
|
78
78
|
end
|
79
79
|
|
@@ -82,7 +82,7 @@ class ParserTest < TestBase
|
|
82
82
|
parser = ::Currency::Parser.new
|
83
83
|
parser.time = Time.new
|
84
84
|
|
85
|
-
m = parser.parse("$1234.55").
|
85
|
+
m = parser.parse("$1234.55").should_not == nil
|
86
86
|
m.time.should == parser.time
|
87
87
|
end
|
88
88
|
|
@@ -91,11 +91,11 @@ class ParserTest < TestBase
|
|
91
91
|
parser = ::Currency::Parser.new
|
92
92
|
parser.time = :now
|
93
93
|
|
94
|
-
m = parser.parse("$1234.55").
|
95
|
-
m1_time = m.time.
|
94
|
+
m = parser.parse("$1234.55").should_not == nil
|
95
|
+
m1_time = m.time.should_not == nil
|
96
96
|
|
97
|
-
m = parser.parse("$1234.55").
|
98
|
-
m2_time = m.time.
|
97
|
+
m = parser.parse("$1234.55").should_not == nil
|
98
|
+
m2_time = m.time.should_not == nil
|
99
99
|
|
100
100
|
assert_not_equal m1_time, m2_time
|
101
101
|
end
|
data/spec/timed_cache_spec.rb
CHANGED
@@ -28,12 +28,12 @@ class TimedCacheTest < TestBase
|
|
28
28
|
|
29
29
|
|
30
30
|
it "timed cache usd cad" do
|
31
|
-
rates = @source.raw_rates.
|
32
|
-
rates[:USD].
|
33
|
-
usd_cad = rates[:USD][:CAD].
|
31
|
+
rates = @source.raw_rates.should_not == nil
|
32
|
+
rates[:USD].should_not == nil
|
33
|
+
usd_cad = rates[:USD][:CAD].should_not == nil
|
34
34
|
|
35
|
-
usd = Money.new(123.45, :USD).
|
36
|
-
cad = usd.convert(:CAD).
|
35
|
+
usd = Money.new(123.45, :USD).should_not == nil
|
36
|
+
cad = usd.convert(:CAD).should_not == nil
|
37
37
|
|
38
38
|
assert_kind_of Numeric, m = (cad.to_f / usd.to_f)
|
39
39
|
# $stderr.puts "m = #{m}"
|
@@ -42,13 +42,13 @@ class TimedCacheTest < TestBase
|
|
42
42
|
|
43
43
|
|
44
44
|
it "timed cache cad eur" do
|
45
|
-
rates = @source.raw_rates.
|
46
|
-
rates[:USD].
|
47
|
-
usd_cad = rates[:USD][:CAD].
|
48
|
-
usd_eur = rates[:USD][:EUR].
|
45
|
+
rates = @source.raw_rates.should_not == nil
|
46
|
+
rates[:USD].should_not == nil
|
47
|
+
usd_cad = rates[:USD][:CAD].should_not == nil
|
48
|
+
usd_eur = rates[:USD][:EUR].should_not == nil
|
49
49
|
|
50
|
-
cad = Money.new(123.45, :CAD).
|
51
|
-
eur = cad.convert(:EUR).
|
50
|
+
cad = Money.new(123.45, :CAD).should_not == nil
|
51
|
+
eur = cad.convert(:EUR).should_not == nil
|
52
52
|
|
53
53
|
assert_kind_of Numeric, m = (eur.to_f / cad.to_f)
|
54
54
|
# $stderr.puts "m = #{m}"
|
@@ -61,32 +61,32 @@ class TimedCacheTest < TestBase
|
|
61
61
|
|
62
62
|
test_timed_cache_cad_eur
|
63
63
|
|
64
|
-
rates = @source.raw_rates.
|
65
|
-
rates[:USD].
|
66
|
-
usd_cad_1 = rates[:USD][:CAD].
|
64
|
+
rates = @source.raw_rates.should_not == nil
|
65
|
+
rates[:USD].should_not == nil
|
66
|
+
usd_cad_1 = rates[:USD][:CAD].should_not == nil
|
67
67
|
|
68
|
-
t1 = @cache.rate_load_time.
|
69
|
-
t1_reload = @cache.rate_reload_time.
|
68
|
+
t1 = @cache.rate_load_time.should_not == nil
|
69
|
+
t1_reload = @cache.rate_reload_time.should_not == nil
|
70
70
|
t1_reload.to_i.should > t1.to_i
|
71
71
|
|
72
72
|
@cache.time_to_live = 5
|
73
73
|
@cache.time_to_live_fudge = 0
|
74
74
|
|
75
75
|
# puts @cache.rate_reload_time.to_i - @cache.rate_load_time.to_i
|
76
|
-
@cache.rate_reload_time.to_i - @cache.rate_load_time.to_i == @cache.time_to_live.
|
76
|
+
@cache.rate_reload_time.to_i - @cache.rate_load_time.to_i == @cache.time_to_live.should_not == nil
|
77
77
|
|
78
78
|
sleep 10
|
79
79
|
|
80
80
|
test_timed_cache_cad_eur
|
81
81
|
|
82
|
-
t2 = @cache.rate_load_time.
|
83
|
-
t1.to_i != t2.to_i.
|
82
|
+
t2 = @cache.rate_load_time.should_not == nil
|
83
|
+
t1.to_i != t2.to_i.should_not == nil
|
84
84
|
|
85
|
-
rates = @source.raw_rates.
|
86
|
-
rates[:USD].
|
87
|
-
usd_cad_2 = rates[:USD][:CAD].
|
85
|
+
rates = @source.raw_rates.should_not == nil
|
86
|
+
rates[:USD].should_not == nil
|
87
|
+
usd_cad_2 = rates[:USD][:CAD].should_not == nil
|
88
88
|
|
89
|
-
usd_cad_1.object_id != usd_cad_2.object_id.
|
89
|
+
usd_cad_1.object_id != usd_cad_2.object_id.should_not == nil
|
90
90
|
end
|
91
91
|
|
92
92
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acvwilson-currency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Asa Wilson
|
@@ -112,6 +112,6 @@ rubyforge_project:
|
|
112
112
|
rubygems_version: 1.2.0
|
113
113
|
signing_key:
|
114
114
|
specification_version: 2
|
115
|
-
summary: currency 0.5.
|
115
|
+
summary: currency 0.5.2
|
116
116
|
test_files: []
|
117
117
|
|