mirror of
https://github.com/Evolix/chexpire.git
synced 2024-05-13 05:58:38 +02:00
Setup factory_bot
This commit is contained in:
parent
dc2c1b88d0
commit
611c8b78b8
5
Gemfile
5
Gemfile
|
@ -47,6 +47,8 @@ group :development, :test do
|
||||||
gem 'binding_of_caller'
|
gem 'binding_of_caller'
|
||||||
gem 'pry-byebug'
|
gem 'pry-byebug'
|
||||||
gem 'pry-rails'
|
gem 'pry-rails'
|
||||||
|
|
||||||
|
gem "factory_bot_rails"
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
|
@ -61,7 +63,6 @@ group :development do
|
||||||
gem 'annotate', require: false
|
gem 'annotate', require: false
|
||||||
gem 'letter_opener_web'
|
gem 'letter_opener_web'
|
||||||
|
|
||||||
|
|
||||||
gem "guard"
|
gem "guard"
|
||||||
gem "guard-minitest"
|
gem "guard-minitest"
|
||||||
|
|
||||||
|
@ -78,6 +79,8 @@ group :test do
|
||||||
# Easy installation and use of chromedriver to run system tests with Chrome
|
# Easy installation and use of chromedriver to run system tests with Chrome
|
||||||
gem 'chromedriver-helper'
|
gem 'chromedriver-helper'
|
||||||
gem 'launchy'
|
gem 'launchy'
|
||||||
|
|
||||||
|
gem "database_cleaner"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||||
|
|
|
@ -94,6 +94,7 @@ GEM
|
||||||
coderay (1.1.2)
|
coderay (1.1.2)
|
||||||
concurrent-ruby (1.0.5)
|
concurrent-ruby (1.0.5)
|
||||||
crass (1.0.4)
|
crass (1.0.4)
|
||||||
|
database_cleaner (1.7.0)
|
||||||
debug_inspector (0.0.3)
|
debug_inspector (0.0.3)
|
||||||
devise (4.4.3)
|
devise (4.4.3)
|
||||||
bcrypt (~> 3.0)
|
bcrypt (~> 3.0)
|
||||||
|
@ -105,6 +106,11 @@ GEM
|
||||||
devise (>= 4.4)
|
devise (>= 4.4)
|
||||||
erubi (1.7.1)
|
erubi (1.7.1)
|
||||||
execjs (2.7.0)
|
execjs (2.7.0)
|
||||||
|
factory_bot (4.10.0)
|
||||||
|
activesupport (>= 3.0.0)
|
||||||
|
factory_bot_rails (4.10.0)
|
||||||
|
factory_bot (~> 4.10.0)
|
||||||
|
railties (>= 3.0.0)
|
||||||
ffi (1.9.23)
|
ffi (1.9.23)
|
||||||
formatador (0.2.5)
|
formatador (0.2.5)
|
||||||
globalid (0.4.1)
|
globalid (0.4.1)
|
||||||
|
@ -310,8 +316,10 @@ DEPENDENCIES
|
||||||
capistrano3-puma
|
capistrano3-puma
|
||||||
capybara (>= 2.15, < 4.0)
|
capybara (>= 2.15, < 4.0)
|
||||||
chromedriver-helper
|
chromedriver-helper
|
||||||
|
database_cleaner
|
||||||
devise (~> 4.4)
|
devise (~> 4.4)
|
||||||
devise-i18n (~> 1.6)
|
devise-i18n (~> 1.6)
|
||||||
|
factory_bot_rails
|
||||||
guard
|
guard
|
||||||
guard-minitest
|
guard-minitest
|
||||||
jbuilder (~> 2.5)
|
jbuilder (~> 2.5)
|
||||||
|
|
|
@ -26,4 +26,5 @@ guard "minitest", spring: "bin/rails test" do
|
||||||
watch(%r{^test/.+_test\.rb$})
|
watch(%r{^test/.+_test\.rb$})
|
||||||
watch(%r{^test/test_helper\.rb$}) { "test" }
|
watch(%r{^test/test_helper\.rb$}) { "test" }
|
||||||
watch(%r{^test/fixtures/.+\.yml$}) { "test" }
|
watch(%r{^test/fixtures/.+\.yml$}) { "test" }
|
||||||
|
watch(%r{^test/factories/.+\.rb$}) { "test" }
|
||||||
end
|
end
|
||||||
|
|
13
lib/tasks/factory_bot.rake
Normal file
13
lib/tasks/factory_bot.rake
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
namespace :factory_bot do
|
||||||
|
desc "Verify that all FactoryBot factories are valid"
|
||||||
|
task lint: :environment do
|
||||||
|
if Rails.env.test?
|
||||||
|
DatabaseCleaner.cleaning do
|
||||||
|
FactoryBot.lint
|
||||||
|
end
|
||||||
|
else
|
||||||
|
system("bundle exec rake factory_bot:lint RAILS_ENV='test'")
|
||||||
|
fail if $CHILD_STATUS.exitstatus.nonzero?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
4
test/factories/.rubocop.yml
Normal file
4
test/factories/.rubocop.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
inherit_from: ../../.rubocop.yml
|
||||||
|
|
||||||
|
Style/BlockDelimiters:
|
||||||
|
EnforcedStyle: line_count_based
|
|
@ -12,6 +12,7 @@ class ActiveSupport::TestCase
|
||||||
Warden.test_mode!
|
Warden.test_mode!
|
||||||
|
|
||||||
# Add more helper methods to be used by all tests here...
|
# Add more helper methods to be used by all tests here...
|
||||||
|
include FactoryBot::Syntax::Methods
|
||||||
end
|
end
|
||||||
|
|
||||||
Capybara.register_driver :headless_chrome do |app|
|
Capybara.register_driver :headless_chrome do |app|
|
||||||
|
|
Loading…
Reference in a new issue