RSpec in Parse-Resource
BluesChow opened this issue · 2 comments
Hi guys,
your parse-resource is pretty good,I like it.
and I have found that it is like ActiveRecord,but it is NOT ActiveRecord,and when I use RSpec to test user model,I found some validates can not be used.
fox example:If I use validate like this user model:
validates :username, presence:true, format: { with: VALID_EMAIL_REGEX }, uniqueness:true
it will give me a error,it said that .rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.13/lib/active_model/validations/validates.rb:96:in `rescue in block in validates': Unknown validator: 'UniquenessValidator' (ArgumentError)
so if I want to use RSpec to test,how should I test user model's uniqueness?
Thanks in advance!
Blues
Check out this stackoverflow post to fix this:
http://stackoverflow.com/questions/13892107/cannot-validate-uniqueness-in-tableless-class
The issue I'm having is clearing Parse after every test.
uniqueness validation is an ActiveRecord specific type of validation. If you want to use that type of validation within a non-AR class you will most likely need to roll your own validator that simulates the same behavior