spec/currency_spec.rb in currencies-0.4.0 vs spec/currency_spec.rb in currencies-0.4.1
- old
+ new
@@ -1,65 +1,67 @@
+# encoding: utf-8
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe ISO4217::Currency do
before(:all) do
@usd = ISO4217::Currency.from_code(:USD)
@gbp = ISO4217::Currency.from_code(:GBP)
end
-
+
it 'should return code' do
@usd.code.should == 'USD'
@gbp.code.should == 'GBP'
@usd[:code].should == 'USD'
@gbp[:code].should == 'GBP'
@usd['code'].should == 'USD'
@gbp['code'].should == 'GBP'
end
-
+
it 'should return symbol' do
@usd.symbol.should == '$'
@gbp.symbol.should == '£'
@usd[:symbol].should == '$'
@gbp[:symbol].should == '£'
@usd['symbol'].should == '$'
@gbp['symbol'].should == '£'
end
-
+
it 'should return name' do
@usd.name.should == 'Dollars'
@gbp.name.should == 'Pounds'
@usd[:name].should == 'Dollars'
@gbp[:name].should == 'Pounds'
@usd['name'].should == 'Dollars'
@gbp['name'].should == 'Pounds'
end
-
+
describe 'from_code' do
it 'should return new Currency instance when passed iso4217 currency code' do
ISO4217::Currency.from_code('USD').should be_a(ISO4217::Currency)
end
-
+
it 'should return a currency with the same code' do
ISO4217::Currency.from_code('USD').code.should == 'USD'
ISO4217::Currency.from_code('GBP').code.should == 'GBP'
end
-
+
it 'should accept symbol' do
ISO4217::Currency.from_code(:USD).code.should == 'USD'
ISO4217::Currency.from_code(:GBP).code.should == 'GBP'
end
-
+
it 'should work with lower case' do
ISO4217::Currency.from_code('usd').code.should == 'USD'
ISO4217::Currency.from_code('gbp').code.should == 'GBP'
end
end
-
+
describe 'exchange_rate' do
it 'should return a float' do
ISO4217::Currency.from_code('GBP').exchange_rate.should be_a(Float)
end
-
+
it 'should have an exchange rate of 1.0 for the base currency' do
ISO4217::Currency.from_code(ISO4217::Currency.base_currency).exchange_rate.should == 1.0
end
end