Sha256: bfa3907ee812acebfa7dd147d9f3c24cdbc417167ced618e4e6c72b7f7fc03ed

Contents?: true

Size: 1.48 KB

Versions: 8

Compression:

Stored size: 1.48 KB

Contents

require "spec_helper"

describe Mongoid::Extras do

  before do
    @klass = Class.new do
      include Mongoid::Extras
    end
  end

  describe ".cache" do

    before do
      @klass.cache
    end

    it "sets the cached boolean on the class" do
      @klass.cached.should be_true
    end

  end

  describe ".cached?" do

    context "when the class is cached" do

      before do
        @klass.cache
      end

      it "returns true" do
        @klass.should be_cached
      end
    end

    context "when the class is not cached" do

      it "returns false" do
        @klass.should_not be_cached
      end
    end

  end

  describe "#cached?" do

    before do
      @klass.cache
      @doc = @klass.new
    end

    it "returns the class cached? value" do
      @doc.should be_cached
    end
  end

  describe ".enslave" do

    before do
      @klass.enslave
    end

    it "sets the enslaved boolean on the class" do
      @klass.enslaved.should be_true
    end

  end

  describe ".enslaved?" do

    context "when the class is enslaved" do

      before do
        @klass.enslave
      end

      it "returns true" do
        @klass.should be_enslaved
      end
    end

    context "when the class is not enslaved" do

      it "returns false" do
        @klass.should_not be_enslaved
      end
    end

  end

  describe "#enslaved?" do

    before do
      @klass.enslave
      @doc = @klass.new
    end

    it "returns the class enslaved? value" do
      @doc.should be_enslaved
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
mongoid-locomotive-2.0.0.beta9 spec/unit/mongoid/extras_spec.rb
mongoid-pre-2.0.0.beta1 spec/unit/mongoid/extras_spec.rb
mongoid-2.0.0.alpha spec/unit/mongoid/extras_spec.rb
mongoid-1.2.14 spec/unit/mongoid/extras_spec.rb
mongoid-1.2.13 spec/unit/mongoid/extras_spec.rb
mongoid-1.2.12 spec/unit/mongoid/extras_spec.rb
mongoid-1.2.11 spec/unit/mongoid/extras_spec.rb
mongoid-1.2.10 spec/unit/mongoid/extras_spec.rb