Решение на Шеста задача от Стоян Стоянов
Обратно към всички решения
Към профила на Стоян Стоянов
Резултати
- 5 точки от тестове
- 0 бонус точки
- 5 точки общо
- 37 успешни тест(а)
- 10 неуспешни тест(а)
Код
Лог от изпълнението
.......F....F....F..F.F...F.F.FFF..............
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:975381c,'0.1E1',9(36)>
got: nil
(compared using ==)
# /tmp/d20130203-23049-19n49n2/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-19n49n2/solution.rb:20:in `convert'
# /tmp/d20130203-23049-19n49n2/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 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-19n49n2/solution.rb:20:in `convert'
# /tmp/d20130203-23049-19n49n2/solution.rb:47:in `in'
# /tmp/d20130203-23049-19n49n2/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)>'
4) Money arithmetic * with money objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<TypeError: Money can't be coerced into BigDecimal>
# /tmp/d20130203-23049-19n49n2/spec.rb:129: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)>'
5) Money arithmetic / with money objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<TypeError: Money can't be coerced into BigDecimal>
# /tmp/d20130203-23049-19n49n2/spec.rb:129: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 - with numeric objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<NoMethodError: undefined method `amount' for 42:Fixnum>
# /tmp/d20130203-23049-19n49n2/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)>'
7) Money arithmetic raises Money::IncompatibleCurrencies for - with money with different currencies
Failure/Error: expect do
expected Money::IncompatibleCurrencies but nothing was raised
# /tmp/d20130203-23049-19n49n2/spec.rb:152: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 - with other objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<NoMethodError: undefined method `amount' for "foobar":String>
# /tmp/d20130203-23049-19n49n2/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)>'
9) Money arithmetic * with other objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<TypeError: String can't be coerced into BigDecimal>
# /tmp/d20130203-23049-19n49n2/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 #<TypeError: String can't be coerced into BigDecimal>
# /tmp/d20130203-23049-19n49n2/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)>'
Finished in 0.07617 seconds
47 examples, 10 failures
Failed examples:
rspec /tmp/d20130203-23049-19n49n2/spec.rb:44 # ExchangeRate#get always returns 1 as the exchange rate between two identical currencies
rspec /tmp/d20130203-23049-19n49n2/spec.rb:71 # ExchangeRate#convert works for identical currencies without defining any rates
rspec /tmp/d20130203-23049-19n49n2/spec.rb:106 # Money convertion does not change the amount if the same currency is passed
rspec /tmp/d20130203-23049-19n49n2/spec.rb:128 # Money arithmetic * with money objects raises an ArgumentError
rspec /tmp/d20130203-23049-19n49n2/spec.rb:128 # Money arithmetic / with money objects raises an ArgumentError
rspec /tmp/d20130203-23049-19n49n2/spec.rb:136 # Money arithmetic - with numeric objects raises an ArgumentError
rspec /tmp/d20130203-23049-19n49n2/spec.rb:151 # Money arithmetic raises Money::IncompatibleCurrencies for - with money with different currencies
rspec /tmp/d20130203-23049-19n49n2/spec.rb:159 # Money arithmetic - with other objects raises an ArgumentError
rspec /tmp/d20130203-23049-19n49n2/spec.rb:159 # Money arithmetic * with other objects raises an ArgumentError
rspec /tmp/d20130203-23049-19n49n2/spec.rb:159 # Money arithmetic / with other objects raises an ArgumentError
История (2 версии и 0 коментара)
Стоян обнови решението на 15.01.2013 00:47 (преди около 12 години)
Стоян обнови решението на 15.01.2013 00:58 (преди около 12 години)