Skip to content

Commit

Permalink
Add spec to verify Guardfile template exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
netzpirat committed Oct 17, 2011
1 parent 9cd77af commit 371d66c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/guard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ module Guard
autoload :Notifier, 'guard/notifier'
autoload :Hook, 'guard/hook'

# The Guardfile template for `guard init`
GUARDFILE_TEMPLATE = File.expand_path('../guard/templates/Guardfile', __FILE__)

class << self
attr_accessor :options, :interactor, :listener, :lock

Expand All @@ -32,7 +35,7 @@ def initialize_template(guard_name = nil)
else
if !File.exist?('Guardfile')
::Guard::UI.info "Writing new Guardfile to #{ Dir.pwd }/Guardfile"
FileUtils.cp(File.expand_path('../guard/templates/Guardfile', __FILE__), 'Guardfile')
FileUtils.cp(GUARDFILE_TEMPLATE, 'Guardfile')
else
::Guard::UI.error "Guardfile already exists at #{ Dir.pwd }/Guardfile"
exit 1
Expand Down
4 changes: 4 additions & 0 deletions spec/guard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

describe Guard do

it "has a valid Guardfile template" do
File.exists?(Guard::GUARDFILE_TEMPLATE).should be_true
end

describe ".initialize_template" do
context "with a Guard name" do
it "initializes a the Guard" do
Expand Down

0 comments on commit 371d66c

Please sign in to comment.