Created
December 15, 2010 15:25
-
-
Save marcomoura/742078 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/game.rb | |
class Game | |
def initialize() | |
@royal_flush = %w(dez valete dama reis as) | |
@straight_flush = %w(quatro cinco seis sete oito) | |
end | |
def cards(*card) | |
@card = card | |
end | |
def jogadas_possiveis | |
if @card.sort == @straight_flush.sort | |
"straight flush" | |
elsif @card.sort == @royal_flush.sort | |
"royal flush" | |
else | |
"flush" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# features/support/env.rb | |
$:.unshift(File.dirname(__FILE__) + '/../../lib') | |
require 'game' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# language: pt | |
# features/poker.feature | |
Funcionalidade: Detectar jogada de Poker | |
Para jogar poker | |
E com um baralho com um naipe apenas | |
Como um jogador | |
Eu quero ver as possíveis combinações | |
Cenario: Royal flush | |
Dado que estou jogando | |
Quando eu tenho as cartas "dez", "valete", "dama", "reis" e "as" | |
Entao eu tenho um "royal flush" | |
Cenario: Straight flush | |
Dado que estou jogando | |
Quando eu tenho as cartas "quatro", "cinco", "seis", "sete" e "oito" | |
Entao eu tenho um "straight flush" | |
Cenario: flush | |
Dado que estou jogando | |
Quando eu tenho as cartas "as", "dama", "seis", "valete" e "dois" | |
Entao eu tenho um "flush" | |
Cenario: Royal flush fora de ordem | |
Dado que estou jogando | |
Quando eu tenho as cartas "valete", "dama", "dez", "reis" e "as" | |
Entao eu tenho um "royal flush" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: uft-8 | |
# step_definitions/poker_steps.rb | |
Dado /^que estou jogando$/ do | |
@game = Game.new | |
end | |
Quando /^eu tenho as cartas "([^\"]*)", "([^\"]*)", "([^\"]*)", "([^\"]*)" e "([^\"]*)"$/ do |arg1, arg2, arg3, arg4, arg5| | |
@game.cards(arg1, arg2, arg3, arg4, arg5) | |
end | |
Entao /^eu tenho um "([^\"]*)"$/ do |arg1| | |
@game.jogadas_possiveis.should == arg1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment