Permalink
Browse files

implement highest for straight flush

  • Loading branch information...
camillebaldock committed Sep 8, 2014
1 parent 8206f58 commit 5f0e5c4d3b9a3d991ce2c723b07f4d520829ca2f
Showing with 27 additions and 2 deletions.
  1. +4 −2 lib/hand.rb
  2. +23 −0 spec/hand_spec.rb
View
@@ -32,7 +32,7 @@ def <=>(other_hand)
#TODO: refactor this once all test methods returns hashes
def rank
if straight_flush
{ :type => :straight_flush }
straight_flush
elsif has_four
has_four
elsif full_house
@@ -136,7 +136,9 @@ def straight
end
def straight_flush
straight && flush
if flush && straight
straight.merge(:type => :straight_flush)
end
end
def consecutive_cards?(card_values)
View
@@ -148,6 +148,29 @@
it "ranks the hand correctly" do
expect(hand.rank.fetch(:type)).to eq :straight_flush
end
it "sets the highest hand correctly" do
expect(hand.rank.fetch(:highest)).to eq 9
end
end
context "straight flush with low ace hand" do
let(:hand_string_array) { ["2h", "3h", "4h", "5h", "ah"] }
it "ranks the hand correctly" do
expect(hand.rank.fetch(:type)).to eq :straight_flush
end
it "sets the highest hand correctly" do
expect(hand.rank.fetch(:highest)).to eq 5
end
end
context "straight flush with high ace hand" do
let(:hand_string_array) { ["10h", "jh", "qh", "kh", "ah"] }
it "ranks the hand correctly" do
expect(hand.rank.fetch(:type)).to eq :straight_flush
end
it "sets the highest hand correctly" do
expect(hand.rank.fetch(:highest)).to eq 14
end
end
end
end

0 comments on commit 5f0e5c4

Please sign in to comment.