mongoid / mongoid-rspec

RSpec matchers and macros for Mongoid.
MIT License
498 stars 177 forks source link

validate_length_of undefined method `to_allow' #210

Open dks17 opened 6 years ago

dks17 commented 6 years ago

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.

dblock commented 6 years ago

Maybe just not implemented?

dks17 commented 6 years ago

Yes. I checked code of the gem. Looks like is not implemented. This issue should be closed or labelled as new feature.

dblock commented 6 years ago

Reopened and relabeled.