rspec-all_records_validator 0.0.6 → 0.0.9
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 +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -1
- data/README.md +26 -3
- data/Rakefile +5 -0
- data/lib/rspec/all_records_validator/version.rb +1 -1
- data/lib/rspec/all_records_validator.rb +3 -3
- data/rspec-all_records_validator.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3ababcff1dab5b455e5e6aba00a8543a64f6c1ec8bf8473421379f643e27b43
|
4
|
+
data.tar.gz: 0c541b63d4ff5594a80c569ab5e74b2c12c94294e3f03240532c9ac5efea58b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1317679c0a865737fff766a8c52bc36744ed3614a1cec199cf5fc9417cf973dcf86b2c2c1f744509b6118e496b9a438e8dd3bc04a529c64a509e28286fb72cdb
|
7
|
+
data.tar.gz: 85b9e61b9ac6a8e76a4fd4d243fa7a36095ebcf096c8f7ab1fb42db0a86ce5006cb26a63a80d21f11d0982da62706ee264823c127ff055a70636f3e7aa316d79
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rspec-all_records_validator (0.0.
|
4
|
+
rspec-all_records_validator (0.0.9)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -171,6 +171,7 @@ PLATFORMS
|
|
171
171
|
x86_64-linux
|
172
172
|
|
173
173
|
DEPENDENCIES
|
174
|
+
activerecord
|
174
175
|
rails
|
175
176
|
rake
|
176
177
|
rspec
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ require 'rspec/all_records_validator'
|
|
31
31
|
|
32
32
|
RSpec.configure do |config|
|
33
33
|
config.after type: :system do
|
34
|
-
RSpec::AllRecordsValidator.
|
34
|
+
RSpec::AllRecordsValidator.validate!
|
35
35
|
end
|
36
36
|
end
|
37
37
|
```
|
@@ -43,11 +43,22 @@ You can avoid validation for specific models:
|
|
43
43
|
```ruby
|
44
44
|
RSpec.configure do |config|
|
45
45
|
config.after type: :system do
|
46
|
-
RSpec::AllRecordsValidator.
|
46
|
+
RSpec::AllRecordsValidator.validate!(ignored_models: [DoNotValidateThisModel])
|
47
47
|
end
|
48
48
|
end
|
49
49
|
```
|
50
50
|
|
51
|
+
#### Avoid validation for model whitch has no `has_many` association
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
RSpec.configure do |config|
|
55
|
+
config.after type: :system do
|
56
|
+
RSpec::AllRecordsValidator.validate!(only_has_many: true)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
|
51
62
|
#### For feature spec
|
52
63
|
|
53
64
|
You can config This setting for feature spec
|
@@ -55,7 +66,19 @@ You can config This setting for feature spec
|
|
55
66
|
```ruby
|
56
67
|
RSpec.configure do |config|
|
57
68
|
config.after type: :feature do
|
58
|
-
RSpec::AllRecordsValidator.
|
69
|
+
RSpec::AllRecordsValidator.validate!
|
59
70
|
end
|
60
71
|
end
|
61
72
|
```
|
73
|
+
|
74
|
+
### Pro Tip
|
75
|
+
|
76
|
+
If you use fixture or master data, ignore them is good for speed.
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
RSpec::AllRecordsValidator.validate!(ignored_models: [MasterDataModel])
|
80
|
+
```
|
81
|
+
|
82
|
+
## Contributing
|
83
|
+
|
84
|
+
Send me your pull requests.
|
data/Rakefile
CHANGED
@@ -4,12 +4,12 @@ require_relative "all_records_validator/version"
|
|
4
4
|
|
5
5
|
module RSpec
|
6
6
|
module AllRecordsValidator
|
7
|
-
def self.
|
8
|
-
target_classes = ApplicationRecord.subclasses.reject {|klass| klass.abstract_class? ||
|
7
|
+
def self.validate!(ignored_models: [], only_has_many: false)
|
8
|
+
target_classes = ApplicationRecord.subclasses.reject {|klass| klass.abstract_class? || ignored_models.include?(klass) || (only_has_many && klass.reflect_on_all_associations(:has_many).blank?) }
|
9
9
|
|
10
10
|
target_classes.each do |klass|
|
11
11
|
klass.all.each do |obj|
|
12
|
-
|
12
|
+
obj.validate!
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = "validate all objects at end of system spec"
|
12
12
|
spec.homepage = "https://github.com/colorbox/rspec-all_records_validator"
|
13
13
|
spec.license = "MIT"
|
14
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
15
15
|
|
16
16
|
spec.metadata["homepage_uri"] = spec.homepage
|
17
17
|
spec.metadata["source_code_uri"] = spec.homepage
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-all_records_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- colorbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -89,14 +89,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
89
|
requirements:
|
90
90
|
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: 2.
|
92
|
+
version: 2.7.0
|
93
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
|
-
rubygems_version: 3.3.
|
99
|
+
rubygems_version: 3.3.4
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: validate all objects at end of system spec
|