Sha256: f03f75bf337af6331f5e2ebf22fde7dcdac04b091d47b9e779a4513f9cdcd7db

Contents?: true

Size: 947 Bytes

Versions: 3

Compression:

Stored size: 947 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "Dynamoid::Criteria" do
  
  before do
    @user1 = User.create(:name => 'Josh', :email => 'josh@joshsymonds.com')
    @user2 = User.create(:name => 'Justin', :email => 'justin@joshsymonds.com')
  end
  
  it 'finds first using where' do
    User.where(:name => 'Josh').first.should == @user1
  end
  
  it 'finds all using where' do
    User.where(:name => 'Josh').all.should == [@user1]
  end
  
  it 'returns all records' do
    User.all.should =~ [@user1, @user2]
    User.all.first.new_record.should be_false
  end
  
  it 'returns empty attributes for where' do
    Magazine.where(:name => 'Josh').all.should == []
  end
  
  it 'returns empty attributes for all' do
    Magazine.all.should == []
  end
  
  it 'passes each to all members' do
    User.each do |u|
      u.id.should == @user1.id || @user2.id
      u.new_record.should be_false
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dynamoid-0.3.2 spec/dynamoid/criteria_spec.rb
dynamoid-0.3.1 spec/dynamoid/criteria_spec.rb
dynamoid-0.3.0 spec/dynamoid/criteria_spec.rb