Sha256: affba4ecc7d439c6afa0030ba18f4f0ab1e173c723c135b891e7d65fcaa1e5a9

Contents?: true

Size: 1.44 KB

Versions: 4

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

describe Fourchette::Tarball do
  subject { described_class.new }

  describe '#url' do
    let(:git_repo_url) { 'git://github.com/jipiboily/fourchette.git' }
    let(:github_repo) { 'jipiboily/fourchette' }
    let(:branch_name) { 'feature/something-new' }

    before do
      subject.stub(:expiration_timestamp).and_return('123')
      subject.stub(:clone)
      subject.stub(:tar).and_return('tmp/1234567/123.tar.gz')
      subject.stub(:system)
      stub_const('ENV', {'FOURCHETTE_APP_URL' => 'http://example.com'})
      SecureRandom.stub(:uuid).and_return('1234567')
    end

    it {
        expect(
            subject.url(git_repo_url, branch_name, github_repo)
          ).to eq "http://example.com/jipiboily/fourchette/1234567/123"
        }

    it 'clones the repo and checkout the branch' do
      subject.unstub(:clone)
      git_instance = double
      Git.should_receive(:clone).with(git_repo_url, "tmp/1234567", recursive: true).and_return(git_instance)
      git_instance.should_receive(:checkout).with(branch_name)
      subject.url(git_repo_url, branch_name, github_repo)
    end

    it 'creates the tarball' do
      subject.unstub(:tar)
      subject.should_receive(:system).with 'tar -zcf tmp/1234567/123.tar.gz -C tmp/1234567 .'
      subject.url(git_repo_url, branch_name, github_repo)
    end
  end

  describe '#filepath' do
    it { expect(subject.filepath('1234567', '123')).to eq 'tmp/1234567/123.tar.gz' }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fourchette-0.1.2 spec/lib/fourchette/tarball_spec.rb
fourchette-0.1.1 spec/lib/fourchette/tarball_spec.rb
fourchette-0.1.0 spec/lib/fourchette/tarball_spec.rb
fourchette-0.0.8 spec/lib/fourchette/tarball_spec.rb