Sha256: 0ca41a4e2af2b286fc3ffad1186abbf3b2bff9cee44b7dee1a2bde7de5ec8780
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
describe Stevenson::Template::Git do let(:template_url) { 'http://www.github.com/Org/repo.git' } let(:options) { Hash.new } subject { described_class.new(template_url, options) } describe '#local_directory' do let(:tmp_dir) { '/tmp/dir/to/template' } before { allow(Dir).to receive(:mktmpdir).and_return(tmp_dir) } context 'when template_url is a valid URL' do let(:git_repo) { double(:git_repo) } before { allow(::Git).to receive(:clone).and_return(git_repo) } it 'returns a temp directory' do expect(subject.local_directory).to eq tmp_dir end it 'clones the given repository to the working template path' do expect(::Git).to receive(:clone).with(template_url, tmp_dir) subject.local_directory end context "when the :branch option is set" do let(:branch) { 'test-branch' } let(:options) { { branch: branch } } it "should check out the related branch" do expect(git_repo).to receive(:checkout).with(branch).and_return(true) subject.local_directory end end end context 'when template_url is an invalid URL' do let(:template_url) { 'not/a/repo' } before { allow(::Git).to receive(:clone).and_raise(::Git::GitExecuteError) } it 'raises an invalid template exception' do expect { subject.local_directory }.to raise_exception(Stevenson::Template::InvalidTemplateException) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stevenson-2.1.0 | spec/lib/templates/git_spec.rb |
stevenson-2.0.0 | spec/lib/templates/git_spec.rb |