Решение на Шеста задача от Свилен Андонов
Обратно към всички решения
Към профила на Свилен Андонов
Резултати
- 4 точки от тестове
- 0 бонус точки
- 4 точки общо
- 28 успешни тест(а)
- 19 неуспешни тест(а)
Код
Лог от изпълнението
....F....F..F...FFF....F.FF.FFF.....FFF.F.F.F.F
Failures:
1) ExchangeRate#get returns nil for non-existing rates
Failure/Error: rate.get(:EUR, :BGN).should be_nil
NoMethodError:
undefined method `to_d' for nil:NilClass
# /tmp/d20130203-23049-jd2y1p/solution.rb:83:in `get'
# /tmp/d20130203-23049-jd2y1p/spec.rb:31: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 raises an ExchangeRate::Unknown exception when the rate is not defined
Failure/Error: end.to raise_error(ExchangeRate::Unknown)
NameError:
uninitialized constant ExchangeRate::Unknown
# /tmp/d20130203-23049-jd2y1p/spec.rb:58: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) ExchangeRate#convert works for identical currencies without defining any rates
Failure/Error: rate.convert(:JPY, :JPY, 123.to_d).should eq 123.to_d
expected: #<BigDecimal:a87be14,'0.123E3',9(36)>
got: nil
(compared using ==)
# /tmp/d20130203-23049-jd2y1p/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)>'
4) Money convertion allows convertion to other currencies
Failure/Error: levas.amount.should eq '39.2'.to_d
expected: #<BigDecimal:a89ebe4,'0.392E2',18(18)>
got: #<BigDecimal:a89ec34,'0.196E2',18(45)>
(compared using ==)
# /tmp/d20130203-23049-jd2y1p/spec.rb:102: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 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
NoMethodError:
undefined method `to_d' for nil:NilClass
# /tmp/d20130203-23049-jd2y1p/solution.rb:83:in `get'
# /tmp/d20130203-23049-jd2y1p/solution.rb:37:in `in'
# /tmp/d20130203-23049-jd2y1p/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)>'
6) Money convertion raises an ExchangeRate::Unknown exception for unknown rates
Failure/Error: end.to raise_error(ExchangeRate::Unknown)
NameError:
uninitialized constant ExchangeRate::Unknown
# /tmp/d20130203-23049-jd2y1p/spec.rb:113: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)>'
7) Money arithmetic + with numeric objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<NoMethodError: undefined method `amount' for 42:Fixnum>
# /tmp/d20130203-23049-jd2y1p/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-jd2y1p/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 numeric objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<NoMethodError: undefined method `amount' for 42:Fixnum>
# /tmp/d20130203-23049-jd2y1p/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)>'
10) 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-jd2y1p/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)>'
11) Money arithmetic + with other objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<NoMethodError: undefined method `amount' for "foobar":String>
# /tmp/d20130203-23049-jd2y1p/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)>'
12) Money arithmetic - with other objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<NoMethodError: undefined method `amount' for "foobar":String>
# /tmp/d20130203-23049-jd2y1p/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)>'
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-jd2y1p/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 ArgumentError when comparing with other objects
Failure/Error: expect do
expected ArgumentError but nothing was raised
# /tmp/d20130203-23049-jd2y1p/spec.rb:195: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-jd2y1p/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-jd2y1p/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)>'
17) Money comparison with <= raises IncompatibleCurrencies when currencies differ
Failure/Error: end.to raise_error(Money::IncompatibleCurrencies)
NameError:
uninitialized constant Money::IncompatibleCurrencies
# /tmp/d20130203-23049-jd2y1p/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)>'
18) Money comparison with > raises IncompatibleCurrencies when currencies differ
Failure/Error: end.to raise_error(Money::IncompatibleCurrencies)
NameError:
uninitialized constant Money::IncompatibleCurrencies
# /tmp/d20130203-23049-jd2y1p/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)>'
19) Money comparison with >= raises IncompatibleCurrencies when currencies differ
Failure/Error: end.to raise_error(Money::IncompatibleCurrencies)
NameError:
uninitialized constant Money::IncompatibleCurrencies
# /tmp/d20130203-23049-jd2y1p/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.07034 seconds
47 examples, 19 failures
Failed examples:
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:30 # ExchangeRate#get returns nil for non-existing rates
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:55 # ExchangeRate#convert raises an ExchangeRate::Unknown exception when the rate is not defined
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:71 # ExchangeRate#convert works for identical currencies without defining any rates
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:95 # Money convertion allows convertion to other currencies
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:106 # Money convertion does not change the amount if the same currency is passed
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:110 # Money convertion raises an ExchangeRate::Unknown exception for unknown rates
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:136 # Money arithmetic + with numeric objects raises an ArgumentError
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:151 # Money arithmetic raises Money::IncompatibleCurrencies for + with money with different currencies
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:136 # Money arithmetic - with numeric objects raises an ArgumentError
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:151 # Money arithmetic raises Money::IncompatibleCurrencies for - with money with different currencies
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:159 # Money arithmetic + with other objects raises an ArgumentError
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:159 # Money arithmetic - with other objects raises an ArgumentError
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:200 # Money comparison with <=> raises IncompatibleCurrencies when currencies differ
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:194 # Money comparison with == raises ArgumentError when comparing with other objects
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:200 # Money comparison with == raises IncompatibleCurrencies when currencies differ
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:200 # Money comparison with < raises IncompatibleCurrencies when currencies differ
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:200 # Money comparison with <= raises IncompatibleCurrencies when currencies differ
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:200 # Money comparison with > raises IncompatibleCurrencies when currencies differ
rspec /tmp/d20130203-23049-jd2y1p/spec.rb:200 # Money comparison with >= raises IncompatibleCurrencies when currencies differ
История (5 версии и 0 коментара)
Свилен обнови решението на 12.01.2013 10:57 (преди около 12 години)
Свилен обнови решението на 12.01.2013 11:03 (преди около 12 години)
Свилен обнови решението на 13.01.2013 13:35 (преди около 12 години)
Свилен обнови решението на 13.01.2013 18:19 (преди около 12 години)
Свилен обнови решението на 16.01.2013 11:36 (преди около 12 години)