tôi sẽ sử dụng RSpec với Factory girl trong Dự án Rails3 của tôi. Tôi đã cài đặt nhà máy cô gái nhưng nó không tìm thấy factorys tôi có lỗi nàyRSpec không thể tìm thấy Nhà máy từ Factorygirl
Failure/Error: Factory.build(:user).should_be valid
No such factory: user
đặc tả/nhà máy/user_factory.rb:
Factory.define :user do |u|
u.username 'otto'
end
đặc tả/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
Cảm ơn
Vấn đề là với factory_girl. Khi tôi sử dụng factory_girl_rails tất cả mọi thứ làm việc tốt. – ThreeFingerMark