Sha256: cbe13e2ad0c50d9c186aa459db86f05d65c1cef3f8f0c7ccccf5a1b80aaa4c5d
Contents?: true
Size: 1.68 KB
Versions: 3
Compression:
Stored size: 1.68 KB
Contents
require 'spec_helper' require 'anvil/task/projects' describe Anvil::Task::Projects, fakefs: true do let(:dummy_class) do Class.new do include Anvil::Task::Projects end end let(:project) { 'anvil-core' } let(:project_path) { Anvil::Config.base_projects_path + "/#{project}" } subject { dummy_class.new } before { FileUtils.mkdir_p project_path } describe '#project_path' do it "returns the anvil's project path" do expect(subject.project_path(project)) .to eq(project_path) end end describe '#change_project' do let!(:previous_dir) { Dir.getwd } before { FileUtils.mkdir_p project_path } after { Dir.chdir previous_dir } it "cd's into the project's path" do subject.change_project(project) expect(Dir.getwd).to eq(project_path) end end describe '#on_project' do before { subject.stub(:git).and_return(double('git')) } it 'keeps the project changed inside the block' do subject.on_project project do expect(Dir.pwd).to eq(project_path) end end it 'yields a git project object' do expect { |b| subject.on_project(project, &b) }.to yield_with_args end it 'returns the same thing returned by the yielded block' do return_value = 'return-value' expect(subject.on_project(project) { return_value }).to eq(return_value) end end describe '#on_each_project' do let(:projects) { %w(anvil-core anvil-plugins) } before do expect(subject).to receive(:on_project).twice.and_yield(double('git')) end it 'works on each project' do expect { |b| subject.on_each_project(projects, &b) } .to yield_control.twice end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
anvil-core-0.4.2 | spec/lib/anvil/task/projects_spec.rb |
anvil-core-0.4.1 | spec/lib/anvil/task/projects_spec.rb |
anvil-core-0.4.0 | spec/lib/anvil/task/projects_spec.rb |