我將在我的Rails3項目中使用RSpec和Factory factory。我已經安裝了工廠的女孩,但沒有找到廠區,我有這個錯誤RSpec無法從Factorygirl中找到Factorys
Failure/Error: Factory.build(:user).should_be valid
No such factory: user
規格/工廠/ user_factory.rb:
Factory.define :user do |u|
u.username 'otto'
end
規格/ spec_helper.rb
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'factory_girl'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rspec
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
end
Gemfile:
group :development, :test do
gem 'webrat'
gem "cucumber-rails"
gem "rspec-rails"
gem "rspec"
gem "autotest"
gem 'factory_girl'
end
感謝
問題出在factory_girl上。當我使用factory_girl_rails時,一切正常。 – ThreeFingerMark 2010-11-30 08:19:49