Sha256: 19100364b55de21787cceeb907f0c080de1067dc74bbcc89822bdb8e7c28833a

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

require "spec_helper"

describe "Databases list", type: :request do
  before { visit "/" }

  it "hides the breadcrumb" do
    expect(page).not_to have_css(".breadcrumb")
  end

  it "displays list with available databases" do
    expect(page).to have_content("Available databases")

    within "table" do
      expect(page).to have_link("first_database")
      expect(page).to have_link("second_database")
    end
  end

  describe "filtering", js: true do
    it "filters databases by name" do
      fill_in_filter("first")

      within "table.databases" do
        expect(page).to have_link("first_database")
        expect(page).to_not have_link("second_database")
      end
    end

    it "displays a notification when nothing has been found" do
      fill_in_filter("third")
      should_hide_the_table_and_display_a_notification
    end
  end

  describe "click on delete database button", js: true do
    it "deletes a database" do
      click_delete_button_for("second_database")
      confirm_dialog

      expect(page).to have_flash_message("Database second_database has been deleted.")

      within "table.databases" do
        expect(page).to have_link("first_database")
        expect(page).to_not have_link("second_database")
      end

      click_delete_button_for("first_database")
      confirm_dialog

      expect(page).to have_flash_message("Database first_database has been deleted.")

      should_hide_the_table_and_display_a_notification
    end

    def click_delete_button_for(database_name)
      database_row = find(:xpath, %Q{//table//tr//*[contains(text(), "#{database_name}")]/../..})
      within(database_row) { click_link "Delete" }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongo_browser-0.1.0 spec/features/databases_list_spec.rb