From a4d2ea2774bf9d5fac3c76beefc1685dfc451399 Mon Sep 17 00:00:00 2001 From: Jason Slagle Date: Wed, 21 Aug 2013 16:11:35 -0400 Subject: [PATCH] Add fetched tests to git source --- lib/henson/source/git.rb | 6 +++++- spec/henson/source/git_spec.rb | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/henson/source/git.rb b/lib/henson/source/git.rb index ee7c653..50c9843 100644 --- a/lib/henson/source/git.rb +++ b/lib/henson/source/git.rb @@ -53,7 +53,11 @@ def initialize name, repo, opts = {} end def fetched? - File.directory? fetch_path + if @ref_type == :ref + return has_ref?(@target_revision) + else + File.directory? fetch_path + end end def fetch! diff --git a/spec/henson/source/git_spec.rb b/spec/henson/source/git_spec.rb index 127b7dd..655a8c1 100644 --- a/spec/henson/source/git_spec.rb +++ b/spec/henson/source/git_spec.rb @@ -10,8 +10,24 @@ expect(Henson::Source::Git.new("foo", :bar => :baz)).to_not be_fetched end - it "returns false if the repo does not have the correct revision" - it "returns true if cloned and the correct revision" + let(:git) do + lambda { |opts = {}| + Henson::Source::Git.new "osx_defaults", + "https://github.com/wfarr/puppet-osx_defaults", + opts + } + end + it "returns false if the repo does not have the correct revision" do + lgit = git.(:ref => "0123456") + lgit.fetch! + expect(lgit).to_not be_fetched + end + it "returns true if cloned and the correct revision" do + lgit = git.(:ref => "ff5e337") + lgit.fetch! + expect(lgit).to be_fetched + end + end describe "#fetch!" do