Skip to content

Commit

Permalink
test: add test for when wmctrl command is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
iberianpig committed Jul 14, 2024
1 parent 3a8792c commit 2b37e94
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/fusuma/plugin/executors/wmctrl_executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def search_command(event)

private

# @return [NilClass] when wmctrl is installed
# @raise [NotInstalledError] when wmctrl is not installed
def must_install!(cmd)
return if @_installed

Expand Down
9 changes: 9 additions & 0 deletions spec/fusuma/plugin/executors/wmctrl_executor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module Executors
record = Events::Records::IndexRecord.new(index: index)
@event = Events::Event.new(tag: "dummy_detector", record: record)
@executor = WmctrlExecutor.new
allow(@executor).to receive(:must_install!).with("wmctrl").and_return true
allow(@executor).to receive(:search_command).and_return "dummy command"
end

Expand Down Expand Up @@ -74,6 +75,14 @@ module Executors
.and_return([@current_workspace, @total_workspaces])
end


context "when wmctrl command is not installed" do
before do
allow(@executor).to receive(:must_install!).with("wmctrl").and_raise WmctrlExecutor::NotInstalledError
end
it { expect(@executor.executable?(@event)).to be_falsey }
end

context "when workspace: 'prev'" do
around do |example|
ConfigHelper.load_config_yml = <<~CONFIG
Expand Down

0 comments on commit 2b37e94

Please sign in to comment.