【问题标题】:Trying to learn rspec and TDD尝试学习 rspec 和 TDD
【发布时间】:2015-04-25 18:07:12
【问题描述】:

我遇到语法错误的问题,但我不明白为什么。我正在做“The Rspec book”的例子,但我已经到了无法继续的地步。当我在控制台 rspec spec/codebreaker/game_spec.rb --format doc 中写入时,我得到的只是这条消息:语法错误,意外的关键字_end,期望输入结束(SyntaxError)我已经修复了这个错误数千次,但是无论我现在做什么,我都无法弄清楚发生了什么。

这是spec/codebreaker/game_spec.rb的代码

require 'spec_helper'

  module Codebreaker
   describe Game do
     describe "#start" do
       it "sends a welcome message"
         output = double('output')
         game = Game.new(output)
         output.should_receive(:puts).with('Welcome to Codebreaker!')
         game.start
       end
       it "prompts for the first guess"
     end
   end
 end

我添加了另一个“结束”,我也删除了它,但它没有任何作用。可能是我错过了关于不推荐使用的语法或其他东西的东西。非常感谢。

【问题讨论】:

    标签: ruby rspec


    【解决方案1】:

    你应该在它之后添加一个do: it "sends a welcome message" do

    【讨论】:

      【解决方案2】:

      您的第二个it 缺少end

      it "prompts for the first guess"
      end
      

      您还必须以 do 开头。

      it "prompts for the first guess" do
      end
      

      【讨论】:

      • 谢谢。我根本没看到。很抱歉这个问题。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-14
      • 2011-05-10
      • 1970-01-01
      • 2010-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多