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