From 70e4ef68cec1cb972c787006eab7161c12b68047 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Wed, 17 Feb 2021 13:15:39 +0100 Subject: [PATCH 1/2] Change the way we load Alchemy factories Alchemy 5.2 changed the way we load FactoryBot factories. --- spec/models/alchemy/json_api/element_spec.rb | 1 - spec/models/alchemy/json_api/page_spec.rb | 1 - spec/rails_helper.rb | 11 +++++++++++ spec/requests/alchemy/json_api/layout_pages_spec.rb | 2 -- spec/requests/alchemy/json_api/pages_spec.rb | 2 -- .../alchemy/json_api/element_serializer_spec.rb | 1 - .../json_api/essence_boolean_serializer_spec.rb | 1 - .../alchemy/json_api/essence_date_serializer_spec.rb | 1 - .../alchemy/json_api/essence_file_serializer_spec.rb | 1 - .../alchemy/json_api/essence_html_serializer_spec.rb | 1 - .../alchemy/json_api/essence_link_serializer_spec.rb | 1 - .../alchemy/json_api/essence_node_serializer_spec.rb | 1 - .../alchemy/json_api/essence_page_serializer_spec.rb | 2 -- .../json_api/essence_picture_serializer_spec.rb | 2 -- .../json_api/essence_richtext_serializer_spec.rb | 1 - .../json_api/essence_select_serializer_spec.rb | 1 - .../alchemy/json_api/essence_text_serializer_spec.rb | 1 - .../alchemy/json_api/language_serializer_spec.rb | 3 --- .../alchemy/json_api/node_serializer_spec.rb | 1 - .../alchemy/json_api/page_serializer_spec.rb | 1 - 20 files changed, 11 insertions(+), 25 deletions(-) diff --git a/spec/models/alchemy/json_api/element_spec.rb b/spec/models/alchemy/json_api/element_spec.rb index 7345056..008491b 100644 --- a/spec/models/alchemy/json_api/element_spec.rb +++ b/spec/models/alchemy/json_api/element_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -require "alchemy/test_support/factories" RSpec.describe Alchemy::JsonApi::Element, type: :model do it { should belong_to(:page).class_name("Alchemy::JsonApi::Page") } diff --git a/spec/models/alchemy/json_api/page_spec.rb b/spec/models/alchemy/json_api/page_spec.rb index 0750eb1..980b4c0 100644 --- a/spec/models/alchemy/json_api/page_spec.rb +++ b/spec/models/alchemy/json_api/page_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -require "alchemy/test_support/factories" RSpec.describe Alchemy::JsonApi::Page, type: :model do it { should belong_to(:language).class_name("Alchemy::Language") } diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 71b5d52..0bfd1d1 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -18,6 +18,17 @@ end end +require "alchemy/version" +if Alchemy.gem_version >= Gem::Version.new("5.2.0") + require "factory_bot" + require "alchemy/test_support" + + FactoryBot.definition_file_paths.concat(Alchemy::TestSupport.factory_paths) + FactoryBot.reload +else + require "alchemy/test_support/factories" +end + # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are # run as spec files by default. This means that files in spec/support that end diff --git a/spec/requests/alchemy/json_api/layout_pages_spec.rb b/spec/requests/alchemy/json_api/layout_pages_spec.rb index 952a780..ec79dc6 100644 --- a/spec/requests/alchemy/json_api/layout_pages_spec.rb +++ b/spec/requests/alchemy/json_api/layout_pages_spec.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories/page_factory" -require "alchemy/test_support/factories/element_factory" require "alchemy/devise/test_support/factories" RSpec.describe "Alchemy::JsonApi::LayoutPagesController", type: :request do diff --git a/spec/requests/alchemy/json_api/pages_spec.rb b/spec/requests/alchemy/json_api/pages_spec.rb index f48dcc5..d4710fb 100644 --- a/spec/requests/alchemy/json_api/pages_spec.rb +++ b/spec/requests/alchemy/json_api/pages_spec.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories/page_factory" -require "alchemy/test_support/factories/element_factory" require "alchemy/devise/test_support/factories" require "alchemy/version" diff --git a/spec/serializers/alchemy/json_api/element_serializer_spec.rb b/spec/serializers/alchemy/json_api/element_serializer_spec.rb index da48bd6..edde5bd 100644 --- a/spec/serializers/alchemy/json_api/element_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/element_serializer_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories" RSpec.describe Alchemy::JsonApi::ElementSerializer do let(:element) do diff --git a/spec/serializers/alchemy/json_api/essence_boolean_serializer_spec.rb b/spec/serializers/alchemy/json_api/essence_boolean_serializer_spec.rb index 8be839f..6903415 100644 --- a/spec/serializers/alchemy/json_api/essence_boolean_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/essence_boolean_serializer_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories" RSpec.describe Alchemy::JsonApi::EssenceBooleanSerializer do let(:element) { FactoryBot.create(:alchemy_element) } diff --git a/spec/serializers/alchemy/json_api/essence_date_serializer_spec.rb b/spec/serializers/alchemy/json_api/essence_date_serializer_spec.rb index 12c3621..bb2835c 100644 --- a/spec/serializers/alchemy/json_api/essence_date_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/essence_date_serializer_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories" RSpec.describe Alchemy::JsonApi::EssenceDateSerializer do let(:today) { Date.today } diff --git a/spec/serializers/alchemy/json_api/essence_file_serializer_spec.rb b/spec/serializers/alchemy/json_api/essence_file_serializer_spec.rb index e73d96c..8b3d8c9 100644 --- a/spec/serializers/alchemy/json_api/essence_file_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/essence_file_serializer_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories" RSpec.describe Alchemy::JsonApi::EssenceFileSerializer do let(:element) { FactoryBot.create(:alchemy_element) } diff --git a/spec/serializers/alchemy/json_api/essence_html_serializer_spec.rb b/spec/serializers/alchemy/json_api/essence_html_serializer_spec.rb index ee9e8ee..a63af7d 100644 --- a/spec/serializers/alchemy/json_api/essence_html_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/essence_html_serializer_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories" RSpec.describe Alchemy::JsonApi::EssenceHtmlSerializer do let(:element) { FactoryBot.create(:alchemy_element) } diff --git a/spec/serializers/alchemy/json_api/essence_link_serializer_spec.rb b/spec/serializers/alchemy/json_api/essence_link_serializer_spec.rb index a7b10e8..3319c9a 100644 --- a/spec/serializers/alchemy/json_api/essence_link_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/essence_link_serializer_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories" RSpec.describe Alchemy::JsonApi::EssenceLinkSerializer do let(:element) { FactoryBot.create(:alchemy_element) } diff --git a/spec/serializers/alchemy/json_api/essence_node_serializer_spec.rb b/spec/serializers/alchemy/json_api/essence_node_serializer_spec.rb index 4b433fc..e1850f6 100644 --- a/spec/serializers/alchemy/json_api/essence_node_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/essence_node_serializer_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories" require "alchemy/essence_node" RSpec.describe Alchemy::JsonApi::EssenceNodeSerializer do diff --git a/spec/serializers/alchemy/json_api/essence_page_serializer_spec.rb b/spec/serializers/alchemy/json_api/essence_page_serializer_spec.rb index 0a9abc4..1744993 100644 --- a/spec/serializers/alchemy/json_api/essence_page_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/essence_page_serializer_spec.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories/content_factory" -require "alchemy/test_support/factories/essence_page_factory" RSpec.describe Alchemy::JsonApi::EssencePageSerializer do let(:element) { FactoryBot.create(:alchemy_element) } diff --git a/spec/serializers/alchemy/json_api/essence_picture_serializer_spec.rb b/spec/serializers/alchemy/json_api/essence_picture_serializer_spec.rb index e89bfa0..745dfee 100644 --- a/spec/serializers/alchemy/json_api/essence_picture_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/essence_picture_serializer_spec.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories/content_factory" -require "alchemy/test_support/factories/essence_picture_factory" RSpec.describe Alchemy::JsonApi::EssencePictureSerializer do let(:element) { FactoryBot.create(:alchemy_element) } diff --git a/spec/serializers/alchemy/json_api/essence_richtext_serializer_spec.rb b/spec/serializers/alchemy/json_api/essence_richtext_serializer_spec.rb index 568ff92..9eca6d8 100644 --- a/spec/serializers/alchemy/json_api/essence_richtext_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/essence_richtext_serializer_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories" RSpec.describe Alchemy::JsonApi::EssenceRichtextSerializer do let(:element) { FactoryBot.create(:alchemy_element) } diff --git a/spec/serializers/alchemy/json_api/essence_select_serializer_spec.rb b/spec/serializers/alchemy/json_api/essence_select_serializer_spec.rb index f6f7b63..1669a4a 100644 --- a/spec/serializers/alchemy/json_api/essence_select_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/essence_select_serializer_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories" RSpec.describe Alchemy::JsonApi::EssenceSelectSerializer do let(:element) { FactoryBot.create(:alchemy_element) } diff --git a/spec/serializers/alchemy/json_api/essence_text_serializer_spec.rb b/spec/serializers/alchemy/json_api/essence_text_serializer_spec.rb index 0bc7090..1fce226 100644 --- a/spec/serializers/alchemy/json_api/essence_text_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/essence_text_serializer_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories" RSpec.describe Alchemy::JsonApi::EssenceTextSerializer do let(:element) { FactoryBot.create(:alchemy_element) } diff --git a/spec/serializers/alchemy/json_api/language_serializer_spec.rb b/spec/serializers/alchemy/json_api/language_serializer_spec.rb index ef5a7cd..43e1fa8 100644 --- a/spec/serializers/alchemy/json_api/language_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/language_serializer_spec.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories/language_factory" -require "alchemy/test_support/factories/page_factory" -require "alchemy/test_support/factories/node_factory" RSpec.describe Alchemy::JsonApi::LanguageSerializer do let(:language) do diff --git a/spec/serializers/alchemy/json_api/node_serializer_spec.rb b/spec/serializers/alchemy/json_api/node_serializer_spec.rb index 4903f4b..307187c 100644 --- a/spec/serializers/alchemy/json_api/node_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/node_serializer_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories" RSpec.describe Alchemy::JsonApi::NodeSerializer do let(:node) do diff --git a/spec/serializers/alchemy/json_api/page_serializer_spec.rb b/spec/serializers/alchemy/json_api/page_serializer_spec.rb index b6165e5..7ab5a8b 100644 --- a/spec/serializers/alchemy/json_api/page_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/page_serializer_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true require "rails_helper" -require "alchemy/test_support/factories" RSpec.describe Alchemy::JsonApi::PageSerializer do let(:alchemy_page) do From 7447317beb666211fb84501a60e581647f7593c6 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Wed, 17 Feb 2021 13:16:12 +0100 Subject: [PATCH 2/2] Remove cop from rubocop.yml This file has been copy-pasted from Alchemy and the file excluded is not present in this gem. --- .rubocop.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f1ea14e..68a2c8a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -75,10 +75,6 @@ Layout/ElseAlignment: Layout/EmptyLineAfterMagicComment: Enabled: false -Layout/EmptyLinesAroundAccessModifier: - Exclude: - - lib/alchemy/test_support/factories/*.rb - Layout/FirstArrayElementIndentation: Enabled: false