Sha256: 35453ab70718ee389b2a7552ad8ca749e0d1ed36aeaa4a0807d37f0497562b40

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

module FeatureExampleGroup

  def fill_in_filter(value)
    page.execute_script <<-JS
        $("form.filter input[type='text']").val("#{value}").keyup();
    JS
  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
  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

3 entries across 3 versions & 1 rubygems

Version Path
mongo_browser-0.1.3 spec/support/feature_example_group.rb
mongo_browser-0.1.2 spec/support/feature_example_group.rb
mongo_browser-0.1.1 spec/support/feature_example_group.rb