我正在成功使用FactoryGirl,但我刚刚尝试使用factory_girl / step_definitions文件,并且正在获得如下所示的回溯。
如果我删除了factory_girl / step_definitions的要求,则错误消失。
要求是在spark prefork块中的我的features / support / env.rb中完成的(虽然我目前没有运行spork活动的这些测试)。
使用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)
features / support / env.rb details:
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
Backtrace detail:
Testing started at 11:07 AM ...
Using the default and skip_broken profiles...
uninitialized constant TestItemSetting (NameError)
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/activesupport-3.1.0/lib/active_support/inflector/methods.rb:124:in `block in constantize'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/activesupport-3.1.0/lib/active_support/inflector/methods.rb:123:in `each'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/activesupport-3.1.0/lib/active_support/inflector/methods.rb:123:in `constantize'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/activesupport-3.1.0/lib/active_support/core_ext/string/inflections.rb:43:in `constantize'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/factory_girl-3.2.0/lib/factory_girl/factory.rb:25:in `build_class'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/factory_girl-3.2.0/lib/factory_girl/step_definitions.rb:100:in `block (2 levels) in <top (required)>'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/factory_girl-3.2.0/lib/factory_girl/step_definitions.rb:99:in `each'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/factory_girl-3.2.0/lib/factory_girl/step_definitions.rb:99:in `block in <top (required)>'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/factory_girl-3.2.0/lib/factory_girl/registry.rb:17:in `each'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/factory_girl-3.2.0/lib/factory_girl/registry.rb:17:in `each'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/factory_girl-3.2.0/lib/factory_girl/disallows_duplicates_registry.rb:7:in `each'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/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/ruby-1.9.2-head@projectset/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/ruby-1.9.2-head@projectset/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load_code_file'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:171:in `load_file'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `each'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:175:in `load_step_definitions'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:40:in `run!'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:43:in `execute!'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:20:in `execute'
/Users/wwilliam/.rvm/gems/ruby-1.9.2-head@projectset/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>'
答案 0 :(得分:0)
由于工厂test_item设置的运行时定义存在问题而引起抱怨,如评论中所述。很高兴你弄明白了:))