Sha256: e7d15fd9aa25fc5a323f857cec2c005199fac61d2e8fe0aac086df03d3661217

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper'

describe Sequel::Postgres::Schemata do
  
  let(:db) { Sequel::connect adapter: 'postgres', search_path: %w(foo public) } 

  describe "#schemata" do
    it "lists all existing schematas" do
      schemata = db.schemata
      schemata.should include(:public)
      schemata.should_not include(:foo)
    end
  end
  
  describe "#search_path" do
    it "returns the search path" do
      db.search_path.should == %i(foo public)
    end
  end
  
  describe "#search_path=" do
    it "accepts a single symbol" do
      db.search_path = %i(bar)
      db.search_path.should == %i(bar)
    end
    
    it "accepts a single string" do
      db.search_path = 'bar'
      db.search_path.should == %i(bar)
    end
    
    it "accepts a formatted string" do
      db.search_path = 'bar, baz'
      db.search_path.should == %i(bar baz)
    end
    
    it "accepts a symbol list" do
      db.search_path = %i(bar baz)
      db.search_path.should == %i(bar baz)
    end
    
    it "accepts a string list" do
      db.search_path = %w(bar baz)
      db.search_path.should == %i(bar baz)
    end

    it "quotes the string list" do
      db.search_path = %w(bar, baz)
      db.search_path.should == %i(bar, baz)
    end
  end
  
  describe "#current_schemata" do
    it "returns the current schemata" do
      db.current_schemata.should == %i(public)
    end
  end
  
  describe "#rename_schema" do
    it "renames a schema" do
      db.transaction rollback: :always do
        db.create_schema :test_schema
        db.schemata.should include(:test_schema)
        db.current_schemata.should == %i(public)
        db.rename_schema :test_schema, :foo
        db.current_schemata.should == %i(foo public)
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sequel-postgres-schemata-0.0.1 spec/schemata_spec.rb