Sha256: 53563897bd989a2f0d797f64e4cfeebb5bf88bfef34930c15a02e3db152138da

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

describe '#all' do
  before do
    class SelectionDocument
      include Yapper::Document

      field :field1
      field :field2
    end
    class AnotherSelectionDocument
      include Yapper::Document

      field :field1
      field :field2
    end
  end
  before { Yapper::DB.instance.purge }
  after { Object.send(:remove_const, 'SelectionDocument') }
  after { Object.send(:remove_const, 'AnotherSelectionDocument') }

  describe 'with no documents created' do
    it 'returns []' do
      SelectionDocument.all.should == []
    end
  end

  describe 'with a few documents created with string fields' do
    before do
      @doc = SelectionDocument.create(:field1 => 'field1_value', :field2 => 'field2_value')
      SelectionDocument.create(:field1 => 'field1_value', :field2 => 'field2_value')
      SelectionDocument.create(:field1 => 'field1_value', :field2 => 'field2_other_value')
      SelectionDocument.create(:field1 => 'field1_other_value', :field2 => 'field2_other_value')
      AnotherSelectionDocument.create(:field1 => 'field1_value', :field2 => 'field2_value')
    end

    it 'returns all documents' do
      SelectionDocument.all.count.should == 4
      SelectionDocument.all.all? { |doc| doc.class.should == SelectionDocument }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
motion-yapper-0.0.1 spec/integration/all_spec.rb