Sha256: a0edd4800e3416e24b02c20f3f11cf28d3deaef9e56b2427f36adc923495a173

Contents?: true

Size: 714 Bytes

Versions: 18

Compression:

Stored size: 714 Bytes

Contents

require "spec_helper"

describe Mongoid::Extensions::Proc::Scoping do

  describe "#scoped" do

    context "when the proc accessed a hash" do

      before do
        @proc = lambda { |number| { :where => { :count => number } } }
      end

      it "calls the hash with the args" do
        @proc.scoped(10).should == { :where => { :count => 10 } }
      end

    end

    context "when the proc calls a criteria" do

      before do
        @proc = lambda { |title| Person.where(:title => title) }
      end

      it "returns the criteria scoped" do
        @proc.scoped("Sir").should ==
          { :where => { :_type => { "$in" => [ "Doctor", "Person" ] }, :title => "Sir" } }
      end

    end

  end

end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
mongoid-pre-2.0.0.pre spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.2.6 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.2.5 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.2.4 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.2.3 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.2.2 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.2.1 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.2.0 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.1.4 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.1.3 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.1.2 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.1.1 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.1.0 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.0.6 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.0.5 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.0.4 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.0.3 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.0.2 spec/unit/mongoid/extensions/proc/scoping_spec.rb