Sha256: 4110f1e08eb1021ceb420057f025d0d2268a46050c4f44149b1fda0931f90bf2

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 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, :limit, :skip, :offset, :sort, :order,
          :fields, :ignore, :only,
          :each, :find_each,
          :count, :size, :distinct,
          :last, :first, :all, :paginate,
          :exists?, :exist?, :empty?,
          :to_a, :remove,
        ]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
plucky-0.4.4 test/test_plucky.rb
plucky-0.4.3 test/test_plucky.rb
plucky-0.4.2 test/test_plucky.rb
plucky-0.4.1 test/test_plucky.rb