I have a new Rails 4 project with FactoryGirl and rSpec. In my spec_helper.rb
I have:
# lots of stuff
RSpec.configure do |config|
# more stuff
config.include FactoryGirl::Syntax::Methods
end
I also removed the rspec/autorun
require in this file.
A simple spec:
require 'spec_helper'
describe User do
build(:user)
end
with a simple factory:
FactoryGirl.define do
factory :user do
email "[email protected]"
end
end
Fails with the following message.
`block in <top (required)>': undefined method `build' for #<Class:0x007fd46d0e3848> (NoMethodError)
However, if I explicitly qualify build
in the spec like this it passes:
require 'spec_helper'
describe User do
FactoryGirl.build(:user)
end
What can I do so I don't have to add FactoryGirl
every time?