Sha256: 0e5c64af77e7aa59ac9a7d672f736e003b083c1df922b88aa6c7e5c1e1e94e77

Contents?: true

Size: 848 Bytes

Versions: 8

Compression:

Stored size: 848 Bytes

Contents

require File.join(File.dirname(__FILE__), "/../../spec_helper.rb")

describe Mongoid::Field do

  describe "#default" do

    before do
      @field = Mongoid::Field.new(:score, :default => 0)
    end

    it "returns the default option" do
      @field.default.should == 0
    end

  end

  describe "#name" do

    before do
      @field = Mongoid::Field.new(:score, :default => 0)
    end

    it "returns the name" do
      @field.name.should == :score
    end

  end

  describe "#value" do

    before do
      @field = Mongoid::Field.new(:score, :default => 10)
    end

    context "nil is provided" do

      it "returns the default value" do
        @field.value(nil).should == 10
      end

    end

    context "value is provided" do

      it "returns the value" do
        @field.value(30).should == 30
      end

    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mongoid-0.5.2 spec/unit/mongoid/field_spec.rb
mongoid-0.5.1 spec/unit/mongoid/field_spec.rb
mongoid-0.5.0 spec/unit/mongoid/field_spec.rb
mongoid-0.4.8 spec/unit/mongoid/field_spec.rb
mongoid-0.4.7 spec/unit/mongoid/field_spec.rb
mongoid-0.4.5 spec/unit/mongoid/field_spec.rb
mongoid-0.4.4 spec/unit/mongoid/field_spec.rb
mongoid-0.4.3 spec/unit/mongoid/field_spec.rb