Skip to content

Commit 3a9499b

Browse files
committed
expect value object
1 parent 2c389c3 commit 3a9499b

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/foreign_key_on_event_id_migration_generator.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
module RubyEventStore
44
module ActiveRecord
55
class ForeignKeyOnEventIdMigrationGenerator
6-
def call(database_adapter_name, migration_path)
7-
database_adapter = DatabaseAdapter.from_string(database_adapter_name)
6+
def call(database_adapter, migration_path)
87
each_migration(database_adapter) do |migration_name|
98
path = build_path(migration_path, migration_name)
109
write_to_file(path, migration_code(database_adapter, migration_name))

ruby_event_store-active_record/spec/foreign_key_on_event_id_migration_generator_spec.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ module ActiveRecord
1919

2020
before { allow(Time).to receive(:now).and_return(Time.new(2022, 11, 30, 21, 37, 00)) }
2121

22-
%w[mysql2 postgresql sqlite].each do |adapter|
22+
[DatabaseAdapter::MySQL, DatabaseAdapter::SQLite, DatabaseAdapter::PostgreSQL].each do |adapter_class|
23+
adapter = adapter_class.new
2324
specify "it is created within specified directory" do
2425
migration_generator(adapter, @dir)
2526

@@ -51,13 +52,14 @@ module ActiveRecord
5152

5253
context "when postgresql adapter is used" do
5354
specify "should do migration in two steps" do
54-
migration_generator('postgresql', @dir)
55+
migration_generator(DatabaseAdapter::PostgreSQL.new, @dir)
5556
expect(second_step_migration_exists?(@dir)).to be_truthy
5657
expect(generated_files_count(@dir)).to eq(2)
5758
end
5859
end
5960

60-
%w[mysql2 sqlite].each do |adapter|
61+
[DatabaseAdapter::MySQL, DatabaseAdapter::SQLite].each do |adapter_class|
62+
adapter = adapter_class.new
6163
context "when #{adapter} adapter is used" do
6264
specify "should do migration in single step" do
6365
migration_generator(adapter, @dir)
@@ -66,10 +68,6 @@ module ActiveRecord
6668
end
6769
end
6870

69-
specify "unsupported adapter raises error" do
70-
expect { migration_generator('unsupported', @dir) }.to raise_error(UnsupportedAdapter)
71-
end
72-
7371
private
7472

7573
def migration_generator(adapter, dir)

0 commit comments

Comments
 (0)