Sha256: 3662cbccad6cd16ef0fcdf1c1a85c3893bdb689feda0bd809d2090e5f6edf146

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 KB

Contents

require 'rspec'
require 'travis_check_rubies/travis_index'

describe TravisCheckRubies::TravisIndex do
  describe '#base_url' do
    before do
      allow(ENV).to receive(:[]).with('TRAVIS').and_return(env_travis)
    end

    context 'when env variable TRAVIS is set' do
      let(:env_travis){ 'true' }

      it 'gets base_url from rvm debug' do

        allow(subject).to receive(:`).with('rvm debug').
          and_return(%Q{  foo: "xxx"  \n  system: "XXX/YYY"  \n  bar: "yyy"  })

        expect(subject.send(:base_url)).to eq('https://rubies.travis-ci.org/XXX/YYY/')
      end
    end

    context 'when env variable TRAVIS is not set' do
      let(:env_travis){ nil }

      it 'gets base_url from first ubuntu url in index' do
        allow(subject).to receive(:index_urls).and_return(%w[
          https://rubies.travis-ci.org/osx/AAA/1.tar.gz
          https://rubies.travis-ci.org/ubuntu/ZZZ/2.tar.gz
          https://rubies.travis-ci.org/ubuntu/BBB/3.tar.gz
        ])

        expect(subject.send(:base_url)).to eq('https://rubies.travis-ci.org/ubuntu/BBB/')
      end
    end
  end

  describe '#version_strings' do
    it 'gets versions from index urls matching base_url' do
      allow(subject).to receive(:index_urls).and_return(%w[
        https://rubies.travis-ci.org/osx/AAA/1.tar.gz
        https://rubies.travis-ci.org/ubuntu/ZZZ/2.tar.gz
        https://rubies.travis-ci.org/ubuntu/BBB/4.tar.gz
        https://rubies.travis-ci.org/ubuntu/BBB/3.tar.bz2
      ])
      allow(subject).to receive(:base_url).and_return('https://rubies.travis-ci.org/ubuntu/BBB/')

      expect(subject.version_strings).to match_array(%w[3 4])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
travis_check_rubies-0.5.1 spec/travis_check_rubies/travis_index_spec.rb
travis_check_rubies-0.5.0 spec/travis_check_rubies/travis_index_spec.rb