diff --git a/.rubocop.yml b/.rubocop.yml index c316e05..3ec2fa4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,4 +10,8 @@ AllCops: - 'config/**/*' - 'script/**/*' - 'bin/{rails,rake}' - - '*.yml' \ No newline at end of file + - '*.yml' +Layout/LineLength: + Max: 120 +RSpec/ExampleLength: + Max: 10 \ No newline at end of file diff --git a/spec/models/expense_spec.rb b/spec/models/expense_spec.rb index 973ccf2..d6d5f89 100644 --- a/spec/models/expense_spec.rb +++ b/spec/models/expense_spec.rb @@ -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 diff --git a/spec/models/group_affinity_spec.rb b/spec/models/group_affinity_spec.rb index 05f9330..9d56d08 100644 --- a/spec/models/group_affinity_spec.rb +++ b/spec/models/group_affinity_spec.rb @@ -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 diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 10102f4..1bf6ae3 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -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 diff --git a/spec/models/guest_spec.rb b/spec/models/guest_spec.rb index 6786271..711e5ca 100644 --- a/spec/models/guest_spec.rb +++ b/spec/models/guest_spec.rb @@ -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 diff --git a/spec/models/seat_spec.rb b/spec/models/seat_spec.rb index 2020f33..86140a2 100644 --- a/spec/models/seat_spec.rb +++ b/spec/models/seat_spec.rb @@ -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 diff --git a/spec/models/tables_arrangement_spec.rb b/spec/models/tables_arrangement_spec.rb index 4db0859..66e61ac 100644 --- a/spec/models/tables_arrangement_spec.rb +++ b/spec/models/tables_arrangement_spec.rb @@ -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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 0277d58..ae4a2d5 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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 diff --git a/spec/models/wedding_spec.rb b/spec/models/wedding_spec.rb index 6ec8a3e..5664367 100644 --- a/spec/models/wedding_spec.rb +++ b/spec/models/wedding_spec.rb @@ -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