From 0c732208311ea7b8c897a9301401191af114eb5f Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Wed, 8 Sep 2021 16:27:01 +0100 Subject: [PATCH] Add factorybot --- Gemfile | 1 + Gemfile.lock | 6 ++++++ spec/spec_helper.rb | 8 +++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index c06fdf065..4066943b0 100644 --- a/Gemfile +++ b/Gemfile @@ -28,6 +28,7 @@ group :development, :test do gem "pry-byebug" gem "dotenv-rails" gem "selenium-webdriver" + gem "factory_bot_rails" %w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib| gem lib, git: "https://github.com/rspec/#{lib}.git", branch: "main" end diff --git a/Gemfile.lock b/Gemfile.lock index 0cf205e18..b6d1de185 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -134,6 +134,11 @@ GEM dotenv (= 2.7.6) railties (>= 3.2) erubi (1.10.0) + factory_bot (6.2.0) + activesupport (>= 5.0.0) + factory_bot_rails (6.2.0) + factory_bot (~> 6.2.0) + railties (>= 5.0.0) ffi (1.15.4) globalid (0.5.2) activesupport (>= 5.0) @@ -311,6 +316,7 @@ DEPENDENCIES byebug capybara dotenv-rails + factory_bot_rails govuk-components govuk_design_system_formbuilder jbuilder (~> 2.7) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 15a38725b..6cf19332c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,6 +13,9 @@ # it. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration + +require "factory_bot" + RSpec.configure do |config| # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest @@ -84,11 +87,14 @@ RSpec.configure do |config| # # order dependency and want to debug it, you can fix the order by providing # # the seed, which is printed after each run. # # --seed 1234 - # config.order = :random + config.order = :random # # # Seed global randomization in this process using the `--seed` CLI option. # # Setting this allows you to use `--seed` to deterministically reproduce # # test failures related to randomization by passing the same `--seed` value # # as the one that triggered the failure. # Kernel.srand config.seed + + + config.include FactoryBot::Syntax::Methods end