Sha256: 10db8a3f120b02a033c48a94ef8714d8050da0befa54463232a0a40e30f199cc
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 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 context "for views created in a schema other than 'public'" do it "creates view definition and migration files" do migration = file("db/migrate/create_non_public_searches.rb") view_definition = file("db/views/non_public_searches_v01.sql") run_generator ["non_public.search"] expect(migration).to be_a_migration expect(view_definition).to exist end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
scenic-1.5.1 | spec/generators/scenic/view/view_generator_spec.rb |
scenic-1.5.0 | spec/generators/scenic/view/view_generator_spec.rb |