Files
grecia/spec/features/budgets/groups_spec.rb
Javi Martín db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00

54 lines
1.6 KiB
Ruby

require "rails_helper"
describe "Budget Groups" do
let(:budget) { create(:budget, slug: "budget_slug") }
let!(:group) { create(:budget_group, slug: "group_slug", budget: budget) }
context "Load" do
scenario "finds group using budget slug and group slug" do
visit budget_group_path("budget_slug", "group_slug")
expect(page).to have_content "Select an option"
end
scenario "finds group using budget id and group id" do
visit budget_group_path(budget, group)
expect(page).to have_content "Select an option"
end
scenario "raises an error if budget slug is not found" do
expect do
visit budget_group_path("wrong_budget", group)
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if budget id is not found" do
expect do
visit budget_group_path(0, group)
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if group slug is not found" do
expect do
visit budget_group_path(budget, "wrong_group")
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if group id is not found" do
expect do
visit budget_group_path(budget, 0)
end.to raise_error ActiveRecord::RecordNotFound
end
end
context "Show" do
scenario "Headings are sorted by name" do
last_heading = create(:budget_heading, group: group, name: "BBB")
first_heading = create(:budget_heading, group: group, name: "AAA")
visit budget_group_path(budget, group)
expect(first_heading.name).to appear_before(last_heading.name)
end
end
end