From b75c82725167d7bf0249bed2b68eeaf8889f12c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Thu, 18 Jul 2019 08:49:05 +0200 Subject: [PATCH] Improve testing on version_board_spec --- .../features/action_boards/version_board_spec.rb | 16 +++++++++++++++- spec/support/rspec_retry.rb | 10 +++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/modules/boards/spec/features/action_boards/version_board_spec.rb b/modules/boards/spec/features/action_boards/version_board_spec.rb index 9eebd64272..ddb680611a 100644 --- a/modules/boards/spec/features/action_boards/version_board_spec.rb +++ b/modules/boards/spec/features/action_boards/version_board_spec.rb @@ -214,9 +214,23 @@ describe 'Version action board', type: :feature, js: true do visit settings_project_path(project, tab: 'versions') expect(page).to have_content 'Completely new version' + expect(page).to have_content 'Closed version' board_page.visit! - board_page.add_list option: closed_version.name + + board_page.expect_list 'Open version' + board_page.expect_list 'A second version' + board_page.expect_list 'Completely new version' + board_page.expect_card('Open version', 'Foo') + + queries = board_page.board(reload: true).contained_queries + closed = queries.find_by(name: 'Closed version') + expect(closed).to be_nil + + retry_block(screenshot: true) do + board_page.add_list option: closed_version.name + end + board_page.expect_list 'Closed version' expect(page).to have_selector('.version-board-header.-closed') diff --git a/spec/support/rspec_retry.rb b/spec/support/rspec_retry.rb index 8d03112192..f303f2711a 100644 --- a/spec/support/rspec_retry.rb +++ b/spec/support/rspec_retry.rb @@ -35,12 +35,20 @@ end ## # Helper to pass options to retriable while logging # failures -def retry_block(args: {}, &block) +def retry_block(args: {}, screenshot: false, &block) log_errors = Proc.new do |exception, try, elapsed_time, next_interval| $stderr.puts <<-EOS.strip_heredoc #{exception.class}: '#{exception.message}' #{try} tries in #{elapsed_time} seconds and #{next_interval} seconds until the next try. EOS + + if screenshot + begin + Capybara::Screenshot.screenshot_and_save_page + rescue StandardError => e + $stderr.puts "Failed to take screenshot in retry_block: #{e} #{e.message}" + end + end end Retriable.retriable(args.merge(on_retry: log_errors), &block)