Sha256: 6b978e4a29a0532e8d513cdfb2307ee07dd74455d9252c7fd0294ab49b9d21be

Contents?: true

Size: 926 Bytes

Versions: 1

Compression:

Stored size: 926 Bytes

Contents

require 'fake_sqs/collection_view'

describe FakeSQS::CollectionView do

  def wrap(collection)
    FakeSQS::CollectionView.new(collection)
  end

  it 'should correctly wrap an array' do
    array = %w{one two three four}
    view = wrap(array)
    view[0].should == 'one'
    view[1].should == 'two'
    view[2].should == 'three'
    view[3].should == 'four'
  end

  it 'should correctly wrap a hash' do
    hash = { :one => 1, :two => 2, :three => 3 }
    view = wrap(hash)
    view[:one].should == 1
    view[:two].should == 2
    view[:three].should == 3
  end

  it 'should respond to empty correctly' do
    wrap([]).should be_empty
    wrap({'one' => 1}).should_not be_empty
  end

  it 'should be enumerable' do
    result = wrap([1, 2, 3]).map { |i| i * i }
    result.should == [1, 4, 9]
  end

  it 'should respond to size/length' do
    wrap([1, 2, 3]).size.should == 3
    wrap([]).length.should == 0
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fake_sqs-0.1.0 spec/unit/collection_view_spec.rb