Sha256: 09662c4943e23d84cdb751a1f147fc8cd67cca53c4cd8fbab069a5511ddfb460

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require File.join(File.dirname(__FILE__),'teststrap')

context "has_field macro" do
  setup do
    mock_model do
      field :name, :type => String
      field :rad,  :type => Boolean, :default => false
    end
  end
  asserts "passes when the field options are specified" do
    RiotMongoid::HasFieldAssertion.new.evaluate(topic, :name, :type => String).first
  end.equals(:pass)

  asserts "returns useful message" do
    RiotMongoid::HasFieldAssertion.new.evaluate(topic, :name, :type => String).last
  end.matches(/Class has field :name with options \{:type=>String\}/)

  asserts "fails when invalid field options are specified" do
    RiotMongoid::HasFieldAssertion.new.evaluate(topic, :name, :type => Date).first
  end.equals(:fail)

  asserts "passes with a slightly more complex field setup" do
    RiotMongoid::HasFieldAssertion.new.evaluate(topic, :rad, :type => Boolean, :default => false).first
  end.equals(:pass)

  asserts "fails with a slightly more complex field setup and a bad assertion" do
    RiotMongoid::HasFieldAssertion.new.evaluate(topic, :rad, :type => Boolean, :default => true).first
  end.equals(:fail)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
riot-mongoid-2.1.0 test/has_field_test.rb