Skip to content

validate_length_of undefined method `to_allow' #210

Open
@dks17

Description

@dks17

I have:

class User
  include Mongoid::Document

  field  :name, type: String

  validates_length_of :name, in: 1..100, allow_nil: true
end
require 'rails_helper'

RSpec.describe User, type: :model do
    it { is_expected.to validate_length_of(:name).within(1..100).to_allow(nil: true) }
end

and caught the error:

Failure/Error: it { is_expected.to validate_length_of(:name).within(1..100).to_allow(nil: true) }
     NoMethodError:
       undefined method `to_allow' for #<Mongoid::Matchers::Validations::ValidateLengthOfMatcher:0x000055f3d7c01158>
       Did you mean?  to_yaml

Did I make something wrong or it is a bug?
Rails validates_length_of validator.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions