Sha256: 0987985d87e9b434e7e785b653b91c608225e477776e9b9a3ec0f1e6b7ed7856

Contents?: true

Size: 1.29 KB

Versions: 23

Compression:

Stored size: 1.29 KB

Contents

require File.expand_path("../../spec_helper", __FILE__)

describe "Friendly::ScopeProxy" do
  before do
    @klass             = Class.new
    @scope             = stub
    @scope_klass       = stub
    @scope_proxy       = Friendly::ScopeProxy.new(@klass, @scope_klass)
    @params            = {:order! => :created_at.desc}
    @scope_klass.stubs(:new).with(@klass, @params).returns(@scope)
    @klass.stubs(:scope_proxy).returns(@scope_proxy)
    @scope_proxy.add_named(:recent, @params)
  end

  it "returns false for has_named_scope if it doesnt have one by that name" do
    @scope_proxy.should_not be_has_named_scope(:whatever)
  end

  describe "adding a scope" do
    it "adds a scope by that name to the set" do
      @scope_proxy.get(:recent).should == @params
    end

    it "adds a method to the klass that returns an instance of the scope" do
      @klass.recent.should == @scope
    end

    it "returns true for #has_named_scope?(name)" do
      @scope_proxy.should be_has_named_scope(:recent)
    end
  end

  describe "getting an instance of a scope" do
    it "instantiates Scope" do
      @scope_proxy.get_instance(:recent).should == @scope
    end
  end

  describe "accessing an ad_hoc scope" do
    it "instantiates Scope" do
      @scope_proxy.ad_hoc(@params).should == @scope
    end
  end
end

Version data entries

23 entries across 23 versions & 7 rubygems

Version Path
ihoka-friendly-0.8.0.pre spec/unit/scope_proxy_spec.rb
ihoka-friendly-0.7.1.2 spec/unit/scope_proxy_spec.rb
ihoka-friendly-0.7.1.1 spec/unit/scope_proxy_spec.rb
ihoka-friendly-0.7.1 spec/unit/scope_proxy_spec.rb
ihoka-friendly-0.7.0 spec/unit/scope_proxy_spec.rb
friendly-0.6.0 spec/unit/scope_proxy_spec.rb
honkster-friendly-0.5.3 spec/unit/scope_proxy_spec.rb
honkster-friendly-0.5.2 spec/unit/scope_proxy_spec.rb
honkster-friendly-0.5.1 spec/unit/scope_proxy_spec.rb
wayne-friendly-0.5.1 spec/unit/scope_proxy_spec.rb
wego-friendly-0.5.1 spec/unit/scope_proxy_spec.rb
arunthampi-friendly-0.5.1 spec/unit/scope_proxy_spec.rb
friendly_postgres-0.5.1 spec/unit/scope_proxy_spec.rb
friendly-0.5.1 spec/unit/scope_proxy_spec.rb
friendly-0.5.0 spec/unit/scope_proxy_spec.rb
friendly_postgres-0.4.5 spec/unit/scope_proxy_spec.rb
friendly-0.4.5 spec/unit/scope_proxy_spec.rb
friendly-0.4.4 spec/unit/scope_proxy_spec.rb
friendly_postgres-0.4.3 spec/unit/scope_proxy_spec.rb
friendly-0.4.3 spec/unit/scope_proxy_spec.rb