Decided to not use FactoryBot in prod afterall

This commit is contained in:
Daniel Schädler 2019-05-19 17:02:16 +02:00
parent 3b1d6d292c
commit 56e9c94b6f
4 changed files with 5 additions and 18 deletions

View File

@ -40,12 +40,11 @@ gem 'interactor-rails'
gem 'active_model_serializers'
gem 'factory_bot_rails'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: %i[mri mingw x64_mingw]
gem 'coveralls', require: false
gem 'factory_bot_rails'
gem 'faker'
gem 'rspec-rails'
gem 'shoulda-matchers'

View File

@ -1,6 +1,4 @@
# frozen_string_literal: true
require 'factory_bot'
FactoryBot.definition_file_paths = %w(../../spec/factories)
class GroupStageService
def self.generate_group_stage(groups)
@ -10,11 +8,11 @@ class GroupStageService
raise 'Groups need to be equal size' unless (groups.flatten.length.to_f / groups.length.to_f % 1).zero?
groups = groups.map(&method(:get_group_object_from))
FactoryBot.create(:group_stage, groups: groups)
Stage.new level: -1, groups: groups
end
def self.get_group_object_from(team_array)
FactoryBot.create(:group, matches: generate_all_matches_between(team_array))
Group.new matches: generate_all_matches_between(team_array)
end
def self.generate_all_matches_between(teams)

View File

@ -3,7 +3,6 @@
FactoryBot.define do
factory :group do
transient do
matches { nil }
match_count { 4 }
end
@ -11,11 +10,7 @@ FactoryBot.define do
stage
after(:create) do |group, evaluator|
if evaluator.matches.nil?
create_list(:group_match, evaluator.match_count, group: group)
else
evaluator.matches
end
create_list(:group_match, evaluator.match_count, group: group)
end
end
end

View File

@ -6,15 +6,10 @@ FactoryBot.define do
factory :group_stage do
level { -1 }
transient do
groups { nil }
group_count { 4 }
end
after(:create) do |stage, evaluator|
stage.groups = if evaluator.groups.nil?
create_list(:group, evaluator.group_count)
else
evaluator.groups
end
stage.groups = create_list(:group, evaluator.group_count)
end
end