Sha256: af02fb04bb2234271a4c174fcde266d9fb9da070287a0bfff7dd8318342f23ec

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

module FeatureExampleGroup

  def fill_in_filter(value)
    filter_input = find(%Q{form.filter input[type="text"]})
    filter_input.set(value)
  end

  def confirm_dialog(message = 'Are you sure?')
    begin
      wait_until { page.has_css?("div.bootbox.modal") }
    rescue Capybara::TimeoutError
      raise "Expected confirmation modal to be visible."
    end

    within "div.bootbox.modal" do
      page.should have_content(message)
      click_link "OK"
    end

    begin
      wait_until { page.has_no_css?("div.bootbox.modal") }
    rescue Capybara::TimeoutError
      raise "Expected confirmation modal to be disposed."
    end
  end

  def should_hide_the_table_and_display_a_notification
    expect(page).to_not have_css("table.databases")
    expect(page).to have_content("Nothing has been found.")
  end

  # Take a screenshot and html dump for the page
  def capture_page(file_name = Time.now.to_i.to_s)
    reports_path = File.expand_path("reports/capybara")
    FileUtils.mkdir_p(reports_path)

    file_path = File.join(reports_path, file_name)

    captured_files = []

    html_file = "#{file_path}.html"
    File.open(html_file, "w") { |f| f.write(page.body) }
    captured_files << html_file

    if example.metadata[:js]
      image_file = "#{file_path}.png"
      page.driver.render(image_file, full: true)
      captured_files << image_file
    end

    captured_files
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongo_browser-0.2.0.rc2 spec/support/feature_example_group.rb