-1

我成功地使用了 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)

功能/支持/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/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>'
4

1 回答 1

0

正如评论中所讨论的,它之所以抱怨是因为工厂 test_item 设置的运行时定义存在问题。很高兴你明白了:)

于 2012-06-06T19:27:50.600 回答