Sha256: 7b7578f0070301ad6061a3d5469ad7d86ad45754dc6c15c95471db6417123be3

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

require 'helper'

class PluckyTest < Test::Unit::TestCase
  context "Plucky" do
    context ".to_object_id" do
      setup do
        @id = BSON::ObjectId.new
      end

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

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

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

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

      should "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

    context "::Methods" do
      should "return 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
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
plucky-0.5.2 test/test_plucky.rb
plucky-0.5.1 test/test_plucky.rb
plucky-0.5.0 test/test_plucky.rb