shoulda-matchers 4.2.0 → 4.3.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
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: c022366c394fe10215171aee752452d41f7e051ef0174b99e0d9f947486ac1f7
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 38bc2bf3e4d8432ebc8a8c1bfb319fc1da9236699e1ec28d78b53d93621c96c2
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: e06ce93032d5612eb34c952eb310f199b718e35875ae31c84ae177a09ca2bbdcc5fe33cc8fc3a97f5bf77aa3c5e2c91e3f7596e8c6328c66e494c8a9f3a94d90
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 10f26b7b206227be842077802b9da370775b198cf30f32e8df70fa1b1bb69cbddd831244071eab874d98e186c6abee7a8c11187015f65b8f1f570b47ba20e947
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,9 +1,11 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # Shoulda Matchers [![Gem Version][version-badge]][rubygems] [![Build Status][travis-badge]][travis] ![Downloads][downloads-badge] [![Hound][hound-badge]][hound]
         
     | 
| 
      
 1 
     | 
    
         
            +
            # Shoulda Matchers [![Gem Version][version-badge]][rubygems] [![Build Status][travis-badge]][travis] [![Total Downloads][downloads-total]][rubygems] [![Downloads][downloads-badge]][rubygems] [![Hound][hound-badge]][hound]
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            [version-badge]: https://img.shields.io/gem/v/shoulda-matchers.svg
         
     | 
| 
       4 
4 
     | 
    
         
             
            [rubygems]: https://rubygems.org/gems/shoulda-matchers
         
     | 
| 
       5 
5 
     | 
    
         
             
            [travis-badge]: https://img.shields.io/travis/thoughtbot/shoulda-matchers/master.svg
         
     | 
| 
       6 
6 
     | 
    
         
             
            [travis]: https://travis-ci.org/thoughtbot/shoulda-matchers
         
     | 
| 
      
 7 
     | 
    
         
            +
            [downloads-total]: https://img.shields.io/gem/dt/shoulda-matchers.svg
         
     | 
| 
      
 8 
     | 
    
         
            +
            [downloads-badge]: https://img.shields.io/gem/dtv/shoulda-matchers.svg
         
     | 
| 
       7 
9 
     | 
    
         
             
            [downloads-badge]: https://img.shields.io/gem/dtv/shoulda-matchers.svg
         
     | 
| 
       8 
10 
     | 
    
         
             
            [hound-badge]: https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg
         
     | 
| 
       9 
11 
     | 
    
         
             
            [hound]: https://houndci.com
         
     | 
| 
         @@ -334,6 +336,8 @@ about any of them, make sure to [consult the documentation][rubydocs]! 
     | 
|
| 
       334 
336 
     | 
    
         
             
              tests your `has_one` associations.
         
     | 
| 
       335 
337 
     | 
    
         
             
            * **[have_readonly_attribute](lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb)**
         
     | 
| 
       336 
338 
     | 
    
         
             
              tests usage of the `attr_readonly` macro.
         
     | 
| 
      
 339 
     | 
    
         
            +
            * **[have_rich_text](lib/shoulda/matchers/active_record/have_rich_text_matcher.rb)**
         
     | 
| 
      
 340 
     | 
    
         
            +
              tests your `has_rich_text` associations.
         
     | 
| 
       337 
341 
     | 
    
         
             
            * **[serialize](lib/shoulda/matchers/active_record/serialize_matcher.rb)** tests
         
     | 
| 
       338 
342 
     | 
    
         
             
              usage of the `serialize` macro.
         
     | 
| 
       339 
343 
     | 
    
         
             
            * **[validate_uniqueness_of](lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb)**
         
     | 
| 
         @@ -15,6 +15,7 @@ require "shoulda/matchers/active_record/association_matchers/option_verifier" 
     | 
|
| 
       15 
15 
     | 
    
         
             
            require "shoulda/matchers/active_record/have_db_column_matcher"
         
     | 
| 
       16 
16 
     | 
    
         
             
            require "shoulda/matchers/active_record/have_db_index_matcher"
         
     | 
| 
       17 
17 
     | 
    
         
             
            require "shoulda/matchers/active_record/have_readonly_attribute_matcher"
         
     | 
| 
      
 18 
     | 
    
         
            +
            require "shoulda/matchers/active_record/have_rich_text_matcher"
         
     | 
| 
       18 
19 
     | 
    
         
             
            require "shoulda/matchers/active_record/have_secure_token_matcher"
         
     | 
| 
       19 
20 
     | 
    
         
             
            require "shoulda/matchers/active_record/serialize_matcher"
         
     | 
| 
       20 
21 
     | 
    
         
             
            require "shoulda/matchers/active_record/accept_nested_attributes_for_matcher"
         
     | 
| 
         @@ -0,0 +1,79 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Shoulda
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Matchers
         
     | 
| 
      
 3 
     | 
    
         
            +
                module ActiveRecord
         
     | 
| 
      
 4 
     | 
    
         
            +
                  # The `have_rich_text` matcher tests usage of the
         
     | 
| 
      
 5 
     | 
    
         
            +
                  # `has_rich_text` macro.
         
     | 
| 
      
 6 
     | 
    
         
            +
                  #
         
     | 
| 
      
 7 
     | 
    
         
            +
                  # #### Example
         
     | 
| 
      
 8 
     | 
    
         
            +
                  #
         
     | 
| 
      
 9 
     | 
    
         
            +
                  #     class Post < ActiveRecord
         
     | 
| 
      
 10 
     | 
    
         
            +
                  #       has_rich_text :content
         
     | 
| 
      
 11 
     | 
    
         
            +
                  #     end
         
     | 
| 
      
 12 
     | 
    
         
            +
                  #
         
     | 
| 
      
 13 
     | 
    
         
            +
                  #     # RSpec
         
     | 
| 
      
 14 
     | 
    
         
            +
                  #     RSpec.describe Post, type: :model do
         
     | 
| 
      
 15 
     | 
    
         
            +
                  #       it { is_expected.to have_rich_text(:content) }
         
     | 
| 
      
 16 
     | 
    
         
            +
                  #     end
         
     | 
| 
      
 17 
     | 
    
         
            +
                  #
         
     | 
| 
      
 18 
     | 
    
         
            +
                  #     # Minitest (Shoulda)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  #     class PostTest < ActiveSupport::TestCase
         
     | 
| 
      
 20 
     | 
    
         
            +
                  #       should have_rich_text(:content)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  #     end
         
     | 
| 
      
 22 
     | 
    
         
            +
                  #
         
     | 
| 
      
 23 
     | 
    
         
            +
                  # @return [HaveRichText]
         
     | 
| 
      
 24 
     | 
    
         
            +
                  #
         
     | 
| 
      
 25 
     | 
    
         
            +
                  def have_rich_text(rich_text_attribute)
         
     | 
| 
      
 26 
     | 
    
         
            +
                    HaveRichText.new(rich_text_attribute)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                  # @private
         
     | 
| 
      
 30 
     | 
    
         
            +
                  class HaveRichText
         
     | 
| 
      
 31 
     | 
    
         
            +
                    def initialize(rich_text_attribute)
         
     | 
| 
      
 32 
     | 
    
         
            +
                      @rich_text_attribute = rich_text_attribute
         
     | 
| 
      
 33 
     | 
    
         
            +
                    end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                    def description
         
     | 
| 
      
 36 
     | 
    
         
            +
                      "have configured :#{rich_text_attribute} as a ActionText::RichText association"
         
     | 
| 
      
 37 
     | 
    
         
            +
                    end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                    def failure_message
         
     | 
| 
      
 40 
     | 
    
         
            +
                      "Expected #{subject.class} to #{error_description}"
         
     | 
| 
      
 41 
     | 
    
         
            +
                    end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                    def failure_message_when_negated
         
     | 
| 
      
 44 
     | 
    
         
            +
                      "Did not expect #{subject.class} to have ActionText::RichText :#{rich_text_attribute}"
         
     | 
| 
      
 45 
     | 
    
         
            +
                    end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                    def matches?(subject)
         
     | 
| 
      
 48 
     | 
    
         
            +
                      @subject = subject
         
     | 
| 
      
 49 
     | 
    
         
            +
                      @error = run_checks
         
     | 
| 
      
 50 
     | 
    
         
            +
                      @error.nil?
         
     | 
| 
      
 51 
     | 
    
         
            +
                    end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                    private
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                    attr_reader :error, :rich_text_attribute, :subject
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                    def run_checks
         
     | 
| 
      
 58 
     | 
    
         
            +
                      if !has_attribute?
         
     | 
| 
      
 59 
     | 
    
         
            +
                        ":#{rich_text_attribute} does not exist"
         
     | 
| 
      
 60 
     | 
    
         
            +
                      elsif !has_expected_action_text?
         
     | 
| 
      
 61 
     | 
    
         
            +
                        :default
         
     | 
| 
      
 62 
     | 
    
         
            +
                      end
         
     | 
| 
      
 63 
     | 
    
         
            +
                    end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                    def has_attribute?
         
     | 
| 
      
 66 
     | 
    
         
            +
                      @subject.respond_to?(rich_text_attribute.to_s)
         
     | 
| 
      
 67 
     | 
    
         
            +
                    end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                    def has_expected_action_text?
         
     | 
| 
      
 70 
     | 
    
         
            +
                      @subject.send(rich_text_attribute).class.name == 'ActionText::RichText'
         
     | 
| 
      
 71 
     | 
    
         
            +
                    end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                    def error_description
         
     | 
| 
      
 74 
     | 
    
         
            +
                      error == :default ? description : "#{description} but #{error}"
         
     | 
| 
      
 75 
     | 
    
         
            +
                    end
         
     | 
| 
      
 76 
     | 
    
         
            +
                  end
         
     | 
| 
      
 77 
     | 
    
         
            +
                end
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: shoulda-matchers
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 4. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 4.3.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Tammer Saleh
         
     | 
| 
         @@ -14,7 +14,7 @@ authors: 
     | 
|
| 
       14 
14 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       15 
15 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
16 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
     | 
    
         
            -
            date: 2020- 
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2020-02-17 00:00:00.000000000 Z
         
     | 
| 
       18 
18 
     | 
    
         
             
            dependencies:
         
     | 
| 
       19 
19 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       20 
20 
     | 
    
         
             
              name: activesupport
         
     | 
| 
         @@ -116,6 +116,7 @@ files: 
     | 
|
| 
       116 
116 
     | 
    
         
             
            - lib/shoulda/matchers/active_record/have_db_column_matcher.rb
         
     | 
| 
       117 
117 
     | 
    
         
             
            - lib/shoulda/matchers/active_record/have_db_index_matcher.rb
         
     | 
| 
       118 
118 
     | 
    
         
             
            - lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb
         
     | 
| 
      
 119 
     | 
    
         
            +
            - lib/shoulda/matchers/active_record/have_rich_text_matcher.rb
         
     | 
| 
       119 
120 
     | 
    
         
             
            - lib/shoulda/matchers/active_record/have_secure_token_matcher.rb
         
     | 
| 
       120 
121 
     | 
    
         
             
            - lib/shoulda/matchers/active_record/serialize_matcher.rb
         
     | 
| 
       121 
122 
     | 
    
         
             
            - lib/shoulda/matchers/active_record/uniqueness.rb
         
     |