Skip to content

Commit

Permalink
Change the way we load Alchemy factories
Browse files Browse the repository at this point in the history
Alchemy 5.2 changed the way we load FactoryBot factories.
  • Loading branch information
tvdeyen committed Feb 17, 2021
1 parent b9938b3 commit 70e4ef6
Show file tree
Hide file tree
Showing 20 changed files with 11 additions and 25 deletions.
1 change: 0 additions & 1 deletion spec/models/alchemy/json_api/element_spec.rb
Original file line number Diff line number Diff line change
@@ -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") }
Expand Down
1 change: 0 additions & 1 deletion spec/models/alchemy/json_api/page_spec.rb
Original file line number Diff line number Diff line change
@@ -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") }
Expand Down
11 changes: 11 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions spec/requests/alchemy/json_api/layout_pages_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions spec/requests/alchemy/json_api/pages_spec.rb
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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) }
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
Original file line number Diff line number Diff line change
@@ -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) }
Expand Down
Original file line number Diff line number Diff line change
@@ -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) }
Expand Down
Original file line number Diff line number Diff line change
@@ -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) }
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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) }
Expand Down
Original file line number Diff line number Diff line change
@@ -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) }
Expand Down
Original file line number Diff line number Diff line change
@@ -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) }
Expand Down
Original file line number Diff line number Diff line change
@@ -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) }
Expand Down
Original file line number Diff line number Diff line change
@@ -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) }
Expand Down
3 changes: 0 additions & 3 deletions spec/serializers/alchemy/json_api/language_serializer_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion spec/serializers/alchemy/json_api/node_serializer_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion spec/serializers/alchemy/json_api/page_serializer_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 70e4ef6

Please sign in to comment.