Sha256: e4217db5408a382ec51fb8f2e2c6210d530f4cfe814051e887d997cfb131c255

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

require 'helper'

describe Plucky do
  describe ".to_object_id" do
    before do
      @id = BSON::ObjectId.new
    end

    it "converts nil to nil" do
      Plucky.to_object_id(nil).should be_nil
    end

    it "converts blank to nil" do
      Plucky.to_object_id('').should be_nil
    end

    it "leaves object id alone" do
      Plucky.to_object_id(@id).should equal(@id)
    end

    it "converts string to object id" do
      Plucky.to_object_id(@id.to_s).should == @id
    end

    it "not convert string that is not legal object id" do
      Plucky.to_object_id('foo').should == 'foo'
      Plucky.to_object_id(1).should == 1
    end
  end

  describe ".modifier?" do
    context "with a string" do
      it "returns true if modifier" do
        Plucky.modifier?('$in').should == true
      end

      it "returns false if not modifier" do
        Plucky.modifier?('nope').should == false
      end
    end

    context "with a symbol" do
      it "returns true if modifier" do
        Plucky.modifier?(:$in).should == true
      end

      it "returns false if not modifier" do
        Plucky.modifier?(:nope).should == false
      end
    end
  end

  describe "::Methods" do
    it "returns array of methods" do
      Plucky::Methods.should == [
        :where, :filter,
        :sort, :order, :reverse,
        :paginate, :per_page, :limit, :skip, :offset,
        :fields, :projection, :ignore, :only,
        :each, :find_each, :find_one, :find,
        :count, :size, :distinct,
        :last, :first, :all, :to_a,
        :exists?, :exist?, :empty?,
        :remove,
      ].sort_by(&:to_s)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
plucky-0.8.0 spec/plucky_spec.rb