summaryrefslogtreecommitdiff
path: root/qa/qa/page/base.rb
blob: 69f14386223f69d5a9322979f9ac1ad1aae5bf3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module QA
  module Page
    class Base
      include Capybara::DSL
      include Scenario::Actable

      def refresh
        visit current_url
      end

      def wait(css = '.application', time: 60)
        # This resolves cold boot / background tasks problems
        #
        Time.now.tap do |start|
          while Time.now - start < time
            break if page.has_css?(css, wait: 5)
            puts "Waiting for `#{css} on `#{current_url}`"
            refresh
          end
        end

        yield if block_given?
      end

      def self.address
        raise NotImplementedError
      end
    end
  end
end