Skip to content

Commit

Permalink
really fix when tmux is not installed or is not found
Browse files Browse the repository at this point in the history
When tmux cannot be find, `Shellany::Sheller.stdout('tmux -V')`
returns `nil`, not empty string.
  • Loading branch information
eitoball committed Jul 31, 2019
1 parent caf272c commit d21d36f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/notiffany/notifier/tmux/client.rb
Expand Up @@ -11,7 +11,7 @@ class << self
def version
begin
Float(_capture("-V")[/\d+\.\d+/])
rescue TypeError
rescue NoMethodError, TypeError
raise Base::UnavailableError, "Could not find tmux"
end
end
Expand Down
11 changes: 10 additions & 1 deletion spec/lib/notiffany/notifier/tmux_spec.rb
Expand Up @@ -14,7 +14,16 @@ class Notifier
describe ".version" do
context "when tmux is not installed" do
it "fails" do
allow(sheller).to receive(:stdout).and_return('')
allow(sheller).to receive(:stdout).and_return(nil)
expect do
described_class.version
end.to raise_error(Base::UnavailableError)
end
end

context "when 'tmux -v' doesn't contain float-like string" do
it "fails" do
allow(sheller).to receive(:stdout).and_return('master')
expect do
described_class.version
end.to raise_error(Base::UnavailableError)
Expand Down

0 comments on commit d21d36f

Please sign in to comment.