Sha256: 0f11b7e59ebb8fa0c4a571e56fa3be7ae2f444b66dcecff39a1c810f9b6939ef
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
require "spec_helper" require "generators/fx/function/function_generator" RSpec.describe Fx::Generators::FunctionGenerator, :generator do it "creates a function definition file, and a migration" do migration = file("db/migrate/create_function_test.rb") function_definition = file("db/functions/test_v01.sql") run_generator ["test"] expect(function_definition).to exist expect(migration).to be_a_migration expect(migration_file(migration)).to contain("CreateFunctionTest") end context "when passed --no-migration" do it "creates a only function definition file" do migration = file("db/migrate/create_function_test.rb") function_definition = file("db/functions/test_v01.sql") run_generator ["test", "--no-migration"] expect(function_definition).to exist expect(Pathname.new(migration_file(migration))).not_to exist end end it "updates an existing function" do with_function_definition( name: "test", version: 1, sql_definition: "hello" ) do allow(Dir).to receive(:entries).and_return(["test_v01.sql"]) migration = file("db/migrate/update_function_test_to_version_2.rb") function_definition = file("db/functions/test_v02.sql") run_generator ["test"] expect(function_definition).to exist expect(migration).to be_a_migration expect(migration_file(migration)) .to contain("UpdateFunctionTestToVersion2") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fx-0.9.0 | spec/generators/fx/function/function_generator_spec.rb |