Sha256: e5b29043a456c00b7624d2eba0ebfc87615896b760a2d766867de1b0c4d1d6aa

Contents?: true

Size: 972 Bytes

Versions: 1

Compression:

Stored size: 972 Bytes

Contents

module CDQ

  describe "CDQ Magic Method" do

    before do
      class << Author
        include CDQ
      end

      class << self
        include CDQ
      end
    end

    it "wraps an NSManagedObject class in a CDQTargetedQuery" do
      cdq(Author).class.should == CDQTargetedQuery
    end

    it "treats a string as an entity name and returns a CDQTargetedQuery" do
      cdq('Author').class.should == CDQTargetedQuery
    end

    it "treats a symbol as an attribute key and returns a CDQPartialPredicate" do
      cdq(:name).class.should == CDQPartialPredicate
    end

    it "passes through existing CDQObjects unchanged" do
      query = CDQQuery.new 
      cdq(query).should == query
    end

    it "uses 'self' if no object passed in" do
      Author.cdq.class.should == CDQTargetedQuery
    end

    it "works with entities that do not have a specific implementation class" do
      cdq('Publisher').class.should == CDQTargetedQuery
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cdq-0.1.1 spec/cdq/module_spec.rb