BlackJack Assignment submission.#40
BlackJack Assignment submission.#40codeblahblah wants to merge 5 commits intoRubyoffRails:masterfrom
Conversation
|
Initial code looks fine, no issues there.
I think it should return data; if you want to have a method, or a class, that formats it nicely, I think that's a good addition to the project. |
|
@jwo Okay. Will add that to the wishlist. |
|
Try on the player-hand.. if it's over 21 and hits, that's an exception and it shouldn't grab a card. |
|
@jwo I did this: I only got this far for the test case as I do not understand how you to make method call on a mock object which will change the properties thereof. |
|
Use a real Game object, with a mock card object. At some point, the objects must be real. |
|
@jwo Understood. However, the Game object comes with a randomised Deck object which I cannot change/set to suit this specific scenario? |
|
although that's the idea, set the game's deck to something where you have the cards predetermined. On Tue, Feb 25, 2014 at 10:16 AM, drammopo [email protected]
|
|
@jwo There's no setter method - only |
|
With the following class: class Deck
attr_reader :cards
def initialize
@cards = 1..52 #build cards
end
endYou could do: describe Deck do
it "has cards" do
the_cards = [double, double]
deck = Deck.new
deck.stub(:cards) { the_cards}
expect(deck.cards).to eq(the_cards)
end
endSo, you're stubbing the This only works if you are diligent in only using |
|
(then you would pass in your Deck to Game, and you know what happens) |
@jwo After changing the Card's to_s to show "QH" instead of queen-hearts"....
Should we change the Game#status to make
@player_hand.cardsand@delaer_hand.cardsmore readable?