Sha256: af320ca9fbd20272499339a79c2490ed8da5c37acec319a9625ffa49b68d3d60

Contents?: true

Size: 1.44 KB

Versions: 1

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 -zcvf 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

1 entries across 1 versions & 1 rubygems

Version Path
fourchette-0.0.7 spec/lib/fourchette/tarball_spec.rb