spec/spec_helper.rb in win_gui-0.2.1 vs spec/spec_helper.rb in win_gui-0.2.3

- old
+ new

@@ -60,32 +60,31 @@ lambda {|*args| args} end def launch_test_app system APP_START - sleep SLEEP_DELAY until (handle = find_window(nil, WIN_TITLE)) - @launched_test_app = Window.new handle + @test_app = Window.top_level( title: WIN_TITLE, timeout: 10) - def @launched_test_app.textarea #define singleton method retrieving app's text area - Window.new find_window_ex(self.handle, 0, TEXTAREA_CLASS, nil) + def @test_app.textarea #define singleton method retrieving app's text area + Window.new WinGui::find_window_ex(self.handle, 0, TEXTAREA_CLASS, nil) end - @launched_test_app + @test_app end - def close_test_app(app = @launched_test_app) - while app && app.respond_to?(:handle) && find_window(nil, WIN_TITLE) - post_message(app.handle, WM_SYSCOMMAND, SC_CLOSE, nil) - sleep SLEEP_DELAY + def close_test_app + while @test_app && find_window(nil, WIN_TITLE) + @test_app.close + # Dealing with closing confirmation modal dialog + keystroke("N") if Window.top_level( title: "Steganos Locknote", timeout: SLEEP_DELAY*5) end - @launched_test_app = nil + @test_app = nil end # Creates test app object and yields it back to the block def test_app - app = launch_test_app - - yield app + test_app = launch_test_app + yield test_app close_test_app end end