Sha256: 9b9794b3c217eed6faac1c931f9cffc55e2b786ef3c4dffb8ddf71e5d3971e9b

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

# -*- encoding : utf-8 -*-
require 'acceptance/spec_helper'

describe 'Indices' do
  let(:database) { DATABASE }
  subject { database['documenttest'] }
  let(:index) { subject.add_index(:skiplist, on: [:identifier]) }

  it 'should accept a single attribute' do
    single_attr_index = subject.add_index(:hash, on: :identifier)
    expect(single_attr_index.on).to eq [:identifier]
  end

  it 'should be possible to set indices' do
    index.delete

    expect {
      subject.add_index :skiplist, on: [:identifier]
    }.to change { subject.indices.length }.by(1)
  end

  it 'should be possible to get an index by ID' do
    # This is temporary until Index has a key
    index_key = index.id.split('/')[1]

    expect(subject.index(index_key).id).to eq(index.id)
    expect(subject.indices[0].class).to eq(Ashikawa::Core::Index)
  end

  it 'should be possible to create an unique index' do
    index = subject.add_index :skiplist, on: [:identifier], unique: true

    expect(index.unique).to be_truthy
  end

  it 'should be possible to remove indices' do
    skip 'See Bug #34'

    expect {
      index.delete
      sleep(1) # from time to time it may fail because of threading
    }.to change { subject.indices.length }.by(-1)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ashikawa-core-0.14.0 spec/acceptance/index_spec.rb
ashikawa-core-0.13.1 spec/acceptance/index_spec.rb
ashikawa-core-0.13.0 spec/acceptance/index_spec.rb
ashikawa-core-0.12.0 spec/acceptance/index_spec.rb