Sha256: 8938b0185ce9b279666d6aa858b49990a148c807ef5b8bf23e3186696ad49346

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

module BrowserHelper
  def click(id)
    wait_until { find("##{id}").should be_visible }
    find("##{id}").click
  end

  # Hacky way to wait for AJAX because we need a very customized matchers
  # We shouldn't be using this, but I cannot make it work
  def wait_until(&block)
    count = 0
    while true 
      begin
        block.call
        return
      rescue => e
        if count < 30 # Timeout in 3 seconds
          count += 1
          sleep(0.1)
          retry
        else
          raise e
        end
      end
    end
  end

  def snap
    @screenshot_number ||= 0
    page.save_screenshot("tmp/poltergeist_#{@screenshot_number += 1}.png", :full => true)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whowish_word-1.0.0 rails/spec/support/browser_helper.rb