|
5 | 5 | describe "#previous_version" do |
6 | 6 | it "returns 0 when no existing versions found" do |
7 | 7 | temp_dir = create_temp_directory |
8 | | - helper = described_class.new("test_function", temp_dir) |
| 8 | + helper = described_class.new(file_name: "test_function", definition_path: temp_dir) |
9 | 9 |
|
10 | 10 | expect(helper.previous_version).to eq(0) |
11 | 11 | end |
|
16 | 16 | create_version_file(temp_dir, "test_function", 3) |
17 | 17 | create_version_file(temp_dir, "test_function", 2) |
18 | 18 |
|
19 | | - helper = described_class.new("test_function", temp_dir) |
| 19 | + helper = described_class.new(file_name: "test_function", definition_path: temp_dir) |
20 | 20 |
|
21 | 21 | expect(helper.previous_version).to eq(3) |
22 | 22 | end |
|
27 | 27 | FileUtils.touch(temp_dir.join("other_function_v3.sql")) |
28 | 28 | FileUtils.touch(temp_dir.join("test_function.sql")) |
29 | 29 |
|
30 | | - helper = described_class.new("test_function", temp_dir) |
| 30 | + helper = described_class.new(file_name: "test_function", definition_path: temp_dir) |
31 | 31 |
|
32 | 32 | expect(helper.previous_version).to eq(2) |
33 | 33 | end |
|
38 | 38 | temp_dir = create_temp_directory |
39 | 39 | create_version_file(temp_dir, "test_function", 5) |
40 | 40 |
|
41 | | - helper = described_class.new("test_function", temp_dir) |
| 41 | + helper = described_class.new(file_name: "test_function", definition_path: temp_dir) |
42 | 42 |
|
43 | 43 | expect(helper.current_version).to eq(6) |
44 | 44 | end |
45 | 45 |
|
46 | 46 | it "returns 1 when no previous versions exist" do |
47 | 47 | temp_dir = create_temp_directory |
48 | | - helper = described_class.new("test_function", temp_dir) |
| 48 | + helper = described_class.new(file_name: "test_function", definition_path: temp_dir) |
49 | 49 |
|
50 | 50 | expect(helper.current_version).to eq(1) |
51 | 51 | end |
|
54 | 54 | describe "#updating_existing?" do |
55 | 55 | it "returns false when no previous versions exist" do |
56 | 56 | temp_dir = create_temp_directory |
57 | | - helper = described_class.new("test_function", temp_dir) |
| 57 | + helper = described_class.new(file_name: "test_function", definition_path: temp_dir) |
58 | 58 |
|
59 | 59 | expect(helper.updating_existing?).to be false |
60 | 60 | end |
|
63 | 63 | temp_dir = create_temp_directory |
64 | 64 | create_version_file(temp_dir, "test_function", 1) |
65 | 65 |
|
66 | | - helper = described_class.new("test_function", temp_dir) |
| 66 | + helper = described_class.new(file_name: "test_function", definition_path: temp_dir) |
67 | 67 |
|
68 | 68 | expect(helper.updating_existing?).to be true |
69 | 69 | end |
|
72 | 72 | describe "#creating_new?" do |
73 | 73 | it "returns true when no previous versions exist" do |
74 | 74 | temp_dir = create_temp_directory |
75 | | - helper = described_class.new("test_function", temp_dir) |
| 75 | + helper = described_class.new(file_name: "test_function", definition_path: temp_dir) |
76 | 76 |
|
77 | 77 | expect(helper.creating_new?).to be true |
78 | 78 | end |
|
81 | 81 | temp_dir = create_temp_directory |
82 | 82 | create_version_file(temp_dir, "test_function", 1) |
83 | 83 |
|
84 | | - helper = described_class.new("test_function", temp_dir) |
| 84 | + helper = described_class.new(file_name: "test_function", definition_path: temp_dir) |
85 | 85 |
|
86 | 86 | expect(helper.creating_new?).to be false |
87 | 87 | end |
|
90 | 90 | describe "#definition_for_version" do |
91 | 91 | it "returns function definition for function type" do |
92 | 92 | temp_dir = create_temp_directory |
93 | | - helper = described_class.new("test_function", temp_dir) |
| 93 | + helper = described_class.new(file_name: "test_function", definition_path: temp_dir) |
94 | 94 | allow(Fx::Definition).to receive(:function) |
95 | 95 | .and_return("function_definition") |
96 | 96 |
|
97 | | - result = helper.definition_for_version(2, :function) |
| 97 | + result = helper.definition_for_version(version: 2, type: :function) |
98 | 98 |
|
99 | 99 | expect(result).to eq("function_definition") |
100 | 100 | expect(Fx::Definition).to have_received(:function).with( |
|
105 | 105 |
|
106 | 106 | it "returns trigger definition for trigger type" do |
107 | 107 | temp_dir = create_temp_directory |
108 | | - helper = described_class.new("test_trigger", temp_dir) |
| 108 | + helper = described_class.new(file_name: "test_trigger", definition_path: temp_dir) |
109 | 109 | allow(Fx::Definition).to receive(:trigger) |
110 | 110 | .and_return("trigger_definition") |
111 | 111 |
|
112 | | - result = helper.definition_for_version(3, :trigger) |
| 112 | + result = helper.definition_for_version(version: 3, type: :trigger) |
113 | 113 |
|
114 | 114 | expect(result).to eq("trigger_definition") |
115 | 115 | expect(Fx::Definition).to have_received(:trigger).with( |
|
120 | 120 |
|
121 | 121 | it "raises error for unknown type" do |
122 | 122 | temp_dir = create_temp_directory |
123 | | - helper = described_class.new("test_function", temp_dir) |
| 123 | + helper = described_class.new(file_name: "test_function", definition_path: temp_dir) |
124 | 124 |
|
125 | 125 | expect { |
126 | | - helper.definition_for_version(1, :unknown) |
| 126 | + helper.definition_for_version(version: 1, type: :unknown) |
127 | 127 | }.to raise_error( |
128 | 128 | ArgumentError, |
129 | 129 | "Unknown type: unknown. Must be :function or :trigger" |
|
0 commit comments