Sha256: 250d0d0dfddda8513be5ed6698831d88216d823d550d8096fae1033d17cfab7d

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe Spec::Rails::Matchers do
  
  describe 'validations' do
    
    before :all do
      class CouchFoo < CouchRestRails::Document  
        
        property  :something_present
        property  :something_long
        property  :something_formatted
        property  :something_numeric
        
        validates_presence_of     :something_present
        validates_length_of       :something_long, :minimum => 10, :maximum => 50
        validates_format_of       :something_formatted, :with => /[A-Z]{3}-[0-9]{3}/
        validates_numericality_of :something_numeric

      end
      @couch_foo = CouchFoo.new
    end
    
    # Use lengthy matcher names so as not to interfere with 
    # rspec-on-rails-matchers plugin if present
    
    it "should have a matcher for validates_presence_of" do
      @couch_foo.should validate_couchdb_document_presence_of(:something_present)
    end
    
    it "should have a matcher for validates_numericality_of" do
      @couch_foo.should validate_couchdb_document_numericality_of(:something_numeric)
    end
    
    it "should have a matcher for validates_format_of" do
      @couch_foo.should validate_couchdb_document_format_of(:something_formatted, :with => /[A-Z]{3}-[0-9]{3}/)
    end
    
    it "should have a matcher for validates_length_of" do
      @couch_foo.should validate_couchdb_document_length_of(:something_long, :minimum => 10, :maximum => 50)
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
therealadam-couchrest-rails-0.1.1 spec/matchers/couch_document_validations_spec.rb