Files
puzzle-scoreboard/spec/features/contest_spec.rb
sto cd41d83429
All checks were successful
CI / scan_ruby (push) Successful in 18s
CI / scan_js (push) Successful in 15s
CI / lint (push) Successful in 15s
CI / test (push) Successful in 36s
Fix rspec as is
#18
2025-12-03 15:42:45 +01:00

55 lines
1.5 KiB
Ruby

require 'rails_helper'
RSpec.feature "Contests", type: :feature do
let!(:user) { create(:user) }
before do
login(user)
end
context "index" do
let!(:first_contest) { create(:contest, user: user) }
let!(:second_contest) { create(:contest, user: user) }
it "should list existing contests and offer to open them" do
visit contests_path
expect(page).to have_content(I18n.t("contests.index.title", username: user.username))
expect(page).to have_content(first_contest.name)
expect(page).to have_content(second_contest.name)
find(".stretched-link[href=\"/contests/#{first_contest.friendly_id}\"]").click
expect(page).to have_current_path("/contests/#{first_contest.friendly_id}/contestants")
end
it "should offer to create a new contest" do
visit contests_path
click_link I18n.t("contests.index.new_contest")
expect(page).to have_current_path("/contests/new")
end
end
context "new" do
it "should prevent creating contests without a name" do
visit new_contest_path
click_button I18n.t("helpers.buttons.create")
expect(page).to have_content(I18n.t("activerecord.errors.models.contest.attributes.name.blank"))
end
it "should allow creating new contests with valid parameters" do
visit new_contest_path
fill_in I18n.t("activerecord.attributes.contest.name"), with: "Contest name"
click_button I18n.t("helpers.buttons.create")
expect(page).to have_current_path("/contests")
end
end
end