-1
我正在使用FactoryGirl,但我剛剛嘗試要求factory_girl/step_definitions文件,並獲得如下所示的回溯。FactoryGirl step_definitions包含導致錯誤
如果我刪除了factory_girl/step_definitions的要求,該錯誤消失。
這個require是在我的features/support/env.rb中的spark prefork塊中完成的(雖然我目前沒有使用spork active來運行這些測試)。
使用Ruby 1.9.2。
任何人都見過這個錯誤?有什麼想法嗎?
我的寶石相關一部分
capybara (1.1.2)
ci_reporter (1.7.0)
factory_girl_rails (3.2.0, 3.0.0)
rails (3.1.0)
rspec (2.9.0)
rspec-core (2.9.0)
rspec-expectations (2.9.1)
rspec-mocks (2.9.0)
rspec-rails (2.9.0)
cucumber-rails (1.3.0)
功能/支持/ env.rb細節:
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
require 'cucumber/rails'
require 'factory_girl'
require 'factory_girl/step_definitions'
Capybara.default_selector = :xpath
ActionController::Base.allow_rescue = false
begin
DatabaseCleaner.strategy = :truncation
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
Cucumber::Rails::Database.javascript_strategy = :truncation
end
Spork.each_run do
# This code will be run each time you run your specs.
FactoryGirl.reload
end
回溯細節:
Testing started at 11:07 AM ...
Using the default and skip_broken profiles...
uninitialized constant TestItemSetting (NameError)
/Users/wwilliam/.rvm/gems/[email protected]/gems/activesupport-3.1.0/lib/active_support/inflector/methods.rb:124:in `block in constantize'
/Users/wwilliam/.rvm/gems/[email protected]/gems/activesupport-3.1.0/lib/active_support/inflector/methods.rb:123:in `each'
/Users/wwilliam/.rvm/gems/[email protected]/gems/activesupport-3.1.0/lib/active_support/inflector/methods.rb:123:in `constantize'
/Users/wwilliam/.rvm/gems/[email protected]/gems/activesupport-3.1.0/lib/active_support/core_ext/string/inflections.rb:43:in `constantize'
/Users/wwilliam/.rvm/gems/[email protected]/gems/factory_girl-3.2.0/lib/factory_girl/factory.rb:25:in `build_class'
/Users/wwilliam/.rvm/gems/[email protected]/gems/factory_girl-3.2.0/lib/factory_girl/step_definitions.rb:100:in `block (2 levels) in <top (required)>'
/Users/wwilliam/.rvm/gems/[email protected]/gems/factory_girl-3.2.0/lib/factory_girl/step_definitions.rb:99:in `each'
/Users/wwilliam/.rvm/gems/[email protected]/gems/factory_girl-3.2.0/lib/factory_girl/step_definitions.rb:99:in `block in <top (required)>'
/Users/wwilliam/.rvm/gems/[email protected]/gems/factory_girl-3.2.0/lib/factory_girl/registry.rb:17:in `each'
/Users/wwilliam/.rvm/gems/[email protected]/gems/factory_girl-3.2.0/lib/factory_girl/registry.rb:17:in `each'
/Users/wwilliam/.rvm/gems/[email protected]/gems/factory_girl-3.2.0/lib/factory_girl/disallows_duplicates_registry.rb:7:in `each'
/Users/wwilliam/.rvm/gems/[email protected]/gems/factory_girl-3.2.0/lib/factory_girl/step_definitions.rb:97:in `<top (required)>'
/Users/wwilliam/Development/projectset/projectset/features/support/env.rb:20:in `block in <top (required)>'
/Users/wwilliam/.rvm/gems/[email protected]/gems/spork-1.0.0rc3/lib/spork.rb:24:in `prefork'
/Users/wwilliam/Development/projectset/projectset/features/support/env.rb:6:in `<top (required)>'
/Users/wwilliam/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load'
/Users/wwilliam/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load_code_file'
/Users/wwilliam/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:171:in `load_file'
/Users/wwilliam/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/Users/wwilliam/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `each'
/Users/wwilliam/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/Users/wwilliam/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:175:in `load_step_definitions'
/Users/wwilliam/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:40:in `run!'
/Users/wwilliam/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:43:in `execute!'
/Users/wwilliam/.rvm/gems/[email protected]/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:20:in `execute'
/Users/wwilliam/.rvm/gems/[email protected]/gems/cucumber-1.1.9/bin/cucumber:14:in `<top (required)>'
/Users/wwilliam/Development/projectset/projectset/script/cucumber:9:in `load'
/Users/wwilliam/Development/projectset/projectset/script/cucumber:9:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
也許有一些代碼或未初始化的常量TestItemSetting(NameError)' – DVG
@DVG或周圍我沒有在我的項目中的任何地方的代碼,也沒有搜索找到它。我相信它是FactoryGirl的一部分。 – wadesworld
Gotcha。你在本節發佈了什麼內容:'/Users/wwilliam/Development/projectset/projectset/features/support/env.rb:20:in'在'塊中'' /Users/wwilliam/Development /projectset/projectset/features/support/env.rb:6:in'''這似乎是您的唯一代碼正在執行 –
DVG