Sha256: 127cb59e7317f98cb456ffc182b5b74d9916acc064427427997272ee58ee9da8
Contents?: true
Size: 1.35 KB
Versions: 30
Compression:
Stored size: 1.35 KB
Contents
require File.expand_path(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 "#type" do before do @field = Mongoid::Field.new(:name) end it "defaults to String" do @field.type.should == String end end describe "#set" do before do @type = mock @field = Mongoid::Field.new(:score, :default => 10, :type => @type) end context "nil is provided" do it "returns the default value" do @field.set(nil).should == 10 end end context "value is provided" do it "sets the value" do @type.expects(:set).with("30").returns(30) @field.set("30").should == 30 end end end describe "#get" do before do @type = mock @field = Mongoid::Field.new(:score, :default => 10, :type => @type) end it "returns the value" do @type.expects(:get).with(30).returns(30) @field.get(30).should == 30 end end end
Version data entries
30 entries across 30 versions & 1 rubygems