Skip to content

Commit

Permalink
errors for xdotool (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonovk authored Nov 3, 2023
2 parents 8fa9865 + 1f5775d commit 84cf924
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
boaw (0.0.3)
boaw (0.1.0)

GEM
remote: https://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion lib/boaw/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class Boaw
VERSION = '0.0.3'
VERSION = '0.1.0'
end
6 changes: 6 additions & 0 deletions lib/xdotool/adapter.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# frozen_string_literal: true

require_relative 'position_parser'
require_relative 'base_error'

module Xdotool
# Xdotool adapter for mouse control
class Adapter
def initialize
result = Kernel.system('xdotool')
raise BaseError if result.nil?
end

def position
output = IO.popen('xdotool getmouselocation', &:read)

Expand Down
10 changes: 10 additions & 0 deletions lib/xdotool/base_error.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

module Xdotool
# default error
class BaseError < StandardError
def message
'не удалось инициализировать модуль xdotool'
end
end
end
2 changes: 1 addition & 1 deletion test/lib/boaw/version_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

class VersionTest < Minitest::Test
def test_version
assert_equal '0.0.3', Boaw::VERSION
assert_equal '0.1.0', Boaw::VERSION
end
end
7 changes: 6 additions & 1 deletion test/lib/boaw_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
class BoawTest < Minitest::Test
def setup
@mock_adapter = Minitest::Mock.new
@boaw = Boaw.new
mock_kernel = Minitest::Mock.new

Kernel.stub(:system, true, mock_kernel) do
@boaw = Boaw.new
end

@boaw.instance_variable_set(:@adapter, @mock_adapter)
@position = { x: 1, y: 2 }
end
Expand Down
7 changes: 6 additions & 1 deletion test/lib/xdotool/adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ module Xdotool
class AdapterTest < Minitest::Test
def setup
@position = { x: 1, y: 2 }
@adapter = Adapter.new

mock_kernel = Minitest::Mock.new

Kernel.stub(:system, true, mock_kernel) do
@adapter = Adapter.new
end
end

def test_left_click
Expand Down
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require 'byebug'
require_relative '../lib/boaw'
require_relative '../lib/boaw/version'
require_relative '../lib/xdotool/position_parser'
Expand Down

0 comments on commit 84cf924

Please sign in to comment.