From ea1e4775f8234d04fb06d3f199c40879ef7f780a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hrvoje=20=C5=A0imi=C4=87?= Date: Sun, 17 Nov 2013 13:08:17 +0100 Subject: [PATCH] override default Rake application's name since Rake now allows overriding application name, use `cap` instead of `rake` when outputting help --- .gitignore | 1 + lib/capistrano/application.rb | 6 ++++-- spec/lib/capistrano/application_spec.rb | 7 ++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 700d338f..131db7ec 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ tmp .rspec-local .ruby-version _site +.rspec diff --git a/lib/capistrano/application.rb b/lib/capistrano/application.rb index bf91f709..7fc9905c 100644 --- a/lib/capistrano/application.rb +++ b/lib/capistrano/application.rb @@ -3,10 +3,13 @@ module Capistrano def initialize super - @name = "cap" @rakefiles = %w{capfile Capfile capfile.rb Capfile.rb} << capfile end + def name + "cap" + end + def run Rake.application = self super @@ -18,7 +21,6 @@ module Capistrano end def load_rakefile - @name = 'cap' super end diff --git a/spec/lib/capistrano/application_spec.rb b/spec/lib/capistrano/application_spec.rb index 7c0d593c..9c2ecfba 100644 --- a/spec/lib/capistrano/application_spec.rb +++ b/spec/lib/capistrano/application_spec.rb @@ -7,11 +7,10 @@ describe Capistrano::Application do it "provides a --format option which enables the choice of output formatting" it "identifies itself as cap and not rake" do - pending "Waiting for: https://github.com/jimweirich/rake/pull/204" out, _ = capture_io do flags '--help', '-h' end - out.should match(/\bcap [ -f capfile ]\b/) + out.lines.first.should match(/cap \[-f rakefile\]/) end it "overrides the rake method, but still prints the rake version" do @@ -37,9 +36,7 @@ describe Capistrano::Application do def subject.exit(*args) throw(:system_exit, :exit) end - subject.instance_eval do - handle_options - end + subject.run subject.options end