Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix factory loading #39

Merged
merged 2 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ Layout/ElseAlignment:
Layout/EmptyLineAfterMagicComment:
Enabled: false

Layout/EmptyLinesAroundAccessModifier:
Exclude:
- lib/alchemy/test_support/factories/*.rb

Layout/FirstArrayElementIndentation:
Enabled: false

Expand Down
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