Решение на Четвърта задача от Александрина Каракехайова
Обратно към всички решения
Към профила на Александрина Каракехайова
Резултати
- 5 точки от тестове
- 1 отнета точка
- 4 точки общо
- 47 успешни тест(а)
- 10 неуспешни тест(а)
Код
Лог от изпълнението
....F......FF...........F.F...FF.F.F...............F.....
Failures:
1) WarDeck behaves like a deck fills the deck if no initialize parameters are given
Failure/Error: expect(deck.to_a).to match_array all_available_cards
expected collection contained: [#<Card:0x007ff90a242ce0 @rank=2, @suit=:clubs>, #<Card:0x007ff90a242cb8 @rank=3, @suit=:clubs>, #<Card:0x007ff90a242c90 @rank=4, @suit=:clubs>, #<Card:0x007ff90a242c68 @rank=5, @suit=:clubs>, #<Card:0x007ff90a242c40 @rank=6, @suit=:clubs>, #<Card:0x007ff90a242c18 @rank=7, @suit=:clubs>, #<Card:0x007ff90a242bf0 @rank=8, @suit=:clubs>, #<Card:0x007ff90a242bc8 @rank=9, @suit=:clubs>, #<Card:0x007ff90a242ba0 @rank=10, @suit=:clubs>, #<Card:0x007ff90a242b78 @rank=:jack, @suit=:clubs>, #<Card:0x007ff90a242b50 @rank=:queen, @suit=:clubs>, #<Card:0x007ff90a242b28 @rank=:king, @suit=:clubs>, #<Card:0x007ff90a242b00 @rank=:ace, @suit=:clubs>, #<Card:0x007ff90a242ad8 @rank=2, @suit=:diamonds>, #<Card:0x007ff90a242ab0 @rank=3, @suit=:diamonds>, #<Card:0x007ff90a242a88 @rank=4, @suit=:diamonds>, #<Card:0x007ff90a242a10 @rank=5, @suit=:diamonds>, #<Card:0x007ff90a2429e8 @rank=6, @suit=:diamonds>, #<Card:0x007ff90a242998 @rank=7, @suit=:diamonds>, #<Card:0x007ff90a242970 @rank=8, @suit=:diamonds>, #<Card:0x007ff90a242948 @rank=9, @suit=:diamonds>, #<Card:0x007ff90a242920 @rank=10, @suit=:diamonds>, #<Card:0x007ff90a2428f8 @rank=:jack, @suit=:diamonds>, #<Card:0x007ff90a2428d0 @rank=:queen, @suit=:diamonds>, #<Card:0x007ff90a2428a8 @rank=:king, @suit=:diamonds>, #<Card:0x007ff90a242880 @rank=:ace, @suit=:diamonds>, #<Card:0x007ff90a242858 @rank=2, @suit=:hearts>, #<Card:0x007ff90a242830 @rank=3, @suit=:hearts>, #<Card:0x007ff90a242808 @rank=4, @suit=:hearts>, #<Card:0x007ff90a2427e0 @rank=5, @suit=:hearts>, #<Card:0x007ff90a2427b8 @rank=6, @suit=:hearts>, #<Card:0x007ff90a242790 @rank=7, @suit=:hearts>, #<Card:0x007ff90a242768 @rank=8, @suit=:hearts>, #<Card:0x007ff90a242740 @rank=9, @suit=:hearts>, #<Card:0x007ff90a242718 @rank=10, @suit=:hearts>, #<Card:0x007ff90a2426f0 @rank=:jack, @suit=:hearts>, #<Card:0x007ff90a2426c8 @rank=:queen, @suit=:hearts>, #<Card:0x007ff90a2426a0 @rank=:king, @suit=:hearts>, #<Card:0x007ff90a242678 @rank=:ace, @suit=:hearts>, #<Card:0x007ff90a242650 @rank=2, @suit=:spades>, #<Card:0x007ff90a242600 @rank=3, @suit=:spades>, #<Card:0x007ff90a2425b0 @rank=4, @suit=:spades>, #<Card:0x007ff90a242560 @rank=5, @suit=:spades>, #<Card:0x007ff90a242538 @rank=6, @suit=:spades>, #<Card:0x007ff90a2424e8 @rank=7, @suit=:spades>, #<Card:0x007ff90a242498 @rank=8, @suit=:spades>, #<Card:0x007ff90a242470 @rank=9, @suit=:spades>, #<Card:0x007ff90a242448 @rank=10, @suit=:spades>, #<Card:0x007ff90a242420 @rank=:jack, @suit=:spades>, #<Card:0x007ff90a2423f8 @rank=:queen, @suit=:spades>, #<Card:0x007ff90a2423d0 @rank=:king, @suit=:spades>, #<Card:0x007ff90a2423a8 @rank=:ace, @suit=:spades>]
actual collection contained: [#<Card:0x007ff90a1cc1a8 @rank=2, @suit=:spades>, #<Card:0x007ff90a1cc158 @rank=3, @suit=:spades>, #<Card:0x007ff90a1cc130 @rank=4, @suit=:spades>, #<Card:0x007ff90a1cc108 @rank=5, @suit=:spades>, #<Card:0x007ff90a1cc0e0 @rank=6, @suit=:spades>, #<Card:0x007ff90a1cc0b8 @rank=7, @suit=:spades>, #<Card:0x007ff90a1cc090 @rank=8, @suit=:spades>, #<Card:0x007ff90a1cc040 @rank=9, @suit=:spades>, #<Card:0x007ff90a1cc018 @rank=10, @suit=:spades>, #<Card:0x007ff90a1cde40 @rank=:jack, @suit=:spades>, #<Card:0x007ff90a243fa0 @rank=:queen, @suit=:spades>, #<Card:0x007ff90a243f78 @rank=:king, @suit=:spades>, #<Card:0x007ff90a243f50 @rank=:ace, @suit=:spades>, #<Card:0x007ff90a243f28 @rank=2, @suit=:heart>, #<Card:0x007ff90a243f00 @rank=3, @suit=:heart>, #<Card:0x007ff90a243ed8 @rank=4, @suit=:heart>, #<Card:0x007ff90a243eb0 @rank=5, @suit=:heart>, #<Card:0x007ff90a243e88 @rank=6, @suit=:heart>, #<Card:0x007ff90a243e60 @rank=7, @suit=:heart>, #<Card:0x007ff90a243e38 @rank=8, @suit=:heart>, #<Card:0x007ff90a243e10 @rank=9, @suit=:heart>, #<Card:0x007ff90a243de8 @rank=10, @suit=:heart>, #<Card:0x007ff90a243dc0 @rank=:jack, @suit=:heart>, #<Card:0x007ff90a243d98 @rank=:queen, @suit=:heart>, #<Card:0x007ff90a243d70 @rank=:king, @suit=:heart>, #<Card:0x007ff90a243d48 @rank=:ace, @suit=:heart>, #<Card:0x007ff90a243d20 @rank=2, @suit=:diamonds>, #<Card:0x007ff90a243cf8 @rank=3, @suit=:diamonds>, #<Card:0x007ff90a243cd0 @rank=4, @suit=:diamonds>, #<Card:0x007ff90a243ca8 @rank=5, @suit=:diamonds>, #<Card:0x007ff90a243c80 @rank=6, @suit=:diamonds>, #<Card:0x007ff90a243c58 @rank=7, @suit=:diamonds>, #<Card:0x007ff90a243c30 @rank=8, @suit=:diamonds>, #<Card:0x007ff90a243c08 @rank=9, @suit=:diamonds>, #<Card:0x007ff90a243be0 @rank=10, @suit=:diamonds>, #<Card:0x007ff90a243bb8 @rank=:jack, @suit=:diamonds>, #<Card:0x007ff90a243b90 @rank=:queen, @suit=:diamonds>, #<Card:0x007ff90a243b68 @rank=:king, @suit=:diamonds>, #<Card:0x007ff90a243b40 @rank=:ace, @suit=:diamonds>, #<Card:0x007ff90a243b18 @rank=2, @suit=:clubs>, #<Card:0x007ff90a243af0 @rank=3, @suit=:clubs>, #<Card:0x007ff90a243ac8 @rank=4, @suit=:clubs>, #<Card:0x007ff90a243aa0 @rank=5, @suit=:clubs>, #<Card:0x007ff90a243a78 @rank=6, @suit=:clubs>, #<Card:0x007ff90a243a50 @rank=7, @suit=:clubs>, #<Card:0x007ff90a2439d8 @rank=8, @suit=:clubs>, #<Card:0x007ff90a2439b0 @rank=9, @suit=:clubs>, #<Card:0x007ff90a243960 @rank=10, @suit=:clubs>, #<Card:0x007ff90a243910 @rank=:jack, @suit=:clubs>, #<Card:0x007ff90a243898 @rank=:queen, @suit=:clubs>, #<Card:0x007ff90a243870 @rank=:king, @suit=:clubs>, #<Card:0x007ff90a243848 @rank=:ace, @suit=:clubs>]
the missing elements were: [#<Card:0x007ff90a242858 @rank=2, @suit=:hearts>, #<Card:0x007ff90a242830 @rank=3, @suit=:hearts>, #<Card:0x007ff90a242808 @rank=4, @suit=:hearts>, #<Card:0x007ff90a2427e0 @rank=5, @suit=:hearts>, #<Card:0x007ff90a2427b8 @rank=6, @suit=:hearts>, #<Card:0x007ff90a242790 @rank=7, @suit=:hearts>, #<Card:0x007ff90a242768 @rank=8, @suit=:hearts>, #<Card:0x007ff90a242740 @rank=9, @suit=:hearts>, #<Card:0x007ff90a242718 @rank=10, @suit=:hearts>, #<Card:0x007ff90a2426f0 @rank=:jack, @suit=:hearts>, #<Card:0x007ff90a2426c8 @rank=:queen, @suit=:hearts>, #<Card:0x007ff90a2426a0 @rank=:king, @suit=:hearts>, #<Card:0x007ff90a242678 @rank=:ace, @suit=:hearts>]
the extra elements were: [#<Card:0x007ff90a243f28 @rank=2, @suit=:heart>, #<Card:0x007ff90a243f00 @rank=3, @suit=:heart>, #<Card:0x007ff90a243ed8 @rank=4, @suit=:heart>, #<Card:0x007ff90a243eb0 @rank=5, @suit=:heart>, #<Card:0x007ff90a243e88 @rank=6, @suit=:heart>, #<Card:0x007ff90a243e60 @rank=7, @suit=:heart>, #<Card:0x007ff90a243e38 @rank=8, @suit=:heart>, #<Card:0x007ff90a243e10 @rank=9, @suit=:heart>, #<Card:0x007ff90a243de8 @rank=10, @suit=:heart>, #<Card:0x007ff90a243dc0 @rank=:jack, @suit=:heart>, #<Card:0x007ff90a243d98 @rank=:queen, @suit=:heart>, #<Card:0x007ff90a243d70 @rank=:king, @suit=:heart>, #<Card:0x007ff90a243d48 @rank=:ace, @suit=:heart>]
Shared Example Group: "a deck" called from /tmp/d20151112-27349-mydqzs/spec.rb:140
# /tmp/d20151112-27349-mydqzs/spec.rb:18:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) WarDeck behaves like a deck #to_s returns the names of the cards, each on its own line
Failure/Error: expect(small_deck.to_s.strip).to eq "Ace of Spades\n9 of Clubs"
NoMethodError:
undefined method `strip' for #<Array:0x007ff90a296db8>
Shared Example Group: "a deck" called from /tmp/d20151112-27349-mydqzs/spec.rb:140
# /tmp/d20151112-27349-mydqzs/spec.rb:68:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
3) WarDeck #sort sorts the cards in the defined order
Failure/Error: expect(deck.sort.to_a).to eq [jack_of_spades, ten_of_hearts, ace_of_clubs, two_of_clubs]
ArgumentError:
comparison of Array with Array failed
# /tmp/d20151112-27349-mydqzs/solution.rb:105:in `sort_by'
# /tmp/d20151112-27349-mydqzs/solution.rb:105:in `sort_by!'
# /tmp/d20151112-27349-mydqzs/solution.rb:105:in `sort'
# /tmp/d20151112-27349-mydqzs/spec.rb:155:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
4) BeloteDeck behaves like a deck #to_s returns the names of the cards, each on its own line
Failure/Error: expect(small_deck.to_s.strip).to eq "Ace of Spades\n9 of Clubs"
NoMethodError:
undefined method `strip' for #<Array:0x007ff90a1ef018>
Shared Example Group: "a deck" called from /tmp/d20151112-27349-mydqzs/spec.rb:191
# /tmp/d20151112-27349-mydqzs/spec.rb:68:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
5) BeloteDeck hand #deal deals 8 cards
Failure/Error: expect(hand.size).to eq 8
NoMethodError:
undefined method `length' for nil:NilClass
# /tmp/d20151112-27349-mydqzs/solution.rb:48:in `size'
# /tmp/d20151112-27349-mydqzs/spec.rb:215:in `block (4 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
6) BeloteDeck hand #tierce? with tierce returns true for cards with names
Failure/Error: expect(hand.tierce?).to be true
expected #<TrueClass:20> => true
got #<FalseClass:0> => false
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.
# /tmp/d20151112-27349-mydqzs/spec.rb:284:in `block (5 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
7) BeloteDeck hand #tierce? with tierce returns true for cards with numbers
Failure/Error: expect(hand.tierce?).to be true
expected #<TrueClass:20> => true
got #<FalseClass:0> => false
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.
# /tmp/d20151112-27349-mydqzs/spec.rb:299:in `block (5 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
8) BeloteDeck hand #quarte? detects four cards with increasing ranks
Failure/Error: expect(hand.quarte?).to be true
expected #<TrueClass:20> => true
got #<FalseClass:0> => false
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.
# /tmp/d20151112-27349-mydqzs/spec.rb:334:in `block (4 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
9) BeloteDeck hand #quint? detects five cards with increasing ranks
Failure/Error: expect(hand.quint?).to be true
expected #<TrueClass:20> => true
got #<FalseClass:0> => false
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.
# /tmp/d20151112-27349-mydqzs/spec.rb:366:in `block (4 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
10) SixtySixDeck behaves like a deck #to_s returns the names of the cards, each on its own line
Failure/Error: expect(small_deck.to_s.strip).to eq "Ace of Spades\n9 of Clubs"
NoMethodError:
undefined method `strip' for #<Array:0x007ff909fbf090>
Shared Example Group: "a deck" called from /tmp/d20151112-27349-mydqzs/spec.rb:400
# /tmp/d20151112-27349-mydqzs/spec.rb:68:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.04101 seconds
57 examples, 10 failures
Failed examples:
rspec /tmp/d20151112-27349-mydqzs/spec.rb:14 # WarDeck behaves like a deck fills the deck if no initialize parameters are given
rspec /tmp/d20151112-27349-mydqzs/spec.rb:67 # WarDeck behaves like a deck #to_s returns the names of the cards, each on its own line
rspec /tmp/d20151112-27349-mydqzs/spec.rb:145 # WarDeck #sort sorts the cards in the defined order
rspec /tmp/d20151112-27349-mydqzs/spec.rb:67 # BeloteDeck behaves like a deck #to_s returns the names of the cards, each on its own line
rspec /tmp/d20151112-27349-mydqzs/spec.rb:212 # BeloteDeck hand #deal deals 8 cards
rspec /tmp/d20151112-27349-mydqzs/spec.rb:272 # BeloteDeck hand #tierce? with tierce returns true for cards with names
rspec /tmp/d20151112-27349-mydqzs/spec.rb:287 # BeloteDeck hand #tierce? with tierce returns true for cards with numbers
rspec /tmp/d20151112-27349-mydqzs/spec.rb:322 # BeloteDeck hand #quarte? detects four cards with increasing ranks
rspec /tmp/d20151112-27349-mydqzs/spec.rb:354 # BeloteDeck hand #quint? detects five cards with increasing ranks
rspec /tmp/d20151112-27349-mydqzs/spec.rb:67 # SixtySixDeck behaves like a deck #to_s returns the names of the cards, each on its own line
История (2 версии и 1 коментар)
Александрина обнови решението на 11.11.2015 15:41 (преди около 9 години)
Александрина обнови решението на 11.11.2015 16:39 (преди около 9 години)