Rspec confusion

First my FactoryGirl methods arent working.

Second what does these commands actually do?

config.include FactoryGirl::Syntax::Methods
config.include Feature, type: :feature

@charlieanna1 this should help Define helper methods in a module - Helper methods - RSpec Core - RSpec - Relish

Essentially, they make helper methods available within Rspec for you to utilise. The first allows for shortcut FactoryGirl methods like create(:user) instead of FactoryGirl.create(:user) for example. The second enables the Feature module helper methods for only feature specs as indicated by the type.

Can you provide more info on how exactly your FactoryGirl methods arent working?

I have this in my rails_helper

RSpec.configure do |config|
  config.include FactoryGirl::Syntax::Methods
  config.include Feature, type: :feature
  config.use_transactional_fixtures = false
  config.infer_spec_type_from_file_location!
end

but still I have to use FactoryGirl.create(:user)

Can you check if you are requiring spec_helper or rails_helper on the file you are trying to use create(:user) ?

1 Like