detektiiv 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +18 -7
- data/lib/detektiiv.rb +4 -1
- data/lib/detektiiv/factory_runner_patch.rb +12 -4
- data/lib/detektiiv/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f3c713f58968281bdbf88ea909c63a4e5376ffedb02c9c303f07993d9be4e03
|
4
|
+
data.tar.gz: e3961fdb0d4fcd2cc6597401477ff88f406f30d3bb49dc7b64ea9a70155d4d8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c561cf5e4a7346437932bce2bb506590c273a5c207d62b34986c8fa92a77e1e64570bda1587b08f19aafbbacfb1f607fb3395b94463e7d8e7a925fb80efa3473
|
7
|
+
data.tar.gz: 2853e5d3e97105e3f37eaf91526cc2580a4b580337cd63f84f9eb167c12122fb0bc282b0db1ac1f76cb49b048c0e92a2f04bf3afec3495d98496910cff715f00
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Detektiiv
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Detektiiv discovers factory file path defined in other namespace that call from rails application.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -16,13 +14,26 @@ And then execute:
|
|
16
14
|
|
17
15
|
$ bundle
|
18
16
|
|
19
|
-
|
17
|
+
## Usage
|
20
18
|
|
21
|
-
|
19
|
+
Initialize Detektiiv after loading factory_bot gem.
|
22
20
|
|
23
|
-
|
21
|
+
```
|
22
|
+
Detektiiv.configure do |config|
|
23
|
+
config.application_name = 'Rails application name'
|
24
|
+
config.logfile_path = '/tmp/detektiiv.log'
|
25
|
+
end
|
24
26
|
|
25
|
-
|
27
|
+
Detektiiv.exec_patch!
|
28
|
+
```
|
29
|
+
|
30
|
+
Then running test. If there are calling factory defined in other namespace, below log shows up.
|
31
|
+
|
32
|
+
```
|
33
|
+
# Logfile created on 2019-07-13 13:33:02 +0900 by logger.rb/61378
|
34
|
+
{:filepath=>#<Proc:0x00007fb3a43c4c18@/Users/kamillle/sample_app/.bundle/bundler/gems/other_app/spec/factories/book.rb:3>}
|
35
|
+
{:caller=>"[\"/Users/kamillle/sample_app/spec/models/author_spec.rb:50:in `block (3 levels) in <top (required)>'\"]"}
|
36
|
+
```
|
26
37
|
|
27
38
|
## Development
|
28
39
|
|
data/lib/detektiiv.rb
CHANGED
@@ -4,6 +4,8 @@ require "detektiiv/version"
|
|
4
4
|
require "detektiiv/configuration"
|
5
5
|
|
6
6
|
module Detektiiv
|
7
|
+
class InitializationError < StandardError; end
|
8
|
+
|
7
9
|
class << self
|
8
10
|
def configure
|
9
11
|
yield(configuration)
|
@@ -14,10 +16,11 @@ module Detektiiv
|
|
14
16
|
end
|
15
17
|
|
16
18
|
def exec_patch!
|
19
|
+
raise InitializationError, 'exec_patch! must be called after load factory_bot gem' unless defined?(FactoryBot)
|
20
|
+
|
17
21
|
require "detektiiv/factory_runner_patch"
|
18
22
|
|
19
23
|
::FactoryBot::FactoryRunner.prepend Detektiiv::FactoryRunnerPatch
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
23
|
-
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
module Detektiiv
|
4
4
|
module FactoryRunnerPatch
|
5
|
-
LOGGER = Logger.new("#{Detektiiv.configuration.logfile_path}")
|
6
|
-
|
7
5
|
def run
|
8
6
|
logging_bad_factory_call
|
9
7
|
|
@@ -24,9 +22,19 @@ module Detektiiv
|
|
24
22
|
if factory_defined_filename&.to_s&.include?("#{Detektiiv.configuration.application_name}/spec/factories") || factory_defined_filename&.to_s&.include?('factory_bot') || factory_defined_filename.nil?
|
25
23
|
return
|
26
24
|
else
|
27
|
-
|
28
|
-
|
25
|
+
logger.debug(filepath: factory_defined_filename)
|
26
|
+
logger.debug(caller: caller.select {|i| i.include?("#{Detektiiv.configuration.application_name}/spec") }.to_s)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def logger
|
31
|
+
@logger ||= Logger.new("#{Detektiiv.configuration.logfile_path}")
|
32
|
+
|
33
|
+
@logger.formatter = proc do |_severity, _datetime, _progname, msg|
|
34
|
+
"#{msg}\n"
|
29
35
|
end
|
36
|
+
|
37
|
+
@logger
|
30
38
|
end
|
31
39
|
end
|
32
40
|
end
|
data/lib/detektiiv/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: detektiiv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kamillle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|