Sha256: 85aa5091ecc172688c38b188bd352b56f0a790e027ab22e9f1b17c8cbb42545e

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'

describe "LudicrousSpeed" do
  it 'has a really cool finder' do
    Foo.should.respond_to :name_yield_or
  end

  it 'has a really cool named finder' do
    Foo.should.respond_to :bar
  end

  it 'has a really cool finder definitions' do
    Foo.should.respond_to :definitions
  end

  it 'will have bar and it will find _why\'s bacon' do
    Foo.definitions[:bar].call.should == {:conditions => "_why = 'bacon'"}
  end

  it 'has conditions that get scoped' do
    Foo.send( :scoped_methods ).should.be.empty?
    
    Foo.bar do
      Foo.send( :scoped_methods ).should == [ { :find => {:conditions => "_why = 'bacon'"} } ]
      Foo.send( :current_scoped_methods ).should == { :find => {:conditions => "_why = 'bacon'"} }
    end

    Foo.send( :scoped_methods ).should.be.empty?
  end
  
  it 'like params in the name yield or scopes as well' do
    should.not.raise  { Foo.omg( '_why', 1 ) }
  end
  
  
  it 'can do nesting with ease' do
    Foo.send( :scoped_methods ).should.be.empty?
    
    Foo.omg( 'name', 6 ) do
      Foo.send( :scoped_methods ).should == [ { :find => {:conditions => "name != 6"} } ]
      Foo.send( :current_scoped_methods ).should == { :find => {:conditions => "name != 6"} }

      Foo.bar do
        Foo.send( :scoped_methods ).should == [{:find=>{:conditions=>"name != 6"}}, {:find=>{:conditions=>"(name != 6) AND (_why = 'bacon')"}}]
        Foo.send( :current_scoped_methods ).should == {:find=>{:conditions=>"(name != 6) AND (_why = 'bacon')"}}
      end

      Foo.send( :scoped_methods ).should == [ { :find => {:conditions => "name != 6"} } ]
      Foo.send( :current_scoped_methods ).should == { :find => {:conditions => "name != 6"} }
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cajun-ludicrous_speed-0.0.0 spec/ludicrous_speed_spec.rb