factory_bot-awesome_linter 1.0.5 → 1.0.6

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: b4a2f5d05d6d9ca4043893d5c91205e859ba510a16a79437e20d7346a5f80d75
4
- data.tar.gz: 477c1487d7b700b374b27e3e0943e27664ffd5892ebdcdbcb07e7d67bd34ed3c
3
+ metadata.gz: ae90b0c8efc9e341ac25b4edc3455c4cd9e73734a45b53d2501b8491e409b3c3
4
+ data.tar.gz: 5d43d76e260da885ce7a70cd139b3b0dee54e7faf73ca733583e853e3e6abecf
5
5
  SHA512:
6
- metadata.gz: dc8fb4c26f797fcaef3820e45df7cb255432941feec7ccd6ca40b239a322e7b8a48eacf7ccbf3b329c94eec9be69a822336af0aaa0db56e4f7dd0ce1078164e9
7
- data.tar.gz: 94b4841a8604386094d5927c06f3dc5c2db6541fbd020bbf87d929f953d54d860eb930ce44f556edd121991bd9a184da53d23decebef6482a5527d725c9f4a82
6
+ metadata.gz: 5c06274829cba67b130a75d0b585e3ad74228381c119fc39ad63d9fa709bd42f4027b437415827a76fbaf21641f47f3b14845ed5e2f58fcb8da90c3531799c05
7
+ data.tar.gz: 1837ff2d64c83ea65f15b089b4dd7c022b6394597d10ca0678e6962eb6d23074b1aaaa06ad6791f8fe09c3bb69733b12d7c2731c08916ab8c5fc948bc740e8fb
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2022 Savater Sebastien
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # Awesome linter for FactoryBot
2
+
3
+ This gem enhances [FactoryBot linter](https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#linting-factories)
4
+
5
+ * it wraps factories creation:
6
+ * within DatabaseCleaner if present
7
+ * within ActiveRecord within transaction if DatabaseCleaner is not present but ActiveRecord is
8
+
9
+ * it displays a progress bar and quickly display failures (just like [fuubar](https://github.com/thekompanee/fuubar))
10
+ * it shows backtraces when factories failed
11
+ * it lints all factories and traits by default
12
+ * it allows easy selection of factories
13
+ * it reloads cached factories before each run
14
+
15
+ [![Gem Version](https://badge.fury.io/rb/factory_bot-awesome_linter.svg)](https://rubygems.org/gems/factory_bot-awesome_linter)
16
+ [![CI Status](https://github.com/inkstak/factory_bot-awesome_linter/actions/workflows/ci.yml/badge.svg)](https://github.com/inkstak/factory_bot-awesome_linter/actions/workflows/ci.yml)
17
+ [![Maintainability](https://api.codeclimate.com/v1/badges/9bb8b75ea8c66b1a9c94/maintainability)](https://codeclimate.com/github/inkstak/factory_bot-awesome_linter/maintainability)
18
+ <!-- [![Test Coverage](https://api.codeclimate.com/v1/badges/9bb8b75ea8c66b1a9c94/test_coverage)](https://codeclimate.com/github/inkstak/factory_bot-awesome_linter/test_coverage) -->
19
+
20
+ ## Installation
21
+
22
+ Add these line to your application's Gemfile:
23
+
24
+ ```ruby
25
+ gem 'factory_bot-awesome_linter'
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ Just run:
31
+
32
+ ```ruby
33
+ FactoryBot::AwesomeLinter.lint!
34
+ ```
35
+
36
+ All factories are included by default.
37
+ You can select factories to lint by passing their names, a regexp, or factories:
38
+
39
+ ```ruby
40
+ FactoryBot::AwesomeLinter.lint!(:user)
41
+ FactoryBot::AwesomeLinter.lint!(:user, :account)
42
+ FactoryBot::AwesomeLinter.lint!(/^new_/)
43
+
44
+ factories_to_lint = FactoryBot.factories.reject do |factory|
45
+ factory.name =~ /^old_/
46
+ end
47
+
48
+ FactoryBot::AwesomeLinter.lint!(*factories_to_lint)
49
+ ```
50
+
51
+ All traits are included by default.
52
+ You can exclude them:
53
+
54
+ ```ruby
55
+ FactoryBot::AwesomeLinter.lint!(traits: false)
56
+ ```
57
+
58
+ Default linting strategy is `:create`.
59
+ You can specify another or multiple strategies used for linting:
60
+
61
+ ```ruby
62
+ FactoryBot::AwesomeLinter.lint!(strategy: :build)
63
+ FactoryBot::AwesomeLinter.lint!(strategy: %i[create build_stubbed])
64
+ ```
65
+
66
+ All arguments can be combined:
67
+
68
+ ```ruby
69
+ FactoryBot::AwesomeLinter.lint!(:user, strategy: :build, traits: false)
70
+ ```
71
+
72
+ ## Rake task
73
+
74
+ Create the following task in `lib/tasks/factory_bot.rake`
75
+
76
+ ```ruby
77
+ namespace :factory_bot do
78
+ desc "Verify that all FactoryBot factories are valid"
79
+ task lint: :environment do
80
+ if Rails.env.test?
81
+ abort unless FactoryBot::AwesomeLinter.lint!
82
+ else
83
+ puts "Wrong environment detected to run factory_bot:lint"
84
+ puts "Running `bundle exec bin/rails factory_bot:lint RAILS_ENV='test'` instead"
85
+
86
+ system("bundle exec bin/rails factory_bot:lint RAILS_ENV='test'")
87
+ exit $CHILD_STATUS.exitstatus
88
+ end
89
+ end
90
+ end
91
+ ```
92
+
93
+ Then run :
94
+
95
+ ```
96
+ bundle exec bin/rails factory_bot:lint RAILS_ENV='test'
97
+ ```
98
+
99
+ ## TODO
100
+
101
+ * Add tests
102
+
103
+ ## Contributing
104
+
105
+ 1. Don't hesitate to submit your feature/idea/fix in [issues](https://github.com/inkstak/factory_bot-awesome_linter)
106
+ 2. Fork the [repository](https://github.com/inkstak/factory_bot-awesome_linter)
107
+ 3. Create your feature branch
108
+ 4. Ensure Rubocop are passing
109
+ 4. Create a pull request
110
+
111
+ ### Lint
112
+
113
+ ```bash
114
+ bundle exec rubocop
115
+ ```
116
+
117
+ ## License & credits
118
+
119
+ Inspired by the awesome work from [Thoughtbot](https://github.com/thoughtbot/factory_bot).
120
+
121
+ Please see [LICENSE](https://github.com/inkstak/factory_bot-awesome_linter/blob/main/LICENSE) for further details.
122
+
123
+ Contributors: [./graphs/contributors](https://github.com/inkstak/factory_bot-awesome_linter/graphs/contributors)
@@ -1,5 +1,5 @@
1
1
  module FactoryBot
2
2
  class AwesomeLinter
3
- VERSION = '1.0.5'.freeze
3
+ VERSION = "1.0.6".freeze
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'factory_bot'
4
- require 'ruby-progressbar'
3
+ require "factory_bot"
4
+ require "ruby-progressbar"
5
5
 
6
6
  module FactoryBot
7
7
  class AwesomeLinter
@@ -11,10 +11,9 @@ module FactoryBot
11
11
 
12
12
  def initialize(*args, strategy: :create, traits: true)
13
13
  @factories_to_lint = load_factories(*args)
14
-
15
- @factory_strategy = strategy
16
- @traits = traits
17
- @progress_bar = ProgressBar.create(format: "\e[0;32m %c/%C |%w>%i| %e \e[0m")
14
+ @factory_strategies = Array.wrap(strategy)
15
+ @traits = traits
16
+ @progress_bar = ProgressBar.create(format: "\e[0;32m %c/%C |%w>%i| %e \e[0m")
18
17
  @invalid_factories = []
19
18
  end
20
19
 
@@ -72,18 +71,22 @@ module FactoryBot
72
71
  end
73
72
 
74
73
  def lint_factory(factory)
75
- cleaning do
76
- FactoryBot.public_send(@factory_strategy, factory.name)
74
+ @factory_strategies.each do |stategy|
75
+ cleaning do
76
+ FactoryBot.public_send(stategy, factory.name)
77
+ end
77
78
  end
78
- rescue StandardError => e
79
+ rescue => e
79
80
  invalid_factory! e, factory
80
81
  end
81
82
 
82
83
  def lint_trait(factory, trait)
83
- cleaning do
84
- FactoryBot.public_send(@factory_strategy, factory.name, trait.name)
84
+ @factory_strategies.each do |stategy|
85
+ cleaning do
86
+ FactoryBot.public_send(stategy, factory.name, trait.name)
87
+ end
85
88
  end
86
- rescue StandardError => e
89
+ rescue => e
87
90
  invalid_factory! e, factory, trait
88
91
  end
89
92
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_bot-awesome_linter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Savater Sebastien
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-15 00:00:00.000000000 Z
11
+ date: 2023-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: factory_bot
@@ -39,12 +39,13 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.11.0
41
41
  description:
42
- email:
43
- - savater.sebastien@gmail.com
42
+ email: github.60k5k@simplelogin.co
44
43
  executables: []
45
44
  extensions: []
46
45
  extra_rdoc_files: []
47
46
  files:
47
+ - LICENSE
48
+ - README.md
48
49
  - lib/factory_bot-awesome_linter.rb
49
50
  - lib/factory_bot-awesome_linter/version.rb
50
51
  homepage: https://github.com/inkstak/factory_bot-awesome_linter
@@ -66,8 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
67
  - !ruby/object:Gem::Version
67
68
  version: '0'
68
69
  requirements: []
69
- rubygems_version: 3.3.7
70
+ rubygems_version: 3.3.26
70
71
  signing_key:
71
72
  specification_version: 4
72
- summary: Enhanced linter for FactoryBot
73
+ summary: An awesome linter for FactoryBot
73
74
  test_files: []