Sha256: 0a2315f4518bb48a462905c4c32121f0dbf325ccf8cf3ea33a8eecdf07a97cbb
Contents?: true
Size: 1.46 KB
Versions: 4
Compression:
Stored size: 1.46 KB
Contents
require File.dirname(__FILE__) + '/base' require File.dirname(__FILE__) + '/../lib/taps/schema' describe Taps::Schema do before do Taps::AdapterHacks.stubs(:load) @connection = mock("AR connection") ActiveRecord::Base.stubs(:connection).returns(@connection) end it "parses a database url and returns a config hash for activerecord" do Taps::Schema.create_config("postgres://myuser:mypass@localhost/mydb").should == { 'adapter' => 'postgresql', 'database' => 'mydb', 'username' => 'myuser', 'password' => 'mypass', 'host' => 'localhost' } end it "translates sqlite in the database url to sqlite3" do Taps::Schema.create_config("sqlite://myuser:mypass@localhost/mydb")['adapter'].should == 'sqlite3' end it "connects activerecord to the database" do Taps::Schema.expects(:create_config).with("postgres://myuser:mypass@localhost/mydb").returns("db config") ActiveRecord::Base.expects(:establish_connection).with("db config").returns(true) Taps::Schema.connection("postgres://myuser:mypass@localhost/mydb").should == true end it "resets the db tables' primary keys" do Taps::Schema.stubs(:connection) ActiveRecord::Base.connection.expects(:respond_to?).with(:reset_pk_sequence!).returns(true) ActiveRecord::Base.connection.stubs(:tables).returns(['table1']) ActiveRecord::Base.connection.expects(:reset_pk_sequence!).with('table1') should.not.raise { Taps::Schema.reset_db_sequences("postgres://myuser:mypass@localhost/mydb") } end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
ricardochimal-taps-0.2.5 | spec/schema_spec.rb |
ricardochimal-taps-0.2.6 | spec/schema_spec.rb |
taps-0.2.5 | spec/schema_spec.rb |
taps-0.2.6 | spec/schema_spec.rb |