Решение на Четвърта задача от Даяна Маринова
Обратно към всички решения
Към профила на Даяна Маринова
Резултати
- 4 точки от тестове
- 1 отнета точка
- 3 точки общо
- 37 успешни тест(а)
- 20 неуспешни тест(а)
Код
Лог от изпълнението
.......FFF."Ace of Spades"
"9 of Clubs"
F........F..."9 of Clubs"
"Ace of Spades"
F..FF.FF.F.F.F.F.F.F..FF..."9 of Clubs"
"Ace of Spades"
F....F
Failures:
1) WarDeck behaves like a deck #draw_bottom_card pops the bottom-most card
Failure/Error: expect(small_deck.draw_bottom_card).to eq nine_of_clubs
expected: #<Card:0x007fab9e5e8598 @rank=9, @suit=:clubs>
got: #<Card:0x007fab9e5e85c0 @rank=:ace, @suit=:spades>
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-#<Card:0x007fab9e5e8598 @rank=9, @suit=:clubs>
+#<Card:0x007fab9e5e85c0 @rank=:ace, @suit=:spades>
Shared Example Group: "a deck" called from /tmp/d20151112-27349-1ixor1r/spec.rb:140
# /tmp/d20151112-27349-1ixor1r/spec.rb:36: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)>'
2) WarDeck behaves like a deck #top peeks at the top-most card
Failure/Error: expect(small_deck.top_card).to eq ace_of_spades
expected: #<Card:0x007fab9e523950 @rank=:ace, @suit=:spades>
got: #<Card:0x007fab9e523900 @rank=9, @suit=:clubs>
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-#<Card:0x007fab9e523950 @rank=:ace, @suit=:spades>
+#<Card:0x007fab9e523900 @rank=9, @suit=:clubs>
Shared Example Group: "a deck" called from /tmp/d20151112-27349-1ixor1r/spec.rb:140
# /tmp/d20151112-27349-1ixor1r/spec.rb:43: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 behaves like a deck #bottom peeks at the bottom-most card
Failure/Error: expect(small_deck.bottom_card).to eq nine_of_clubs
expected: #<Card:0x007fab9e4b85b0 @rank=9, @suit=:clubs>
got: #<Card:0x007fab9e4b85d8 @rank=:ace, @suit=:spades>
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-#<Card:0x007fab9e4b85b0 @rank=9, @suit=:clubs>
+#<Card:0x007fab9e4b85d8 @rank=:ace, @suit=:spades>
Shared Example Group: "a deck" called from /tmp/d20151112-27349-1ixor1r/spec.rb:140
# /tmp/d20151112-27349-1ixor1r/spec.rb:50: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) 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:0x007fab9e5d0f10>
Shared Example Group: "a deck" called from /tmp/d20151112-27349-1ixor1r/spec.rb:140
# /tmp/d20151112-27349-1ixor1r/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 behaves like a deck #draw_bottom_card pops the bottom-most card
Failure/Error: expect(small_deck.draw_bottom_card).to eq nine_of_clubs
expected: #<Card:0x007fab9e54a370 @rank=9, @suit=:clubs>
got: #<Card:0x007fab9e54a398 @rank=:ace, @suit=:spades>
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-#<Card:0x007fab9e54a370 @rank=9, @suit=:clubs>
+#<Card:0x007fab9e54a398 @rank=:ace, @suit=:spades>
Shared Example Group: "a deck" called from /tmp/d20151112-27349-1ixor1r/spec.rb:191
# /tmp/d20151112-27349-1ixor1r/spec.rb:36: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)>'
6) 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:0x007fab9e4d39c8>
Shared Example Group: "a deck" called from /tmp/d20151112-27349-1ixor1r/spec.rb:191
# /tmp/d20151112-27349-1ixor1r/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)>'
7) BeloteDeck hand #highest_of_suit returns the strongest card of the specified suit
Failure/Error: expect(hand.highest_of_suit(:spades)).to eq Card.new(:king, :spades)
expected: #<Card:0x007fab9e488720 @rank=:king, @suit=:spades>
got: nil
(compared using ==)
# /tmp/d20151112-27349-1ixor1r/spec.rb:233: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)>'
8) BeloteDeck hand #belote? returns true if there is a king and a queen of the same suit
Failure/Error: expect(hand.belote?).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-1ixor1r/spec.rb:251: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 #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-1ixor1r/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)>'
10) 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-1ixor1r/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)>'
11) 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-1ixor1r/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)>'
12) 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-1ixor1r/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)>'
13) BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns true when there is a carre
Failure/Error: expect(hand.public_send(method)).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.
Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1ixor1r/spec.rb:386
# /tmp/d20151112-27349-1ixor1r/spec.rb:86: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)>'
14) BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns true when there is a carre
Failure/Error: expect(hand.public_send(method)).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.
Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1ixor1r/spec.rb:390
# /tmp/d20151112-27349-1ixor1r/spec.rb:86: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)>'
15) BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns true when there is a carre
Failure/Error: expect(hand.public_send(method)).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.
Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1ixor1r/spec.rb:394
# /tmp/d20151112-27349-1ixor1r/spec.rb:86: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)>'
16) SixtySixDeck behaves like a deck implements Enumerable
Failure/Error: expect(small_deck.to_a).to eq [ace_of_spades, nine_of_clubs]
expected: [#<Card:0x007fab9df85660 @rank=:ace, @suit=:spades>, #<Card:0x007fab9df85638 @rank=9, @suit=:clubs>]
got: [#<Card:0x007fab9df85638 @rank=9, @suit=:clubs>, #<Card:0x007fab9df85660 @rank=:ace, @suit=:spades>]
(compared using ==)
Diff:
@@ -1,3 +1,3 @@
-[#<Card:0x007fab9df85660 @rank=:ace, @suit=:spades>,
- #<Card:0x007fab9df85638 @rank=9, @suit=:clubs>]
+[#<Card:0x007fab9df85638 @rank=9, @suit=:clubs>,
+ #<Card:0x007fab9df85660 @rank=:ace, @suit=:spades>]
Shared Example Group: "a deck" called from /tmp/d20151112-27349-1ixor1r/spec.rb:400
# /tmp/d20151112-27349-1ixor1r/spec.rb:11: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)>'
17) SixtySixDeck behaves like a deck #draw_top_card pops the top-most card
Failure/Error: expect(small_deck.draw_top_card).to eq ace_of_spades
expected: #<Card:0x007fab9decc2c8 @rank=:ace, @suit=:spades>
got: #<Card:0x007fab9decc2a0 @rank=9, @suit=:clubs>
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-#<Card:0x007fab9decc2c8 @rank=:ace, @suit=:spades>
+#<Card:0x007fab9decc2a0 @rank=9, @suit=:clubs>
Shared Example Group: "a deck" called from /tmp/d20151112-27349-1ixor1r/spec.rb:400
# /tmp/d20151112-27349-1ixor1r/spec.rb:29: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)>'
18) SixtySixDeck behaves like a deck #draw_bottom_card pops the bottom-most card
Failure/Error: expect(small_deck.draw_bottom_card).to eq nine_of_clubs
expected: #<Card:0x007fab9dab5ec8 @rank=9, @suit=:clubs>
got: #<Card:0x007fab9dab6058 @rank=:ace, @suit=:spades>
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-#<Card:0x007fab9dab5ec8 @rank=9, @suit=:clubs>
+#<Card:0x007fab9dab6058 @rank=:ace, @suit=:spades>
Shared Example Group: "a deck" called from /tmp/d20151112-27349-1ixor1r/spec.rb:400
# /tmp/d20151112-27349-1ixor1r/spec.rb:36: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)>'
19) 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:0x007fab9d747278>
Shared Example Group: "a deck" called from /tmp/d20151112-27349-1ixor1r/spec.rb:400
# /tmp/d20151112-27349-1ixor1r/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)>'
20) SixtySixDeck hand #twenty? returns false for hands without a king and queen of the same suit
Failure/Error: expect(hand.twenty?(:hearts)).to be false
expected #<FalseClass:0> => false
got #<TrueClass:20> => true
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-1ixor1r/spec.rb:465: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)>'
Finished in 0.04996 seconds
57 examples, 20 failures
Failed examples:
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:35 # WarDeck behaves like a deck #draw_bottom_card pops the bottom-most card
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:42 # WarDeck behaves like a deck #top peeks at the top-most card
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:49 # WarDeck behaves like a deck #bottom peeks at the bottom-most card
rspec /tmp/d20151112-27349-1ixor1r/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-1ixor1r/spec.rb:35 # BeloteDeck behaves like a deck #draw_bottom_card pops the bottom-most card
rspec /tmp/d20151112-27349-1ixor1r/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-1ixor1r/spec.rb:220 # BeloteDeck hand #highest_of_suit returns the strongest card of the specified suit
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:239 # BeloteDeck hand #belote? returns true if there is a king and a queen of the same suit
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:272 # BeloteDeck hand #tierce? with tierce returns true for cards with names
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:287 # BeloteDeck hand #tierce? with tierce returns true for cards with numbers
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:322 # BeloteDeck hand #quarte? detects four cards with increasing ranks
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:354 # BeloteDeck hand #quint? detects five cards with increasing ranks
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:74 # BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns true when there is a carre
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:74 # BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns true when there is a carre
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:74 # BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns true when there is a carre
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:8 # SixtySixDeck behaves like a deck implements Enumerable
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:28 # SixtySixDeck behaves like a deck #draw_top_card pops the top-most card
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:35 # SixtySixDeck behaves like a deck #draw_bottom_card pops the bottom-most card
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:67 # SixtySixDeck behaves like a deck #to_s returns the names of the cards, each on its own line
rspec /tmp/d20151112-27349-1ixor1r/spec.rb:455 # SixtySixDeck hand #twenty? returns false for hands without a king and queen of the same suit
История (3 версии и 1 коментар)
Даяна обнови решението на 11.11.2015 15:38 (преди около 9 години)
Даяна обнови решението на 11.11.2015 16:22 (преди около 9 години)
Даяна обнови решението на 11.11.2015 17:28 (преди около 9 години)