Решение на Шеста задача от Стоян Найденов
Обратно към всички решения
Към профила на Стоян Найденов
Резултати
- 5 точки от тестове
- 0 бонус точки
- 5 точки общо
- 36 успешни тест(а)
- 11 неуспешни тест(а)
Код
Лог от изпълнението
..FF...........F..F................F.FFF.F.F.F.
Failures:
1) ExchangeRate#set allows rates to be updated if called multiple times
Failure/Error: expect do
result should have been changed to #<BigDecimal:a60dc40,'0.149E1',18(18)>, but is now #<BigDecimal:a4d6cdc,'0.15E1',18(18)>
# /tmp/d20130203-23049-pf9na9/spec.rb:16: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#set sets the exchange rate in both directions
Failure/Error: rate.get(:EUR, :BGN).should eq '1.25'.to_d
expected: #<BigDecimal:a3da068,'0.125E1',18(18)>
got: #<BigDecimal:a60c37c,'0.2E1',9(36)>
(compared using ==)
# /tmp/d20130203-23049-pf9na9/spec.rb:25: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-pf9na9/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 raises an ExchangeRate::Unknown exception for unknown rates
Failure/Error: expect do
expected ExchangeRate::Unknown, got #<NoMethodError: undefined method `*' for nil:NilClass>
# /tmp/d20130203-23049-pf9na9/spec.rb:111: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 comparison with <=> raises ArgumentError when comparing with other objects
Failure/Error: expect do
expected ArgumentError, got #<NameError: uninitialized constant Money::ArgumentsError>
# /tmp/d20130203-23049-pf9na9/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)>'
6) Money comparison with == raises ArgumentError when comparing with other objects
Failure/Error: expect do
expected ArgumentError but nothing was raised
# /tmp/d20130203-23049-pf9na9/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)>'
7) Money comparison with == raises IncompatibleCurrencies when currencies differ
Failure/Error: expect do
expected Money::IncompatibleCurrencies but nothing was raised
# /tmp/d20130203-23049-pf9na9/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)>'
8) Money comparison with < raises ArgumentError when comparing with other objects
Failure/Error: expect do
expected ArgumentError, got #<NameError: uninitialized constant Money::ArgumentsError>
# /tmp/d20130203-23049-pf9na9/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)>'
9) Money comparison with <= raises ArgumentError when comparing with other objects
Failure/Error: expect do
expected ArgumentError, got #<NameError: uninitialized constant Money::ArgumentsError>
# /tmp/d20130203-23049-pf9na9/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 ArgumentError when comparing with other objects
Failure/Error: expect do
expected ArgumentError, got #<NameError: uninitialized constant Money::ArgumentsError>
# /tmp/d20130203-23049-pf9na9/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)>'
11) Money comparison with >= raises ArgumentError when comparing with other objects
Failure/Error: expect do
expected ArgumentError, got #<NameError: uninitialized constant Money::ArgumentsError>
# /tmp/d20130203-23049-pf9na9/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)>'
Finished in 0.06787 seconds
47 examples, 11 failures
Failed examples:
rspec /tmp/d20130203-23049-pf9na9/spec.rb:13 # ExchangeRate#set allows rates to be updated if called multiple times
rspec /tmp/d20130203-23049-pf9na9/spec.rb:21 # ExchangeRate#set sets the exchange rate in both directions
rspec /tmp/d20130203-23049-pf9na9/spec.rb:88 # Money has a custom to_s representation
rspec /tmp/d20130203-23049-pf9na9/spec.rb:110 # Money convertion raises an ExchangeRate::Unknown exception for unknown rates
rspec /tmp/d20130203-23049-pf9na9/spec.rb:194 # Money comparison with <=> raises ArgumentError when comparing with other objects
rspec /tmp/d20130203-23049-pf9na9/spec.rb:194 # Money comparison with == raises ArgumentError when comparing with other objects
rspec /tmp/d20130203-23049-pf9na9/spec.rb:200 # Money comparison with == raises IncompatibleCurrencies when currencies differ
rspec /tmp/d20130203-23049-pf9na9/spec.rb:194 # Money comparison with < raises ArgumentError when comparing with other objects
rspec /tmp/d20130203-23049-pf9na9/spec.rb:194 # Money comparison with <= raises ArgumentError when comparing with other objects
rspec /tmp/d20130203-23049-pf9na9/spec.rb:194 # Money comparison with > raises ArgumentError when comparing with other objects
rspec /tmp/d20130203-23049-pf9na9/spec.rb:194 # Money comparison with >= raises ArgumentError when comparing with other objects
История (2 версии и 0 коментара)
Стоян обнови решението на 16.01.2013 16:53 (преди около 12 години)
Стоян обнови решението на 16.01.2013 16:57 (преди около 12 години)