From 3f23a8d405053d485245c7c4587e7d995580b20f Mon Sep 17 00:00:00 2001 From: Kazuaki MATSUO Date: Sun, 1 Oct 2017 22:00:51 +0900 Subject: [PATCH] add an example for after hook --- example/spec/capybara_init.rb | 7 ++++--- example/spec/ios_example_spec.rb | 2 +- example/spec/spec_helper.rb | 4 ++++ lib/appium_capybara/driver/appium/driver.rb | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/example/spec/capybara_init.rb b/example/spec/capybara_init.rb index 33230a7..37ae59c 100644 --- a/example/spec/capybara_init.rb +++ b/example/spec/capybara_init.rb @@ -1,4 +1,5 @@ require 'rspec' +require 'capybara' require 'capybara/rspec' require 'appium_capybara' require 'site_prism' @@ -8,10 +9,10 @@ url = "http://localhost:4723/wd/hub" Capybara.register_driver(:appium) do |app| - all_options = caps.merge(appium_lib: {server_url: url}) - puts all_options.inspect + all_options = caps.merge(appium_lib: {server_url: url}) + puts all_options.inspect - Appium::Capybara::Driver.new app, all_options + Appium::Capybara::Driver.new app, all_options end Capybara.default_driver = :appium diff --git a/example/spec/ios_example_spec.rb b/example/spec/ios_example_spec.rb index 30a808c..9dc0bb6 100644 --- a/example/spec/ios_example_spec.rb +++ b/example/spec/ios_example_spec.rb @@ -3,6 +3,6 @@ describe 'UICatalog smoke test' do it 'should detect the nav bar' do home_page = Pages::Home.new - expect(home_page.navigation_bar.first).to be_truthy + expect(home_page.navigation_bar.first).to be_falsey end end diff --git a/example/spec/spec_helper.rb b/example/spec/spec_helper.rb index 250bde7..0bd9e25 100644 --- a/example/spec/spec_helper.rb +++ b/example/spec/spec_helper.rb @@ -7,4 +7,8 @@ config.after(:each) do |result| Capybara.current_session.driver.quit end + + config.after do |result| + Capybara.current_session.driver.save_screenshot 'error.png' if result.exception + end end \ No newline at end of file diff --git a/lib/appium_capybara/driver/appium/driver.rb b/lib/appium_capybara/driver/appium/driver.rb index 9bc487a..cead049 100644 --- a/lib/appium_capybara/driver/appium/driver.rb +++ b/lib/appium_capybara/driver/appium/driver.rb @@ -51,7 +51,7 @@ def reset! @appium_driver.reset if @appium_driver end - # new + # @deprecated This method is being removed def browser_initialized? !! @browser end