require "rails_helper"

describe "Deleting a existing event" do


  before do
    admin = User.create!(user_attributes(admin: true))
    sign_in(admin)
  end

  it "finds and deletes a event then shows listing page without deleted event" do
    announcement = Announcement.create(title: "Announcement title",
                                        text: "Announcement text",
                                        author: "Announcement author")

    visit events_path

    click_link "Delete Announcement"

    expect(current_path).to eq(events_path)
    expect(page).not_to have_text(announcement.title)

    expect(page).to have_text("Announcement successfully deleted!")
  end
end
