Sha256: e42e9e76a0ff2f0d1dc73a734170f338a28ecd0edb58a1fad51e827d8a07be4a
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
module Spec module Rails module Matchers def validate_couchdb_document_format_of(attribute, options) return simple_matcher("document model to validate format of :#{attribute} with #{options[:with]}") do |model| model.send("#{attribute}=", nil) !model.valid? && model.errors.on(attribute) end end def validate_couchdb_document_length_of(attribute, options) return simple_matcher("document model to validate length of :#{attribute} within #{options[:maximum] || 0} to #{options[:minimum] || 'infinity'}") do |model| if options[:within] model.send("#{attribute}=", 'x' * (options[:within].last + 1)) else if options[:maximum] model.send("#{attribute}=", 'x' * (options[:maximum] + 1)) else model.send("#{attribute}=", 'x' * (options[:minimum] - 1)) end end !model.valid? && model.errors.on(attribute) end end def validate_couchdb_document_presence_of(attribute) return simple_matcher("document model to validate presence of :#{attribute}") do |model| model.send("#{attribute}=", nil) !model.valid? && model.errors.on(attribute) end end def validate_couchdb_document_numericality_of(attribute) return simple_matcher("document model to validate numericality of :#{attribute}") do |model| model.send("#{attribute}=", 'x') !model.valid? && model.errors.on(attribute) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
therealadam-couchrest-rails-0.1.1 | lib/spec/rails/matchers/couch_document_validations.rb |