Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add require 'factory_bot_rails' in GETTING-STARTED instructions #1632

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

salmanasiddiqui
Copy link

@salmanasiddiqui salmanasiddiqui commented Mar 31, 2024

Following readme results in the code below

rails_helper.rb:

# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
# Prevent database truncation if the environment is production
abort('The Rails environment is running in production mode!') if Rails.env.production?
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!
require 'support/factory_bot'

...

support/factory_bot.rb:

RSpec.configure do |config|
  config.include FactoryBot::Syntax::Methods
end

This results in an error:

uninitialized constant `FactoryBot`

because factory_bot gem has not bene loaded yet. So I required it in factory_bot.rb to fix the issue.

support/factory_bot.rb:

require 'factory_bot_rails'

RSpec.configure do |config|
  config.include FactoryBot::Syntax::Methods
end

This PR updates the instructions in Getting-Started accordingly

@salmanasiddiqui salmanasiddiqui changed the title Add require 'factory_bot' in README instructions Add require 'factory_bot' in Getting-Started instructions Mar 31, 2024
@salmanasiddiqui salmanasiddiqui changed the title Add require 'factory_bot' in Getting-Started instructions Add require 'factory_bot_rails' in GETTING-STARTED instructions Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants