Решение на Шеста задача от Елена Денева
Обратно към всички решения
Към профила на Елена Денева
Резултати
- 5 точки от тестове
- 0 бонус точки
- 5 точки общо
- 37 успешни тест(а)
- 10 неуспешни тест(а)
Код
Лог от изпълнението
/tmp/d201......F....F.F........FF....FF........
Failures:
1) ExchangeRate#get returns nil for non-existing rates
Failure/Error: rate.get(:EUR, :BGN).should be_nil
NoMethodError:
undefined method `[]' for nil:NilClass
# /tmp/d20130203-23049-1ayl2i0/solution.rb:20:in `get'
# /tmp/d20130203-23049-1ayl2i0/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#get always returns 1 as the exchange rate between two identical currencies
Failure/Error: rate.get(:JPY, :JPY).should eq 1.to_d
NoMethodError:
undefined method `[]' for nil:NilClass
# /tmp/d20130203-23049-1ayl2i0/solution.rb:20:in `get'
# /tmp/d20130203-23049-1ayl2i0/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)>'
3) ExchangeRate#get does not allow changing the exchange rate between two identical currencies
Failure/Error: rate.get(:EUR, :EUR).should eq 1.to_d
expected: #<BigDecimal:9f48dd8,'0.1E1',9(36)>
got: #<BigDecimal:9f48e28,'0.5E0',9(36)>
(compared using ==)
# /tmp/d20130203-23049-1ayl2i0/spec.rb:50: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 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-1ayl2i0/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)>'
5) Money arithmetic * with money objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<RuntimeError: Invalid operation>
# /tmp/d20130203-23049-1ayl2i0/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 money objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<RuntimeError: Invalid operation>
# /tmp/d20130203-23049-1ayl2i0/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)>'
7) Money arithmetic * with other objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<RuntimeError: Invalid operation>
# /tmp/d20130203-23049-1ayl2i0/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)>'
8) Money arithmetic / with other objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<RuntimeError: Invalid operation>
# /tmp/d20130203-23049-1ayl2i0/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 comparison with == raises ArgumentError when comparing with other objects
Failure/Error: expect do
expected ArgumentError but nothing was raised
# /tmp/d20130203-23049-1ayl2i0/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)>'
10) Money comparison with == raises IncompatibleCurrencies when currencies differ
Failure/Error: expect do
expected IncompatibleCurrencies but nothing was raised
# /tmp/d20130203-23049-1ayl2i0/spec.rb:201: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.07715 seconds
47 examples, 10 failures
Failed examples:
rspec /tmp/d20130203-23049-1ayl2i0/spec.rb:30 # ExchangeRate#get returns nil for non-existing rates
rspec /tmp/d20130203-23049-1ayl2i0/spec.rb:44 # ExchangeRate#get always returns 1 as the exchange rate between two identical currencies
rspec /tmp/d20130203-23049-1ayl2i0/spec.rb:48 # ExchangeRate#get does not allow changing the exchange rate between two identical currencies
rspec /tmp/d20130203-23049-1ayl2i0/spec.rb:88 # Money has a custom to_s representation
rspec /tmp/d20130203-23049-1ayl2i0/spec.rb:128 # Money arithmetic * with money objects raises an ArgumentError
rspec /tmp/d20130203-23049-1ayl2i0/spec.rb:128 # Money arithmetic / with money objects raises an ArgumentError
rspec /tmp/d20130203-23049-1ayl2i0/spec.rb:159 # Money arithmetic * with other objects raises an ArgumentError
rspec /tmp/d20130203-23049-1ayl2i0/spec.rb:159 # Money arithmetic / with other objects raises an ArgumentError
rspec /tmp/d20130203-23049-1ayl2i0/spec.rb:194 # Money comparison with == raises ArgumentError when comparing with other objects
rspec /tmp/d20130203-23049-1ayl2i0/spec.rb:200 # Money comparison with == raises IncompatibleCurrencies when currencies differ
История (1 версия и 0 коментара)
Елена обнови решението на 11.01.2013 19:33 (преди почти 12 години)