|
6 | 6 | migration = file("db/migrate/create_trigger_test.rb") |
7 | 7 | trigger_definition = file("db/triggers/test_v01.sql") |
8 | 8 |
|
9 | | - run_generator ["test", "table_name" => "some_table"] |
| 9 | + run_generator( |
| 10 | + described_class, |
| 11 | + ["test", {"table_name" => "some_table"}] |
| 12 | + ) |
10 | 13 |
|
11 | 14 | expect(trigger_definition).to exist |
12 | | - expect(migration).to be_a_migration |
13 | | - expect(migration_file(migration)).to contain("CreateTriggerTest") |
14 | | - expect(migration_file(migration)).to contain("on: :some_table") |
| 15 | + expect_to_be_a_migration(migration) |
| 16 | + expect(migration_content(migration)).to include("CreateTriggerTest") |
| 17 | + expect(migration_content(migration)).to include("on: :some_table") |
15 | 18 | end |
16 | 19 |
|
17 | 20 | context "when passed --no-migration" do |
18 | 21 | it "creates a only trigger definition file" do |
19 | 22 | migration = file("db/migrate/create_trigger_test.rb") |
20 | 23 | trigger_definition = file("db/triggers/test_v01.sql") |
21 | 24 |
|
22 | | - run_generator ["test", {"table_name" => "some_table"}, "--no-migration"] |
| 25 | + run_generator( |
| 26 | + described_class, |
| 27 | + ["test", {"table_name" => "some_table"}], |
| 28 | + {migration: false} |
| 29 | + ) |
23 | 30 |
|
24 | 31 | expect(trigger_definition).to exist |
25 | | - expect(Pathname.new(migration_file(migration))).not_to exist |
| 32 | + expect(migration).not_to exist |
26 | 33 | end |
27 | 34 | end |
28 | 35 |
|
29 | 36 | it "supports naming the table as `on` aswell as `table_name`" do |
30 | 37 | migration = file("db/migrate/create_trigger_test.rb") |
31 | 38 | trigger_definition = file("db/triggers/test_v01.sql") |
32 | 39 |
|
33 | | - run_generator ["test", "on" => "some_table"] |
| 40 | + run_generator( |
| 41 | + described_class, |
| 42 | + ["test", {"on" => "some_table"}] |
| 43 | + ) |
34 | 44 |
|
35 | 45 | expect(trigger_definition).to exist |
36 | | - expect(migration).to be_a_migration |
37 | | - expect(migration_file(migration)).to contain("CreateTriggerTest") |
38 | | - expect(migration_file(migration)).to contain("on: :some_table") |
| 46 | + expect_to_be_a_migration(migration) |
| 47 | + expect(migration_content(migration)).to include("CreateTriggerTest") |
| 48 | + expect(migration_content(migration)).to include("on: :some_table") |
39 | 49 | end |
40 | 50 |
|
41 | 51 | it "requires `table_name` or `on` to be specified" do |
42 | 52 | expect do |
43 | | - run_generator ["test", "foo" => "some_table"] |
| 53 | + run_generator( |
| 54 | + described_class, |
| 55 | + ["test", {"foo" => "some_table"}] |
| 56 | + ) |
44 | 57 | end.to raise_error(ArgumentError) |
45 | 58 | end |
46 | 59 |
|
|
49 | 62 | migration = file("db/migrate/update_trigger_test_to_version_2.rb") |
50 | 63 | trigger_definition = file("db/triggers/test_v02.sql") |
51 | 64 |
|
52 | | - run_generator ["test", "table_name" => "some_table"] |
| 65 | + run_generator( |
| 66 | + described_class, |
| 67 | + ["test", {"table_name" => "some_table"}] |
| 68 | + ) |
53 | 69 |
|
54 | 70 | expect(trigger_definition).to exist |
55 | | - expect(migration).to be_a_migration |
56 | | - expect(migration_file(migration)).to contain("UpdateTriggerTestToVersion2") |
57 | | - expect(migration_file(migration)).to contain("on: :some_table") |
| 71 | + expect_to_be_a_migration(migration) |
| 72 | + expect(migration_content(migration)).to include("UpdateTriggerTestToVersion2") |
| 73 | + expect(migration_content(migration)).to include("on: :some_table") |
58 | 74 | end |
59 | 75 | end |
0 commit comments