Sha256: 8065c9da21a4542285f0b674d2c7c501d0be9903905c143e7d20527a194a5ee2

Contents?: true

Size: 1.68 KB

Versions: 22

Compression:

Stored size: 1.68 KB

Contents

require_relative './spec_helper'

describe Groovy do
  before :each do
    Groonga::Context.default = nil
  end

  describe '.open' do
    it 'explodes if called with no params' do
      expect do
        Groovy.open
      end.to raise_error(ArgumentError)
    end

    it 'explodes if called with nil db_path' do
      expect do
        Groovy.open(nil)
      end.to raise_error(ArgumentError)
    end

    context 'if no context given' do
      it 'sets up database for default context' do
        expect(Groonga::Context.default.database).to be_nil
        Groovy.open('tmp/foo1')
        expect(Groonga::Context.default.database).to be_a(Groonga::Database)
        Groovy.close # default
      end
    end

    context 'if context given' do
      it 'sets up database for default context' do
        expect(Groonga::Context.default.database).to be_nil
        Groovy.open('tmp/foo2', :test)
        expect(Groonga::Context.default.database).to be_nil

        expect(Groovy['test']).to be_a(Groonga::Context)
        expect(Groovy[:test].database).to be_a(Groonga::Database)

        Groovy.close(:test)
      end
    end
  end

  describe '.close' do
    it 'thows if not opened (default)' do
      expect { Groovy.close }.to raise_error(Groovy::ContextNotFound)
    end

    it 'thows if context does not exist' do
      expect { Groovy.close(:foo) }.to raise_error(Groovy::ContextNotFound)
    end

    it 'thows if already closed' do
      Groovy.open('tmp/foo')
      Groovy.close
      expect do
        Groovy.close
      end.to raise_error(Groovy::ContextNotFound)
    end

    it 'works if ctx exists and open' do
      Groovy.open('tmp/foo', :test)
      expect(Groovy.close(:test)).to eq(nil)
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
groovy-0.5.1 spec/groovy_spec.rb
groovy-0.5.0 spec/groovy_spec.rb
groovy-0.4.7 spec/groovy_spec.rb
groovy-0.4.6 spec/groovy_spec.rb
groovy-0.4.5 spec/groovy_spec.rb
groovy-0.4.4 spec/groovy_spec.rb
groovy-0.4.3 spec/groovy_spec.rb
groovy-0.4.2 spec/groovy_spec.rb
groovy-0.4.1 spec/groovy_spec.rb
groovy-0.4.0 spec/groovy_spec.rb
groovy-0.3.0 spec/groovy_spec.rb
groovy-0.2.9 spec/groovy_spec.rb
groovy-0.2.8 spec/groovy_spec.rb
groovy-0.2.7 spec/groovy_spec.rb
groovy-0.2.6 spec/groovy_spec.rb
groovy-0.2.5 spec/groovy_spec.rb
groovy-0.2.3 spec/groovy_spec.rb
groovy-0.2.2 spec/groovy_spec.rb
groovy-0.2.1 spec/groovy_spec.rb
groovy-0.2.0 spec/groovy_spec.rb