Sha256: 838076021ca9b24cc2729f42db985b5cd013ec523f8177e70ec505d4c4191537

Contents?: true

Size: 667 Bytes

Versions: 11

Compression:

Stored size: 667 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 => { :title => "Sir" } }
      end

    end

  end

end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
mongoid-locomotive-2.0.0.beta9 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-pre-2.0.0.beta1 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-2.0.0.alpha spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.2.14 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.2.13 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.2.12 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.2.11 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.2.10 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.2.9 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.2.8 spec/unit/mongoid/extensions/proc/scoping_spec.rb
mongoid-1.2.7 spec/unit/mongoid/extensions/proc/scoping_spec.rb