spec/unit/environment/git_spec.rb in r10k-1.3.5 vs spec/unit/environment/git_spec.rb in r10k-1.4.0
- old
+ new
@@ -38,23 +38,14 @@
expect(subject.ref).to eq 'd026ea677116424d2968edb9cee8cbc24d09322b'
end
end
describe "synchronizing the environment" do
- it "updates all modules when creating a new environment" do
- allow(working_dir).to receive(:cloned?).and_return(false)
+ it "syncs the working directory" do
expect(working_dir).to receive(:sync)
- expect(subject).to receive(:sync_modules)
subject.sync
end
-
- it "does not update all modules when updating an existing environment" do
- allow(working_dir).to receive(:cloned?).and_return(true)
- expect(working_dir).to receive(:sync)
- expect(subject).to_not receive(:sync_modules)
- subject.sync
- end
end
describe "generating a puppetfile for the environment" do
let(:puppetfile) { subject.puppetfile }
@@ -74,8 +65,47 @@
describe "enumerating modules" do
it "loads the Puppetfile and returns modules in that puppetfile" do
expect(subject.puppetfile).to receive(:load)
expect(subject.puppetfile).to receive(:modules).and_return [:modules]
expect(subject.modules).to eq([:modules])
+ end
+ end
+
+ describe "determining the status" do
+ it "is absent when the working directory is absent" do
+ expect(working_dir).to receive(:exist?).and_return false
+ expect(subject.status).to eq :absent
+ end
+
+ it "is mismatched when the working directory is not git" do
+ expect(working_dir).to receive(:exist?).and_return true
+ expect(working_dir).to receive(:git?).and_return false
+ expect(subject.status).to eq :mismatched
+ end
+
+ it "is mismatched when the working directory remote doesn't match the desired remote" do
+ expect(working_dir).to receive(:exist?).and_return true
+ expect(working_dir).to receive(:git?).and_return true
+ expect(working_dir).to receive(:remote).and_return 'git://git-server.site/my-other-repo.git'
+ expect(subject.status).to eq :mismatched
+ end
+
+ it "is is outdated when the working directory has not been synced" do
+ expect(working_dir).to receive(:exist?).and_return true
+ expect(working_dir).to receive(:git?).and_return true
+ expect(working_dir).to receive(:remote).and_return 'git://git-server.site/my-repo.git'
+ expect(subject.status).to eq :outdated
+ end
+
+ it "is is insync when the working directory has been synced" do
+ expect(working_dir).to receive(:exist?).and_return true
+ expect(working_dir).to receive(:git?).and_return true
+ expect(working_dir).to receive(:remote).and_return 'git://git-server.site/my-repo.git'
+
+ expect(working_dir).to receive(:sync)
+
+ subject.sync
+
+ expect(subject.status).to eq :insync
end
end
end