Sha256: ab17f5fddbb9aa08895a72e7ea6e84980ff99edb3f71b0d1b9673d6af41589a3

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require "spec_helper"

module Scenic
  module Adapters
    describe Postgres, :db do
      describe "create_view" do
        it "successfully creates a view" do
          Postgres.create_view("greetings", "SELECT text 'hi' AS greeting")

          expect(Postgres.views.map(&:name)).to include("greetings")
        end
      end

      describe "drop_view" do
        it "successfully drops a view" do
          Postgres.create_view("greetings", "SELECT text 'hi' AS greeting")

          Postgres.drop_view("greetings")

          expect(Postgres.views.map(&:name)).not_to include("greetings")
        end
      end

      describe "views" do
        it "finds views and builds Scenic::View objects" do
          ActiveRecord::Base.connection.execute "CREATE VIEW greetings AS SELECT text 'hi' AS greeting"

          expect(Postgres.views).to eq([
            View.new(
              "viewname" => "greetings",
              "definition" => "SELECT 'hi'::text AS greeting;",
            ),
          ])
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scenic-0.3.0 spec/scenic/adapters/postgres_spec.rb
scenic-0.2.1 spec/scenic/adapters/postgres_spec.rb
scenic-0.2.0 spec/scenic/adapters/postgres_spec.rb