Sha256: 29793277e6e18ec61104202973484c364107a56ef3ba57533f8d1fc7a4133e2d

Contents?: true

Size: 1.26 KB

Versions: 11

Compression:

Stored size: 1.26 KB

Contents

# -*- coding: utf-8 -*-
require 'spec_helper'
require 'gemirro/http'
require 'gemirro/source'

# Source tests
module Gemirro
  describe 'Source' do
    before(:each) do
      @source = Source.new('RubyGems', 'https://rubygems.org')
    end

    it 'should be initialized' do
      expect(@source.name).to eq('rubygems')
      expect(@source.host).to eq('https://rubygems.org')
      expect(@source.gems).to eq([])
    end

    it 'should fetch versions' do
      Struct.new('FetchVersions', :body)
      result = Struct::FetchVersions.new(true)
      allow(Http).to receive(:get).once.with(
        "https://rubygems.org/#{Configuration.versions_file}"
      ).and_return(result)
      expect(@source.fetch_versions).to be_truthy
    end

    it 'should fetch gem' do
      Struct.new('FetchGem', :body)
      result = Struct::FetchGem.new(true)
      allow(Http).to receive(:get).once.with(
        'https://rubygems.org/gems/gemirro-0.0.1.gem').and_return(result)
      expect(@source.fetch_gem('gemirro', '0.0.1')).to be_truthy
    end

    it 'should add gems' do
      expect(@source.gems).to eq([])
      @source.gem('gemirro')
      result = @source.gems
      expect(result[0].name).to eq('gemirro')
      expect(result[0].requirement).to be_a(::Gem::Requirement)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
gemirro-0.10.5 spec/gemirro/source_spec.rb
gemirro-0.10.4 spec/gemirro/source_spec.rb
gemirro-0.10.3 spec/gemirro/source_spec.rb
gemirro-0.10.2 spec/gemirro/source_spec.rb
gemirro-0.10.1 spec/gemirro/source_spec.rb
gemirro-0.10.0 spec/gemirro/source_spec.rb
gemirro-0.9.1 spec/gemirro/source_spec.rb
gemirro-0.9.0 spec/gemirro/source_spec.rb
gemirro-0.8.1 spec/gemirro/source_spec.rb
gemirro-0.8.0 spec/gemirro/source_spec.rb
gemirro-0.7.0 spec/gemirro/source_spec.rb