factory_trace 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a8964b9b2f6e4000d28ab545d781474d9c18668dbdb96a34de0c03b4282237f
4
- data.tar.gz: 72a2d76a083cf9266e5296b3c538d7f9f49102acdd1328cd385fc1f9e8e3e6a8
3
+ metadata.gz: 8a89ea162c1549be94964cbcdb8e0815c01d7e1b510844d928fde97e9b6f1008
4
+ data.tar.gz: 631b6277e162570d9d9fb12e23d60cf87fb1a3f615b8afed208b14f6bfaf5159
5
5
  SHA512:
6
- metadata.gz: 6096b82a57a43ab7ae87ef886f98ccda54dc0babb5e7a211d15a81464086e1fe479226af114fa745e5a47ce209df2fdcf0e81136f2058959e428147b98de248a
7
- data.tar.gz: b683fd747531cbc50851834f2bbf0aa4a2f17c03e8eadbd7bc5ac2571312abd9046d2d4a46bd8499d0640e9f5e43e46e952583794a3a454ccc3c286029f42f6e
6
+ metadata.gz: ee92060fadd43f146477fc7faeaed89157637b37460f5d84db4565112e3f52d1cbf08fbcac4431243e5e59375530cabe361a977b02fe101bf8d56e88005f5108
7
+ data.tar.gz: e60fb845b869986c1400ab1c9803c860e0bdcaa2360d626fb15ec268dfeb24763438a275c50417e3635e729a6a7e527bac36e1f4e165636dcf5b14ab7c934304
@@ -2,6 +2,7 @@
2
2
  require 'factory_bot'
3
3
  require 'json'
4
4
  require 'set'
5
+ require 'pathname'
5
6
  # Library
6
7
  require 'factory_trace/configuration'
7
8
  require 'factory_trace/version'
@@ -24,6 +25,7 @@ require 'factory_trace/writers/writer'
24
25
  require 'factory_trace/writers/report_writer'
25
26
  require 'factory_trace/writers/trace_writer'
26
27
 
28
+ require 'factory_trace/monkey_patches/monkey_patches'
27
29
  require 'factory_trace/monkey_patches/factory'
28
30
  require 'factory_trace/monkey_patches/trait'
29
31
  require 'factory_trace/monkey_patches/definition_proxy'
@@ -6,7 +6,11 @@ module FactoryTrace
6
6
  # @return [String] file and line where the original method was called
7
7
  def location
8
8
  location = caller_locations[1]
9
- "#{location.absolute_path}:#{location.lineno}"
9
+
10
+ base = Pathname.new(Dir.pwd)
11
+ method = Pathname.new(location.path)
12
+
13
+ "#{method.relative_path_from(base)}:#{location.lineno}"
10
14
  end
11
15
  end
12
16
  end
@@ -8,7 +8,7 @@ module FactoryTrace
8
8
  proxy = FactoryBot::DefinitionProxy.new(factory.definition)
9
9
  proxy.instance_eval(&block) if block_given?
10
10
 
11
- FactoryBot.register_factory(factory)
11
+ REGISTER.register_factory(factory)
12
12
 
13
13
  proxy.child_factories.each do |(child_name, child_caller_location, child_options, child_block)|
14
14
  parent_factory = child_options.delete(:parent) || name
@@ -17,7 +17,7 @@ module FactoryTrace
17
17
  end
18
18
 
19
19
  def trait(name, &block)
20
- FactoryBot.register_trait(FactoryBot::Trait.new(name, Helpers::Caller.location, &block))
20
+ REGISTER.register_trait(FactoryBot::Trait.new(name, Helpers::Caller.location, &block))
21
21
  end
22
22
  end
23
23
  end
@@ -0,0 +1,5 @@
1
+ module FactoryTrace
2
+ module MonkeyPatches
3
+ REGISTER = FactoryBot::VERSION >= '5.1.0' ? FactoryBot::Internal : FactoryBot
4
+ end
5
+ end
@@ -5,7 +5,7 @@ module FactoryTrace
5
5
  def self.call
6
6
  collection = FactoryTrace::Structures::Collection.new
7
7
 
8
- FactoryBot.traits.each do |trait|
8
+ MonkeyPatches::REGISTER.traits.each do |trait|
9
9
  collection.add(FactoryTrace::Helpers::Converter.trait(trait))
10
10
  end
11
11
 
@@ -1,3 +1,3 @@
1
1
  module FactoryTrace
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_trace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - djezzzl
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-29 00:00:00.000000000 Z
11
+ date: 2019-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: factory_bot
@@ -83,6 +83,7 @@ files:
83
83
  - lib/factory_trace/monkey_patches/definition_proxy.rb
84
84
  - lib/factory_trace/monkey_patches/dsl.rb
85
85
  - lib/factory_trace/monkey_patches/factory.rb
86
+ - lib/factory_trace/monkey_patches/monkey_patches.rb
86
87
  - lib/factory_trace/monkey_patches/trait.rb
87
88
  - lib/factory_trace/preprocessors/extract_defined.rb
88
89
  - lib/factory_trace/preprocessors/extract_used.rb