Module: Repla::Test::Helper
- Defined in:
- lib/repla/test/lib/helper.rb
Overview
Test helper
Constant Summary collapse
- APPLESCRIPT_DIRECTORY =
File.join(File.dirname(__FILE__), '..', 'applescript')
- CONFIRMDIALOGAPPLESCRIPT_FILE =
File.join(APPLESCRIPT_DIRECTORY, 'confirm_dialog.applescript')
- WINDOWIDAPPLESCRIPT_FILE =
File.join(APPLESCRIPT_DIRECTORY, 'window_id.applescript')
- CANCELDIALOGAPPLESCRIPT_FILE =
File.join(APPLESCRIPT_DIRECTORY, 'cancel_dialog.applescript')
- QUITAPPLESCRIPT_FILE =
File.join(APPLESCRIPT_DIRECTORY, 'quit.applescript')
- ISRUNNINGAPPLESCRIPT_FILE =
File.join(APPLESCRIPT_DIRECTORY, 'is_running.applescript')
- SWITCHWINDOWSAPPLESCRIPT_FILE =
File.join(APPLESCRIPT_DIRECTORY, 'switch_windows.applescript')
- WINDOWBOUNDSAPPLESCRIPT_FILE =
File.join(APPLESCRIPT_DIRECTORY, 'window_bounds.applescript')
- SETWINDOWBOUNDSAPPLESCRIPT_FILE =
File.join(APPLESCRIPT_DIRECTORY, 'set_window_bounds'\ '.applescript')
Class Method Summary collapse
- .cancel_dialog ⇒ Object
- .confirm_dialog ⇒ Object
- .quit ⇒ Object
- .run_javascript(javascript) ⇒ Object
- .set_window_bounds(bounds, window_id = nil) ⇒ Object
- .switch_windows ⇒ Object
- .window_bounds(window_id = nil) ⇒ Object
- .window_id ⇒ Object
Instance Method Summary collapse
Class Method Details
.cancel_dialog ⇒ Object
35 36 37 38 |
# File 'lib/repla/test/lib/helper.rb', line 35 def self.cancel_dialog run_applescript(CANCELDIALOGAPPLESCRIPT_FILE) sleep TEST_PAUSE_TIME # Give dialog time end |
.confirm_dialog ⇒ Object
22 23 24 25 |
# File 'lib/repla/test/lib/helper.rb', line 22 def self.confirm_dialog run_applescript(CONFIRMDIALOGAPPLESCRIPT_FILE) sleep TEST_PAUSE_TIME # Give dialog time end |
.quit ⇒ Object
42 43 44 |
# File 'lib/repla/test/lib/helper.rb', line 42 def self.quit run_applescript(QUITAPPLESCRIPT_FILE) end |
.run_javascript(javascript) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/repla/test/lib/helper.rb', line 13 def self.run_javascript(javascript) # `osascript` requires redirecting stderr to stdout for some reason `osascript -l JavaScript -e \ #{Shellwords.escape(javascript)} 2>&1`.chomp! # return `node -e #{Shellwords.escape(javascript)}` end |
.set_window_bounds(bounds, window_id = nil) ⇒ Object
68 69 70 71 72 |
# File 'lib/repla/test/lib/helper.rb', line 68 def self.set_window_bounds(bounds, window_id = nil) arguments = [bounds] arguments = arguments.push(window_id) if window_id run_applescript(SETWINDOWBOUNDSAPPLESCRIPT_FILE, arguments) end |
.switch_windows ⇒ Object
55 56 57 |
# File 'lib/repla/test/lib/helper.rb', line 55 def self.switch_windows run_applescript(SWITCHWINDOWSAPPLESCRIPT_FILE) end |
.window_bounds(window_id = nil) ⇒ Object
61 62 63 |
# File 'lib/repla/test/lib/helper.rb', line 61 def self.window_bounds(window_id = nil) run_applescript(WINDOWBOUNDSAPPLESCRIPT_FILE, [window_id]) end |
.window_id ⇒ Object
29 30 31 |
# File 'lib/repla/test/lib/helper.rb', line 29 def self.window_id run_applescript(WINDOWIDAPPLESCRIPT_FILE) end |
Instance Method Details
#app_running? ⇒ Boolean
48 49 50 51 |
# File 'lib/repla/test/lib/helper.rb', line 48 def app_running? result = run_applescript(ISRUNNINGAPPLESCRIPT_FILE) result == 'true' end |