System tests are used to test the application from the user's point of view. To test for specific exceptions, particularly regarding authorization permissions, controller tests fit better. Another option would be to test the page displayed shows a certain text, like "Internal server error". I'm choosing controller tests because they're faster and we're basically testing the same scenario many times and we've already got a test checking what happens when users access a page raising an exception.
36 lines
902 B
Ruby
36 lines
902 B
Ruby
require "rails_helper"
|
|
|
|
describe "Valuation budgets" do
|
|
before do
|
|
valuator = create(:valuator, user: create(:user, username: "Rachel", email: "rachel@valuators.org"))
|
|
login_as(valuator.user)
|
|
end
|
|
|
|
context "Index" do
|
|
scenario "Displaying budgets" do
|
|
budget = create(:budget)
|
|
visit valuation_budgets_path
|
|
|
|
expect(page).to have_content(budget.name)
|
|
end
|
|
|
|
scenario "Filters by phase" do
|
|
budget1 = create(:budget, :finished)
|
|
budget2 = create(:budget, :finished)
|
|
budget3 = create(:budget, :accepting)
|
|
|
|
visit valuation_budgets_path
|
|
|
|
expect(page).not_to have_content(budget1.name)
|
|
expect(page).not_to have_content(budget2.name)
|
|
expect(page).to have_content(budget3.name)
|
|
end
|
|
|
|
scenario "With no budgets" do
|
|
visit valuation_budgets_path
|
|
|
|
expect(page).to have_content "There are no budgets"
|
|
end
|
|
end
|
|
end
|