← Back to Upcase

Rspec confusion


(Charlieanna ) #1

First my FactoryGirl methods arent working.

Second what does these commands actually do?

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

(Tom Ridge) #2

@charlieanna1 this should help https://relishapp.com/rspec/rspec-core/docs/helper-methods/define-helper-methods-in-a-module

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?


(Charlieanna ) #3

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)


(Thiago Gabriel B. da Silva) #4

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