title: Shoulda matcher `validate_length_of` in RSpec with Reform form
body: <p>I'm setting up specs for my forms (using <code>Reform</code> gem) with <code>RSpec</code> and <code>Shoulda Matchers</code> gems. I'cant figure out why I'm having validation issues.  </p>
  
  <p>My actual configurations : </p>
  
  <pre class="lang-rb prettyprint-override"><code>  ruby '2.5.1'
    gem 'rails', '~&gt; 5.2.0'
    gem 'rspec-rails', '~&gt; 3.8'
    gem 'shoulda-matchers', '~&gt; 4.0'
    gem 'reform-rails', '~&gt; 0.1'
  </code></pre>
  
  <p>I've already tried different sorts of length validations in my form. But nothing make things much better.</p>
  
  <p>Here is the minimal form used for testing :</p>
  
  <pre class="lang-rb prettyprint-override"><code># frozen_string_literal: true
  
  class UserForm &lt; Reform::Form
    # == Properties  ==========================================================
    property :nickname
  
  
    # == Validations ==========================================================
    validates :nickname, presence: true, length: { minimum: 3, maximum: 100 } 
  end
  </code></pre>
  
  <p>Here is the spec :</p>
  
  <pre class="lang-rb prettyprint-override"><code># frozen_string_literal: true
  
  RSpec.describe UserForm, type: :model do
    subject { described_class.new(User.new) }
  
    it { is_expected.to validate_presence_of :nickname }
    it { is_expected.to validate_length_of(:nickname).is_at_least(3).is_at_most(100) }
  end
  </code></pre>
  
  <p>Note that the <code>validate_presence_of</code> matcher works perfectly. </p>
  
  <p>I'm having as <code>RSpec</code> output : </p>
  
  <pre><code>  1) UserForm should validate that the length of :nickname is between 3 and 100
       Failure/Error: it { is_expected.to validate_length_of(:nickname).is_at_least(3).is_at_most(100) }
  
         Expected UserForm to validate that the length of :nickname is between
         3 and 100, but this could not be proved.
           After setting :nickname to ‹"xxx"›, the matcher expected the
           UserForm to be valid, but it was invalid instead, producing these
           validation errors:
  
           * nickname: ["is too short (at least 3 characters)"]
  </code></pre>
  
  <p>I'm obviously excepting to make these sorts of validations working.</p>
  
  <p>I hope I can find help here :)</p>