Skip to content

Commit

Permalink
Refactor launchy option handling
Browse files Browse the repository at this point in the history
  • Loading branch information
yujinakayama committed Jun 11, 2017
1 parent 9209180 commit a6eb452
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 5 additions & 5 deletions lib/guard/rubocop/runner.rb
Expand Up @@ -20,7 +20,7 @@ def run(paths = [])
notify(passed)
end

open_launchy
open_launchy_if_needed

passed
end
Expand Down Expand Up @@ -127,11 +127,11 @@ def pluralize(number, thing, options = {})
text
end

def open_launchy
return unless @options[:launchy]
def open_launchy_if_needed
return unless (output_path = @options[:launchy])
return unless File.exist?(output_path)
require 'launchy'
pn = Pathname.new(@options[:launchy])
::Launchy.open(@options[:launchy]) if pn.exist?
::Launchy.open(output_path)
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions spec/guard/rubocop/runner_spec.rb
Expand Up @@ -92,8 +92,7 @@
let(:options) { { launchy: 'launchy_path' } }

before do
allow(Pathname).to receive(:new)
.with('launchy_path') { double(exist?: true) }
allow(File).to receive(:exist?).with('launchy_path').and_return(true)
end

it 'opens Launchy' do
Expand Down

0 comments on commit a6eb452

Please sign in to comment.