Sha256: 87bbb79c980a7bf6ded5d0bda078d91b963af3bf907d9acf5c483cf127521af9

Contents?: true

Size: 1.24 KB

Versions: 8

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

describe WialonApi::Namespace do
  describe '.names' do
    before(:each) do
      WialonApi::Namespace.instance_variable_set(:@names, nil)
    end

    context 'on first call' do
      it 'loads namespaces from a file' do
        filename = double('Filename')
        expect(File).to receive(:expand_path).and_return(filename)
        namespaces = double('Namespaces list')
        expect(YAML).to receive(:load_file).with(filename).and_return(namespaces)

        WialonApi::Namespace.names
      end
    end

    context 'on subsequent calls' do
      before(:each) do
        WialonApi::Namespace.names
      end

      it 'returns the cached list' do
        expect(YAML).not_to receive(:load_file)
        WialonApi::Namespace.names
      end
    end
  end

  describe '.exists?' do
    context 'with an existing namespace' do
      it 'returns true' do
        expect(WialonApi::Namespace).to exist('core')
      end
    end

    context 'with a non-existent namespace' do
      it 'returns false' do
        expect(WialonApi::Namespace).not_to exist('wrong')
      end
    end

    context 'with an existing symbol namespace' do
      it 'returns true' do
        expect(WialonApi::Namespace).to exist(:user)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wialon_api-0.0.8 spec/wialon_api/namespace_spec.rb
wialon_api-0.0.7 spec/wialon_api/namespace_spec.rb
wialon_api-0.0.6 spec/wialon_api/namespace_spec.rb
wialon_api-0.0.5 spec/wialon_api/namespace_spec.rb
wialon_api-0.0.4 spec/wialon_api/namespace_spec.rb
wialon_api-0.0.3 spec/wialon_api/namespace_spec.rb
wialon_api-0.0.2 spec/wialon_api/namespace_spec.rb
wialon_api-0.0.1 spec/wialon_api/namespace_spec.rb