我跟随RSpec书,我无法通过黄瓜测试通过某个地点.我甚至试过在书中的源代码上运行黄瓜,它仍然无法通过.我不确定我是否正在使用更新版本的黄瓜,但必须有办法让它通过!
当我到达程序应该开始一个新游戏时,我被告知有一个未定义的方法'puts'.为什么它未定义,我应该如何捕捉puts黄瓜中的程序?在RSpec中运行测试以确保游戏使消息正常工作,不确定如何使其通过黄瓜.
(黄瓜版本1.3.17,Ruby版本2.1.2)
基本上,我有这些功能:
Feature: code-breaker starts game
As a code-breaker
I want to start a game
So that I can break the code
Scenario: start game
Given I am not yet playing
When I start a new game
Then I should see "Welcome to Codebreaker!"
And I should see "Enter guess:"
Run Code Online (Sandbox Code Playgroud)
和这些步骤定义:
class Output
def messages
@messages ||= []
end
def puts(message)
messages << message
end
end
def output
@output ||= Output.new
end
Given /^I …Run Code Online (Sandbox Code Playgroud)