I went through what seems like all the right steps, and I keep getting this error. From the gemfile:
group :test do gem 'rspec-rails' gem 'shoulda-matchers', require: false gem 'database_cleaner' gem 'factory_girl_rails', '~> 4.0', require: false gem 'faker' end
spec_helper.rb:
require 'factory_girl_rails' RSpec.configure do |config| config.include FactoryGirl::Syntax::Methods FactoryGirl.definition_file_paths = [File.expand_path('../factories', __FILE__)] FactoryGirl.find_definitions FactoryGirl.factories.clear end
specifications / factories / company.rb: require "spec_helper" requires "faker"
FactoryGirl.define do factory :company do name { Faker::Name.name } system_name { Faker::Company.name } domain { Faker::Internet.url } end end
company_spec.rb: require 'spec_helper'
describe 'Company' do it 'has a valid factory' do FactoryGirl.build(:company).should be_valid end end
Getting Error Error / Error:
Failure/Error: FactoryGirl.create(:company).should be_valid ArgumentError: Factory not registered: company
source share