我正在使用 rspec 在 Rails4 中练习 TDD 的东西,并打算通过命令创建几个文件夹,例如factories
, model
, requests
, controller
。所以我将这样的行添加到config/application.rb
:
config.generators do |g|
g.test_framework :rspec,
:model_specs => true,
:view_specs => false,
:helper_specs => false,
:routing_specs => false,
:controller_specs => true,
:request_specs => true
g.fixture_replacement :factory_girl, :dir => "spec/factories"
end
然而。当我rails g rspec:install
在命令行中运行时。系统返回错误:
/home/rayvonmice/workspace/kulu/config/application.rb:14:in `<top (required)>': undefined local variable or method `config' for main:Object (NameError)
from /home/rayvonmice/.rvm/gems/ruby-2.0.0-p247@global/gems/railties-4.0.0/lib/rails/commands.rb:44:in `require'
from /home/rayvonmice/.rvm/gems/ruby-2.0.0-p247@global/gems/railties-4.0.0/lib/rails/commands.rb:44:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
所以我不太明白config/application.rb
文件有什么问题。这是否意味着我只能手动生成这些文件夹?