Run Rubocop autocorrect on spec/models

This commit is contained in:
Manuel Bustillo 2024-12-28 17:27:28 +01:00
parent 5fcac34a52
commit 4d69863974
9 changed files with 58 additions and 32 deletions

View File

@ -10,4 +10,8 @@ AllCops:
- 'config/**/*'
- 'script/**/*'
- 'bin/{rails,rake}'
- '*.yml'
- '*.yml'
Layout/LineLength:
Max: 120
RSpec/ExampleLength:
Max: 10

View File

@ -1,12 +1,14 @@
# frozen_string_literal: true
# Copyright (C) 2024 Manuel Bustillo
require 'rails_helper'
RSpec.describe Expense, type: :model do
RSpec.describe Expense do
describe 'validations' do
it { should validate_presence_of(:name) }
it { should validate_presence_of(:amount) }
it { should validate_numericality_of(:amount).is_greater_than(0) }
it { should validate_presence_of(:pricing_type) }
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_presence_of(:amount) }
it { is_expected.to validate_numericality_of(:amount).is_greater_than(0) }
it { is_expected.to validate_presence_of(:pricing_type) }
end
end

View File

@ -4,16 +4,20 @@
require 'rails_helper'
RSpec.describe GroupAffinity, type: :model do
RSpec.describe GroupAffinity do
subject(:affinity) { build(:group_affinity, group_a:, group_b:) }
let(:wedding) { create(:wedding) }
let(:group_a) { create(:group, wedding:) }
let(:group_b) { create(:group, wedding:) }
let(:group_c) { create(:group, wedding:) }
subject { build(:group_affinity, group_a:, group_b: ) }
describe 'validations' do
it { should validate_numericality_of(:discomfort).is_greater_than_or_equal_to(0).is_less_than_or_equal_to(2) }
it do
expect(affinity).to validate_numericality_of(:discomfort)
.is_greater_than_or_equal_to(0)
.is_less_than_or_equal_to(2)
end
end
describe '.create' do

View File

@ -1,10 +1,12 @@
# frozen_string_literal: true
# Copyright (C) 2024 Manuel Bustillo
require 'rails_helper'
RSpec.describe Group, type: :model do
RSpec.describe Group do
describe 'callbacks' do
it 'should set color before create' do
it 'sets color before create' do
expect(create(:group).color).to be_present
end
end

View File

@ -1,12 +1,17 @@
# frozen_string_literal: true
# Copyright (C) 2024 Manuel Bustillo
require 'rails_helper'
RSpec.describe Guest, type: :model do
RSpec.describe Guest do
describe 'validations' do
it { should validate_presence_of(:name) }
subject(:guest) { build(:guest) }
it { is_expected.to validate_presence_of(:name) }
it do
should define_enum_for(:status).with_values(
expect(guest).to define_enum_for(:status).with_values(
considered: 0,
invited: 10,
confirmed: 20,
@ -16,7 +21,7 @@ RSpec.describe Guest, type: :model do
end
end
it { should belong_to(:group).optional }
it { is_expected.to belong_to(:group).optional }
describe 'scopes' do
describe '.potential' do
@ -27,7 +32,7 @@ RSpec.describe Guest, type: :model do
confirmed_guest = create(:guest, status: :confirmed)
tentative_guest = create(:guest, status: :tentative)
expect(Guest.potential).to match_array([invited_guest, confirmed_guest, tentative_guest])
expect(described_class.potential).to contain_exactly(invited_guest, confirmed_guest, tentative_guest)
end
end
end

View File

@ -1,7 +1,9 @@
# frozen_string_literal: true
# Copyright (C) 2024 Manuel Bustillo
require 'rails_helper'
RSpec.describe Seat, type: :model do
RSpec.describe Seat do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,8 +1,10 @@
# frozen_string_literal: true
# Copyright (C) 2024 Manuel Bustillo
require 'rails_helper'
RSpec.describe TablesArrangement, type: :model do
RSpec.describe TablesArrangement do
describe 'callbacks' do
it 'assigns a name before creation' do
expect(create(:tables_arrangement).name).to be_present

View File

@ -1,7 +1,9 @@
# frozen_string_literal: true
# Copyright (C) 2024 Manuel Bustillo
require 'rails_helper'
RSpec.describe User, type: :model do
RSpec.describe User do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,22 +1,25 @@
# frozen_string_literal: true
# Copyright (C) 2024 Manuel Bustillo
require 'rails_helper'
RSpec.describe Wedding, type: :model do
RSpec.describe Wedding do
describe 'validations' do
subject { build(:wedding) }
describe 'slug' do
it { should allow_value('foo').for(:slug) }
it { should allow_value('foo-bar').for(:slug) }
it { should allow_value('foo-123').for(:slug) }
it { should allow_value('foo-123-').for(:slug) }
it { should allow_value('foo--123').for(:slug) }
it { should_not allow_value('Foo').for(:slug) }
it { should_not allow_value('/foo').for(:slug) }
it { should_not allow_value('foo/123').for(:slug) }
it { should_not allow_value('foo_123').for(:slug) }
it { should_not allow_value('foo/').for(:slug) }
describe 'slug' do
it { is_expected.to allow_value('foo').for(:slug) }
it { is_expected.to allow_value('foo-bar').for(:slug) }
it { is_expected.to allow_value('foo-123').for(:slug) }
it { is_expected.to allow_value('foo-123-').for(:slug) }
it { is_expected.to allow_value('foo--123').for(:slug) }
it { is_expected.not_to allow_value('Foo').for(:slug) }
it { is_expected.not_to allow_value('/foo').for(:slug) }
it { is_expected.not_to allow_value('foo/123').for(:slug) }
it { is_expected.not_to allow_value('foo_123').for(:slug) }
it { is_expected.not_to allow_value('foo/').for(:slug) }
end
end
end