Sha256: b9a0720ada8ec9f5fea9c073290b2af014c9ed3dc3e08c0bca97759d09fe8668

Contents?: true

Size: 614 Bytes

Versions: 2

Compression:

Stored size: 614 Bytes

Contents

require 'spec_helper'

describe MongoDoc::Validations do

  class ValidationTest
    include MongoDoc::Document

    attr_accessor :data
    validates_presence_of :data
  end

  context "requirements" do
    subject { ValidationTest.new }

    it { should respond_to(:valid?) }
    it { should respond_to(:errors) }

    it "is included by Document" do
      MongoDoc::Validations.should === subject
    end
  end

  context "validations" do
    it "valid? fails when a document is invalid" do
      doc = ValidationTest.new
      doc.should_not be_valid
      doc.should have(1).error_on(:data)
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
mongo_doc_rails2-0.6.1 spec/validations_spec.rb
mongo_doc-0.5.5 spec/validations_spec.rb