Sha256: 876dda2844b856ee8975c050881fea529ec6a7ead75c3d3e539ce3c03a6cb2d4
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
require "spec_helper" require "generators/scenic/view/view_generator" describe Scenic::Generators::ViewGenerator, :generator do it "creates view definition and migration files" do migration = file("db/migrate/create_searches.rb") view_definition = file("db/views/searches_v01.sql") run_generator ["search"] expect(migration).to be_a_migration expect(view_definition).to exist end it "updates an existing view" do with_view_definition("searches", 1, "hello") do migration = file("db/migrate/update_searches_to_version_2.rb") view_definition = file("db/views/searches_v02.sql") allow(Dir).to receive(:entries).and_return(["searches_v01.sql"]) run_generator ["search"] expect(migration).to be_a_migration expect(view_definition).to exist end end it "adds 'materialized: true' to the migration if view is materialized" do with_view_definition("aired_episodes", 1, "hello") do allow(Dir).to receive(:entries).and_return(["aired_episodes_v01.sql"]) run_generator ["aired_episode", "--materialized"] migration = migration_file( "db/migrate/update_aired_episodes_to_version_2.rb" ) expect(migration).to contain "materialized: true" end end end
Version data entries
3 entries across 3 versions & 1 rubygems