spec/lbank_spec.rb in lbank-0.0.3 vs spec/lbank_spec.rb in lbank-1.0.0
- old
+ new
@@ -1,28 +1,28 @@
require 'spec_helper'
describe Lbank do
+ describe '#currency_rates' do
+ subject { described_class.currency_rates }
- it "should return currency rates" do
- currency_rates = subject.currency_rates
-
- currency_rates['USD'].should be > 0
+ its(['USD']) { is_expected.to be > 0 }
end
- it "should convert currency" do
- subject.convert_currency(10, 'LTL', 'EUR').should be > 0
+ describe '#convert_currency' do
+ it 'converts currency' do
+ expect(subject.convert_currency(10, 'USD', 'EUR')).to be > 0
+ expect(subject.convert_currency(10, 'EUR', 'LTL')).to eq 34.528
- date = Date.new(2012, 8, 4)
+ date = Date.new(2012, 8, 4)
- round(subject.convert_currency(10, 'LTL', 'EUR', date)).should == 2.90
- round(subject.convert_currency(10, 'LTL', 'USD', date)).should == 3.55
- round(subject.convert_currency(100, 'RUB', 'LTL', date)).should == 8.68
- round(subject.convert_currency(100, 'RUB', 'USD', date)).should == 3.08
+ expect(subject.convert_currency(10, 'EUR', 'LTL')).to eq 34.528
+ expect(round(subject.convert_currency(1, 'USD', 'EUR', date))).to eq 0.82
+ expect(round(subject.convert_currency(100, 'RUB', 'USD', date))).to eq 3.08
+ end
end
private
def round(number, precision = 2)
("%.#{precision}f" % number).to_f
end
-
-end
\ No newline at end of file
+end