Решение на Шеста задача от Николай Димитров
Обратно към всички решения
Към профила на Николай Димитров
Резултати
- 5 точки от тестове
- 0 бонус точки
- 5 точки общо
- 37 успешни тест(а)
- 10 неуспешни тест(а)
Код
Лог от изпълнението
................FF..F.FF..F..FFFF..............
Failures:
1) Money convertion allows convertion to other currencies
Failure/Error: levas.amount.should eq '39.2'.to_d
NoMethodError:
undefined method `amount' for #<BigDecimal:9411a64,'0.392E2',18(45)>
# /tmp/d20130203-23049-g4tjra/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)>'
2) 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 `amount' for #<BigDecimal:9571f80,'0.5E1',9(36)>
# /tmp/d20130203-23049-g4tjra/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)>'
3) 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-g4tjra/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)>'
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-g4tjra/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 numeric objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<NoMethodError: undefined method `currency' for 42:Fixnum>
# /tmp/d20130203-23049-g4tjra/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 - with numeric objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<NoMethodError: undefined method `currency' for 42:Fixnum>
# /tmp/d20130203-23049-g4tjra/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 + with other objects raises an ArgumentError
Failure/Error: expect do
expected ArgumentError, got #<NoMethodError: undefined method `currency' for "foobar":String>
# /tmp/d20130203-23049-g4tjra/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 #<NoMethodError: undefined method `currency' for "foobar":String>
# /tmp/d20130203-23049-g4tjra/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-g4tjra/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-g4tjra/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.05978 seconds
47 examples, 10 failures
Failed examples:
rspec /tmp/d20130203-23049-g4tjra/spec.rb:95 # Money convertion allows convertion to other currencies
rspec /tmp/d20130203-23049-g4tjra/spec.rb:106 # Money convertion does not change the amount if the same currency is passed
rspec /tmp/d20130203-23049-g4tjra/spec.rb:128 # Money arithmetic * with money objects raises an ArgumentError
rspec /tmp/d20130203-23049-g4tjra/spec.rb:128 # Money arithmetic / with money objects raises an ArgumentError
rspec /tmp/d20130203-23049-g4tjra/spec.rb:136 # Money arithmetic + with numeric objects raises an ArgumentError
rspec /tmp/d20130203-23049-g4tjra/spec.rb:136 # Money arithmetic - with numeric objects raises an ArgumentError
rspec /tmp/d20130203-23049-g4tjra/spec.rb:159 # Money arithmetic + with other objects raises an ArgumentError
rspec /tmp/d20130203-23049-g4tjra/spec.rb:159 # Money arithmetic - with other objects raises an ArgumentError
rspec /tmp/d20130203-23049-g4tjra/spec.rb:159 # Money arithmetic * with other objects raises an ArgumentError
rspec /tmp/d20130203-23049-g4tjra/spec.rb:159 # Money arithmetic / with other objects raises an ArgumentError
История (5 версии и 2 коментара)
Николай обнови решението на 10.01.2013 13:04 (преди почти 12 години)
Николай обнови решението на 10.01.2013 14:09 (преди почти 12 години)
Николай обнови решението на 11.01.2013 09:16 (преди почти 12 години)
Николай обнови решението на 15.01.2013 20:18 (преди почти 12 години)
Николай обнови решението на 16.01.2013 12:08 (преди почти 12 години)