spec/lib/fourchette/tarball_spec.rb in fourchette-0.1.2 vs spec/lib/fourchette/tarball_spec.rb in fourchette-0.1.3
- old
+ new
@@ -7,38 +7,44 @@
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')
+ allow(subject).to receive(:expiration_timestamp).and_return('123')
+ allow(subject).to receive(:clone)
+ allow(subject).to receive(:tar).and_return('tmp/1234567/123.tar.gz')
+ allow(subject).to receive(:system)
+ stub_const('ENV', 'FOURCHETTE_APP_URL' => 'http://example.com')
+ allow(SecureRandom).to receive(: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 do
+ expect(
+ subject.url(git_repo_url, branch_name, github_repo)
+ ).to eq 'http://example.com/jipiboily/fourchette/1234567/123'
+ end
it 'clones the repo and checkout the branch' do
- subject.unstub(:clone)
+ allow(subject).to receive(:clone).and_call_original
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)
+ expect(Git).to receive(:clone).with(
+ git_repo_url, 'tmp/1234567', recursive: true
+ ).and_return(git_instance)
+ expect(git_instance).to 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 .'
+ allow(subject).to receive(:tar).and_call_original
+ expect(subject).to 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' }
+ it 'should return the correct filepath' do
+ expect(subject.filepath('1234567', '123')).to eq 'tmp/1234567/123.tar.gz'
+ end
end
-end
\ No newline at end of file
+end