diff --git a/spec/checkers/enum_type_checker/postgresql_spec.rb b/spec/checkers/enum_type_checker/postgresql_spec.rb index eda939e..7ab3cab 100644 --- a/spec/checkers/enum_type_checker/postgresql_spec.rb +++ b/spec/checkers/enum_type_checker/postgresql_spec.rb @@ -11,7 +11,11 @@ let(:enum) { entity_class.defined_enums.keys.first } let!(:entity_class) do define_class do |klass| - klass.enum field: { value1: 'value1', value2: 'value2' } + if ActiveRecord::VERSION::MAJOR >= 8 + klass.enum field: { value1: 'value1', value2: 'value2' } + else + klass.enum :field, { value1: 'value1', value2: 'value2' } + end end end diff --git a/spec/checkers/enum_type_checker_spec.rb b/spec/checkers/enum_type_checker_spec.rb index 228314c..ca8d5a4 100644 --- a/spec/checkers/enum_type_checker_spec.rb +++ b/spec/checkers/enum_type_checker_spec.rb @@ -7,7 +7,11 @@ let(:enum) { entity_class.defined_enums.keys.first } let!(:entity_class) do define_class do |klass| - klass.enum field: %i[value1 value2] + if ActiveRecord::VERSION::MAJOR >= 8 + klass.enum :field, %i[value1 value2] + else + klass.enum field: %i[value1 value2] + end end end diff --git a/spec/checkers/enum_value_checker_spec.rb b/spec/checkers/enum_value_checker_spec.rb index 57a93fb..7678130 100644 --- a/spec/checkers/enum_value_checker_spec.rb +++ b/spec/checkers/enum_value_checker_spec.rb @@ -29,7 +29,12 @@ context 'when values are consistent' do let(:klass) do define_class do |klass| - klass.enum :status, { value1: 'value1', value2: 'value2' } + if ActiveRecord::VERSION::MAJOR >= 8 + klass.enum :status, { value1: 'value1', value2: 'value2' } + else + klass.enum status: { value1: 'value1', value2: 'value2' } + end + klass.validates :status, inclusion: { in: %w[value1 value2] } end end @@ -94,7 +99,15 @@ end context 'when enum values are inconsistent' do - let(:klass) { define_class { |klass| klass.enum :status, { value1: 'value1', something: 'something' } } } + let(:klass) do + define_class do |klass| + if ActiveRecord::VERSION::MAJOR >= 8 + klass.enum :status, { value1: 'value1', something: 'something' } + else + klass.enum status: { value1: 'value1', something: 'something' } + end + end + end specify do expect(checker.report.first).to have_attributes( @@ -111,7 +124,15 @@ end context 'when enum values are out of order' do - let(:klass) { define_class { |klass| klass.enum :status, { value2: 'value2', value1: 'value1' } } } + let(:klass) do + define_class do |klass| + if ActiveRecord::VERSION::MAJOR >= 8 + klass.enum :status, { value2: 'value2', value1: 'value1' } + else + klass.enum status: { value2: 'value2', value1: 'value1' } + end + end + end specify do expect(checker.report.first).to have_attributes(