Sha256: 78df000819bc32169cc1f6ec9177b1657638a2bc0038221411a07d3662f4f98f

Contents?: true

Size: 1.47 KB

Versions: 21

Compression:

Stored size: 1.47 KB

Contents

require 'kontena/plugin_manager/rubygems_client'
require 'json'

describe Kontena::PluginManager::RubygemsClient do
  let(:subject) { described_class.new }
  let(:client) { double }

  before(:each) do
    allow(subject).to receive(:client).and_return(client)
  end

  context '#search' do
    it 'searches rubygems and returns a hash' do
      expect(client)
        .to receive(:get)
        .with(
          hash_including(
            path: "/api/v1/search.json?query=foofoo",
            headers: hash_including(
              'Content-Type' => 'application/json',
              'Accept' => 'application/json'
            )
          )
        )
        .and_return(double(body: JSON.dump(foo: 'bar')))
      expect(subject.search('foofoo')['foo']).to eq 'bar'
    end
  end

  context '#versions' do
    it 'fetches version list from rubygems and returns an array of Gem::Versions' do
      expect(client)
        .to receive(:get)
        .with(
          hash_including(
            path: "/api/v1/versions/foofoo.json",
            headers: hash_including(
              'Content-Type' => 'application/json',
              'Accept' => 'application/json'
            )
          )
        )
        .and_return(double(body: JSON.dump([{'number' => '0.1.0'}, {'number' => '0.2.0'}])))
      versions = subject.versions('foofoo')
      expect(versions.first).to be_kind_of Gem::Version
      expect(versions.first.to_s).to eq '0.2.0'
      expect(versions.last.to_s).to eq '0.1.0'
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
kontena-cli-1.3.5 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.3.5.rc1 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.4.0.pre6 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.4.0.pre5 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.4.0.pre4 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.4.0.pre3 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.4.0.pre2 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.4.0.pre1 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.3.4 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.3.4.rc1 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.3.3 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.3.3.rc1 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.3.2 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.3.2.rc2 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.3.2.rc1 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.3.1 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.3.1.rc2 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.3.1.rc1 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.3.0 spec/kontena/plugin_manager/rubygems_client_spec.rb
kontena-cli-1.3.0.rc4 spec/kontena/plugin_manager/rubygems_client_spec.rb