Решение на Шеста задача от Филарета Йорданова
Обратно към всички решения
Към профила на Филарета Йорданова
Резултати
- 4 точки от тестове
- 0 бонус точки
- 4 точки общо
- 31 успешни тест(а)
- 16 неуспешни тест(а)
Код
Лог от изпълнението
.......F....F..F.F.....F.FF.FFF.....F.F.F.F.F.F
Failures:
1) ExchangeRate#get always returns 1 as the exchange rate between two identical currencies
Failure/Error: rate.get(:JPY, :JPY).should eq 1.to_d
expected: #<BigDecimal:8e52eac,'0.1E1',9(36)>
got: nil
(compared using ==)
# /tmp/d20130203-23049-gk3b9b/spec.rb:45:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) ExchangeRate#convert works for identical currencies without defining any rates
Failure/Error: rate.convert(:JPY, :JPY, 123.to_d).should eq 123.to_d
ExchangeRate::Unknown:
ExchangeRate::Unknown
# /tmp/d20130203-23049-gk3b9b/solution.rb:35:in `convert'
# /tmp/d20130203-23049-gk3b9b/spec.rb:72:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
3) Money has a custom to_s representation
Failure/Error: Money.new('12.1'.to_d, :USD).to_s.should eq '12.10 USD'
expected: "12.10 USD"
got: "12.1 USD"
(compared using ==)
# /tmp/d20130203-23049-gk3b9b/spec.rb:90:in `block (2 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
4) Money convertion does not change the amount if the same currency is passed
Failure/Error: Money.new(5.to_d, :EUR).in(:EUR, ExchangeRate.new).amount.should eq 5.to_d
ExchangeRate::Unknown:
ExchangeRate::Unknown
# /tmp/d20130203-23049-gk3b9b/solution.rb:35:in `convert'
# /tmp/d20130203-23049-gk3b9b/solution.rb:57:in `in'
# /tmp/d20130203-23049-gk3b9b/spec.rb:107:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
5) Money arithmetic + with numeric objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<NoMethodError: undefined method `currency' for 42:Fixnum>
# /tmp/d20130203-23049-gk3b9b/spec.rb:137:in `block (4 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
6) Money arithmetic raises Money::IncompatibleCurrencies for + with money with different currencies
Failure/Error: end.to raise_error(Money::IncompatibleCurrencies)
NameError:
uninitialized constant Money::IncompatibleCurrencies
# /tmp/d20130203-23049-gk3b9b/spec.rb:154:in `block (4 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
7) Money arithmetic - with numeric objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<NoMethodError: undefined method `currency' for 42:Fixnum>
# /tmp/d20130203-23049-gk3b9b/spec.rb:137:in `block (4 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
8) Money arithmetic raises Money::IncompatibleCurrencies for - with money with different currencies
Failure/Error: end.to raise_error(Money::IncompatibleCurrencies)
NameError:
uninitialized constant Money::IncompatibleCurrencies
# /tmp/d20130203-23049-gk3b9b/spec.rb:154:in `block (4 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
9) Money arithmetic + with other objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<NoMethodError: undefined method `currency' for "foobar":String>
# /tmp/d20130203-23049-gk3b9b/spec.rb:160:in `block (4 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
10) Money arithmetic - with other objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<NoMethodError: undefined method `currency' for "foobar":String>
# /tmp/d20130203-23049-gk3b9b/spec.rb:160:in `block (4 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
11) Money comparison with <=> raises IncompatibleCurrencies when currencies differ
Failure/Error: end.to raise_error(Money::IncompatibleCurrencies)
NameError:
uninitialized constant Money::IncompatibleCurrencies
# /tmp/d20130203-23049-gk3b9b/spec.rb:203:in `block (4 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
12) Money comparison with == raises IncompatibleCurrencies when currencies differ
Failure/Error: end.to raise_error(Money::IncompatibleCurrencies)
NameError:
uninitialized constant Money::IncompatibleCurrencies
# /tmp/d20130203-23049-gk3b9b/spec.rb:203:in `block (4 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
13) Money comparison with < raises IncompatibleCurrencies when currencies differ
Failure/Error: end.to raise_error(Money::IncompatibleCurrencies)
NameError:
uninitialized constant Money::IncompatibleCurrencies
# /tmp/d20130203-23049-gk3b9b/spec.rb:203:in `block (4 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
14) Money comparison with <= raises IncompatibleCurrencies when currencies differ
Failure/Error: end.to raise_error(Money::IncompatibleCurrencies)
NameError:
uninitialized constant Money::IncompatibleCurrencies
# /tmp/d20130203-23049-gk3b9b/spec.rb:203:in `block (4 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
15) Money comparison with > raises IncompatibleCurrencies when currencies differ
Failure/Error: end.to raise_error(Money::IncompatibleCurrencies)
NameError:
uninitialized constant Money::IncompatibleCurrencies
# /tmp/d20130203-23049-gk3b9b/spec.rb:203:in `block (4 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
16) Money comparison with >= raises IncompatibleCurrencies when currencies differ
Failure/Error: end.to raise_error(Money::IncompatibleCurrencies)
NameError:
uninitialized constant Money::IncompatibleCurrencies
# /tmp/d20130203-23049-gk3b9b/spec.rb:203:in `block (4 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.06523 seconds
47 examples, 16 failures
Failed examples:
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:44 # ExchangeRate#get always returns 1 as the exchange rate between two identical currencies
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:71 # ExchangeRate#convert works for identical currencies without defining any rates
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:88 # Money has a custom to_s representation
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:106 # Money convertion does not change the amount if the same currency is passed
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:136 # Money arithmetic + with numeric objects raises an ArgumentError
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:151 # Money arithmetic raises Money::IncompatibleCurrencies for + with money with different currencies
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:136 # Money arithmetic - with numeric objects raises an ArgumentError
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:151 # Money arithmetic raises Money::IncompatibleCurrencies for - with money with different currencies
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:159 # Money arithmetic + with other objects raises an ArgumentError
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:159 # Money arithmetic - with other objects raises an ArgumentError
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:200 # Money comparison with <=> raises IncompatibleCurrencies when currencies differ
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:200 # Money comparison with == raises IncompatibleCurrencies when currencies differ
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:200 # Money comparison with < raises IncompatibleCurrencies when currencies differ
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:200 # Money comparison with <= raises IncompatibleCurrencies when currencies differ
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:200 # Money comparison with > raises IncompatibleCurrencies when currencies differ
rspec /tmp/d20130203-23049-gk3b9b/spec.rb:200 # Money comparison with >= raises IncompatibleCurrencies when currencies differ
История (2 версии и 0 коментара)
Филарета обнови решението на 13.01.2013 17:57 (преди почти 12 години)
Филарета обнови решението на 14.01.2013 01:36 (преди почти 12 години)