Skip to content

Commit

Permalink
Refactor launchy option
Browse files Browse the repository at this point in the history
  • Loading branch information
yujinakayama committed Jun 11, 2017
1 parent 481a15e commit 60868ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/guard/rubocop/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ def pluralize(number, thing, options = {})
end

def open_launchy
return unless @options[:launchy]
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
Original file line number Diff line number Diff line change
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 60868ea

Please sign in to comment.