Error not detected by cucumber test

0

I'm using the version of gem aruba 0.13.0 and cucumber 2.x.x

I would like to know how to detect the following error using a step definition of aruba. More specifically if the exit status was successful and if it is possible by the type of error that is occurring in the execution of the application:

#!/usr/bin/env ruby

$:.unshift File.join(File.dirname(__FILE__), "..","lib")

require 'game'

game = Game.new
game.start

while not game.ended?
    game.next_step
end

The error occurs at the time of executing the above class by the command line.

bin/forca:10:in <main>': undefined method ended? ' for # < 'Game: 0x000000012fc7d0 @output = # <' IO: < 'STDOUT > > > (NoMethodError) Basically what it is telling me is that the method ended is not set, and really is not, but cucumber does not detect the error.

The functionality is as follows by cucumber:

Funcionalidade: Começar jogo
    Para poder passar o tempo
    Como jogador
    Quero poder começar um novo jogo

    Cenário: Começo de novo jogo um sucesso
        Ao começar o jogo, é mostrada a mensagem inicial para o jogador.

        Quando começo um novo jogo
        E termino o jogo
        Então o jogo termina com a seguinte mensagem na tela:
         """
         Bem vindo ao jogo da forca!
         """

I use the following step to predict the error:

Então /^o jogo termina com a seguinte mensagem na tela:$/ do |text|
    steps %{
        Then it should pass with:
        """
        #{text}
        """ 
}
end 

Thanks for the feedback and I edited for better understanding.

    
asked by anonymous 03.02.2016 / 15:47

1 answer

0

The answer to the question is how the steps were defined, a wrong syntax was used for the steps defined in the aruba gem itself

Então /^o jogo termina com a seguinte mensagem na tela:$/ do |text|
    steps %{
        Then it should pass with:
        """
        #{text}
        """ 
}
end
is wrong when it would look better or in the case the correct one:
Então /^o jogo termina com a seguinte mensagem na tela:$/ do |text|
        step %(the stdout should contain "#{text}")
}
end
much more concise and according to what the gem caters.

Well, thank you to those who answered my questions.

    
23.04.2016 / 21:10