Sha256: e4f5761f3e758c3a05149b103b3f44160956989c910632e52babc3398c9e1a17

Contents?: true

Size: 1.58 KB

Versions: 7

Compression:

Stored size: 1.58 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 be_true
      end

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

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

      it "returns false if not modifier" do
        Plucky.modifier?(:nope).should be_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, :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

7 entries across 7 versions & 1 rubygems

Version Path
plucky-0.6.6 spec/plucky_spec.rb
plucky-0.6.5 spec/plucky_spec.rb
plucky-0.6.4 spec/plucky_spec.rb
plucky-0.6.3 spec/plucky_spec.rb
plucky-0.6.2 spec/plucky_spec.rb
plucky-0.6.1 spec/plucky_spec.rb
plucky-0.6.0 spec/plucky_spec.rb