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