lib/gumboot/shared_examples/database_schema.rb in aaf-gumboot-2.0.1 vs lib/gumboot/shared_examples/database_schema.rb in aaf-gumboot-2.1.0
- old
+ new
@@ -1,14 +1,14 @@
# frozen_string_literal: true
RSpec.shared_examples 'Database Schema' do
context 'AAF shared implementation' do
- RSpec::Matchers.define :have_collation do |expected, name|
- match { |actual| actual[:Collation] == expected }
+ RSpec::Matchers.define :have_collations do |expected, name|
+ match { |actual| expected.include?[actual[:Collation]] }
failure_message do |actual|
- "expected #{name} to use collation #{expected}, but was " \
+ "expected #{name} to use collation #{expected.join(' or ')}, but was " \
"#{actual[:Collation]}"
end
end
before { expect(connection).to be_a(Mysql2::Client) }
@@ -33,22 +33,24 @@
expect(db_collation).to eq('utf8_bin')
query('SHOW TABLE STATUS').each do |table|
table_name = table[:Name]
next if table_name == 'schema_migrations'
- expect(table).to have_collation('utf8_bin', "`#{table_name}`")
+ expect(table).to(
+ have_collations(%w[utf8_bin utf8mb4_bin], "`#{table_name}`")
+ )
query("SHOW FULL COLUMNS FROM #{table_name}").each do |column|
next unless column[:Collation]
next if exemptions.any? do |except_table, except_columns|
except_table == table_name.to_sym &&
except_columns.any? do |except_column|
except_column == column[:Field].to_sym
end
end
expect(column)
- .to have_collation('utf8_bin',
- " `#{table_name}`.`#{column[:Field]}`")
+ .to have_collations(%w[utf8_bin utf8mb4_bin],
+ " `#{table_name}`.`#{column[:Field]}`")
end
end
end
end
end