rspec-all_records_validator 0.0.7 → 0.1.0
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.lock +2 -1
- data/README.md +23 -0
- data/lib/rspec/all_records_validator/version.rb +1 -1
- data/lib/rspec/all_records_validator.rb +3 -3
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e2f7cae056e1f823338f2c399fceae7db6c44333c9643795ba058867540c00ad
         | 
| 4 | 
            +
              data.tar.gz: 97e990301f8b232199b5cc813a094954b28b21c574f6a4af57e14d36b978b852
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ba6811d02f7082ef00421f6a134d5c1626dd73d9294278adf6a16e7448875f912a49ad9d3193214b2f55804c427cdee7cc0a55143d01f8bd067309ff642aa9e1
         | 
| 7 | 
            +
              data.tar.gz: 4c62c235304c8d08ae8ad538dbdb43e17fcbb6919ca9bd16806e02d3f9da3dcd366077b8dae8313a0e915f229ee738798297037fcb1b15c153b3ee744a8d6b7a
         | 
    
        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.1.0)
         | 
| 5 5 |  | 
| 6 6 | 
             
            GEM
         | 
| 7 7 | 
             
              remote: https://rubygems.org/
         | 
| @@ -168,6 +168,7 @@ GEM | |
| 168 168 |  | 
| 169 169 | 
             
            PLATFORMS
         | 
| 170 170 | 
             
              x86_64-darwin-18
         | 
| 171 | 
            +
              x86_64-darwin-19
         | 
| 171 172 | 
             
              x86_64-linux
         | 
| 172 173 |  | 
| 173 174 | 
             
            DEPENDENCIES
         | 
    
        data/README.md
    CHANGED
    
    | @@ -48,6 +48,17 @@ RSpec.configure do |config| | |
| 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
         | 
| @@ -59,3 +70,15 @@ RSpec.configure do |config| | |
| 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.
         | 
| @@ -4,11 +4,11 @@ require_relative "all_records_validator/version" | |
| 4 4 |  | 
| 5 5 | 
             
            module RSpec
         | 
| 6 6 | 
             
              module AllRecordsValidator
         | 
| 7 | 
            -
                def self.validate!(ignored_models: [])
         | 
| 8 | 
            -
                  target_classes = ApplicationRecord.subclasses.reject {|klass| klass.abstract_class? || ignored_models.include?(klass) }
         | 
| 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 | 
            -
                    klass.all. | 
| 11 | 
            +
                    klass.all.find_each do |obj|
         | 
| 12 12 | 
             
                      obj.validate!
         | 
| 13 13 | 
             
                    end
         | 
| 14 14 | 
             
                  end
         | 
    
        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.1.0
         | 
| 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-07-12 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rails
         | 
| @@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 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
         |