Sha256: ad682fee4c01580736506cc61825100e0f54976601b79bc69785a620354c6ceb

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

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

describe "Dynamoid::Attributes" do

  before do
    @address = Address.create
    @original_id = @address.id
  end

  it 'should write an attribute correctly' do
    @address.write_attribute(:city, 'Chicago')
  end
  
  it 'should write an attribute with the alias' do
    @address[:city] = 'Chicago'
  end
  
  it 'should read a written attribute' do
    @address.write_attribute(:city, 'Chicago')
    @address.read_attribute(:city).should == 'Chicago'
  end
  
  it 'should read a written attribute with the alias' do
    @address.write_attribute(:city, 'Chicago')
    @address[:city].should == 'Chicago'
  end
  
  it 'should update all attributes' do
    @address.expects(:save).once.returns(true)
    @address.update_attributes(:city => 'Chicago')
    @address[:city].should == 'Chicago'
    @address.id.should == @original_id
  end
  
  it 'should update one attribute' do
    @address.expects(:save).once.returns(true)
    @address.update_attribute(:city, 'Chicago')
    @address[:city].should == 'Chicago'
    @address.id.should == @original_id
  end
  
  it 'returns all attributes' do
    Address.attributes.should == [:id, :city]
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dynamoid-0.1.1 spec/dynamoid/attributes_spec.rb
dynamoid-0.1.0 spec/dynamoid/attributes_spec.rb