Error not detected by Cucumber test

Asked

Viewed 489 times

0

I am using the version of Gem Aruba 0.13.0 and Cucumber 2.x. x

would like to know how to detect the following error using a Ruba step Definition. More specifically if Exit status was successful and 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 when executing the above class by the command line.

bin/forca:10:in <main>': undefined methodended?' for #<'Game:0x000000012fc7d0 @output=#<'IO:<'STDOUT>>> (NoMethodError) Basically what he’s telling me is that the ended method isn’t defined, and it really isn’t, but Cucumber doesn’t 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!
         """

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 edited for better understanding.

  • Put your Feature and your ruby screen, probably when Voce is calling your method it is not being referenced.

  • Oops, sorry for the delay! From what I saw he can’t find his . ended? method in the Game class, could post the class?

1 answer

0

The answer to the question is in the way Steps were defined, a wrong syntax was used for Steps defined in Gem Aruba 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 be better or the right case:
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 Gem meets.

Well, thank you to those who answered my questions.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.