solidus_dev_support 2.4.1 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8b89b3a9856d2e920d23a4aa6b111f5d0183ac78c6a4148b1eb41627277bc5a
4
- data.tar.gz: b5ba6eda194e217eb30e965a278f69cf3a0ecd09d3c1b589e66cfbe4bdb49ad5
3
+ metadata.gz: 2909d8c487345aa45ebf8962ace27cbc7d8e2a34eeb2f3eb6ba380913b50c2b4
4
+ data.tar.gz: a921fad3ec04944509f46f7a113a073b48100971395950525242c48a83b994e4
5
5
  SHA512:
6
- metadata.gz: 778ebb59f1f980c9a978fb353c3ba68b4e89bdafe1b0f2d4509108fcac286f08e9e7c1923db706ff809f4bea47df6359dfa82c012b8061dcfabc9f0afd5701c1
7
- data.tar.gz: f1de5819cdd6f252490fa1ee458765b1a47dd1a82f46e92b5b7b027fe80682b6955144aaa7491f4bf56cae910133431a2fa7dc842365d9b69170b251d2a8fe3c
6
+ metadata.gz: bbb86bd58f06496f53b3c5f4d84ce47b41b9be72135d77aba58ee12b0bffdbc3afef0325fc4ec1dd2926d6cf6a97b11527380372ba28e4adb26719f5d3c9dc4d
7
+ data.tar.gz: 39e02e67c9b94436456bf5c751196a6b600dac9ac70b7c90488fa5f2793f959c41302cfc8b66ad860c1daac28ea8811e41571fd711f18ba55526ea59133b3fae
@@ -1,10 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'factory_bot'
4
+
5
+ Spree::Deprecation.silence do
6
+ require 'spree/testing_support/factories'
7
+ puts <<~MSG
8
+ We are transitioning to a new way of loading factories for extensions.
9
+ Be sure this extension does not load factories using require but uses
10
+ the load_for() method in its spec_helper.rb, eg:
11
+
12
+ SolidusDevSupport::TestingSupport::Factories.load_for(ExtensionName1::Engine, ExtensionName2::Engine)
13
+
14
+ This will load Solidus Core factories right before the ones defined in
15
+ lib/extension_name/testing_support/factories/*_factory.rb or
16
+ lib/extension_name/testing_support/factories.rb
17
+
18
+ This message will be removed when all extensions are updated.
19
+ MSG
20
+ end
21
+
3
22
  begin
4
23
  require 'spree/testing_support/factory_bot'
5
24
  rescue LoadError
6
- require 'factory_bot'
7
- require 'spree/testing_support/factories'
25
+ # Do nothing, we are testing the extension against an old version of Solidus
8
26
  end
9
27
 
10
28
  module SolidusDevSupport
@@ -12,21 +30,37 @@ module SolidusDevSupport
12
30
  module Factories
13
31
  def self.load_for(*engines)
14
32
  paths = engines.flat_map do |engine|
15
- factories_file_or_folder = engine.root.glob('lib/*/testing_support/factories{,.rb}')
16
-
17
- if factories_file_or_folder.size == 2 && using_factory_bot_definition_file_paths?
18
- folder, file = factories_file_or_folder.partition(&:directory?).map(&:first).map { |path| path.to_s.gsub(engine.root.to_s, '') }
33
+ # Check if the extension has a lib/*/factories.rb. If it does, we emit a
34
+ # deprecation warning and just use it.
35
+ obsolete_factories_file = engine.root.glob('lib/*/factories.rb').first # 'lib/*/factories/*_factory.rb'
36
+ if obsolete_factories_file.present?
19
37
  ActiveSupport::Deprecation.warn <<-WARN.squish, caller(4)
20
38
  SolidusDevSupport::TestingSupport::Factories.load_for() is automatically loading
21
- all factories present into #{folder}. You should now safely remove #{file} if it
22
- is only used to load ./factories content.
39
+ all factories present in #{obsolete_factories_file.dirname.to_s.gsub(engine.root.to_s, '')}/testing_support/factories/.
40
+ Please move the content of #{obsolete_factories_file.to_s.gsub(engine.root.to_s, '')} to that directory.
23
41
  WARN
24
42
 
25
- engine.root.glob('lib/*/testing_support/factories/**/*_factory.rb')
43
+ [obsolete_factories_file]
26
44
  else
27
- factories_file_or_folder
28
- end.map { |path| path.sub(/.rb\z/, '').to_s }
29
- end
45
+ # If there are both a lib/*/testing_support/factories.rb and a lib/*/testing_support/factories/,
46
+ # we assume that the factories.rb file is only used to load all factories prensent in the directory.
47
+ # That file can be removed from the extension, in fact, we ignore it and emit a message asking to
48
+ # remove it.
49
+ factories_file_or_folder = engine.root.glob('lib/*/testing_support/factories{,.rb}')
50
+ if factories_file_or_folder.size == 2
51
+ folder, file = factories_file_or_folder.partition(&:directory?).map(&:first).map { |path| path.to_s.gsub(engine.root.to_s, '') }
52
+ ActiveSupport::Deprecation.warn <<-WARN.squish, caller(4)
53
+ SolidusDevSupport::TestingSupport::Factories.load_for() is automatically loading
54
+ all factories present into #{folder}. You should now safely remove #{file} if it
55
+ is only used to load ./factories content.
56
+ WARN
57
+
58
+ engine.root.glob('lib/*/testing_support/factories/**/*_factory.rb')
59
+ else
60
+ factories_file_or_folder
61
+ end
62
+ end
63
+ end.map { |path| path.sub(/.rb\z/, '').to_s }
30
64
 
31
65
  if using_factory_bot_definition_file_paths?
32
66
  FactoryBot.definition_file_paths = [
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusDevSupport
4
- VERSION = "2.4.1"
4
+ VERSION = "2.4.2"
5
5
 
6
6
  def self.gem_version
7
7
  Gem::Version.new(VERSION)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_dev_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Desantis