【发布时间】:2016-04-03 02:49:10
【问题描述】:
Pragmatic Programmers' RSpec Book 中的练习是编写一个名为 Codebreakers 的问题解决游戏。目的是在 Ruby 中使用 Cucumber 和 Rspec 接触 BDD。
以下是我的 codebreaker 目录树概览:
-features
-step_definitions
-codebreaker_steps
-support
-env.rb
-codebreaker_starts_game.feature
-codebreaker_submits_guess.feature
-lib
-codebreaker
-codebreaker.rb
-game.rb
-spec
-codebreaker
-game_spec
-spec_helper.rb
codebreaker 的 LoadError 消息:
rspec spec/codebreaker/game_spec.rb
/Documents/rubyProjects/codebreaker/spec/spec_helper.rb:1:in `require': cannot load such file -- codebreaker (LoadError)
from /Documents/rubyProjects/codebreaker/spec/spec_helper.rb:1:in `<top (required)>'
from /Documents/rubyProjects/codebreaker/spec/codebreaker/game_spec.rb:1:in `require'
from /Documents/rubyProjects/codebreaker/spec/codebreaker/game_spec.rb:1:in `<top (required)>'
spec/codebreaker/game_spec.rb 需要“spec_helper”:
require 'spec_helper'
module Codebreaker
describe Game do
describe "#start" do
it "sends a welcome message"
it "prompts for the first guess"
end
end
end
spec/spec_helper.rb 需要'codebreaker',它没有按照错误加载:
require 'codebreaker'
而 lib/codebreaker/codebreaker.rb 需要 codebreaker/game
require 'codebreaker/game'
lib/codebreaker/game.rb:
module Codebreaker
class Game
def initialize(output)
end
def start
end
end
end
感谢您的建议和见解!
谢谢。
【问题讨论】: