Skip to content
Browse files

Add a few specs for better coverage

  • Loading branch information...
1 parent 0859d65 commit 1c743b3f435e1ee3e9ffdc07c5d3dea19de001f3 @jeremyevans committed
Showing with 36 additions and 0 deletions.
  1. +32 −0 spec/core/database_spec.rb
  2. +4 −0 spec/core/schema_generator_spec.rb
View
32 spec/core/database_spec.rb
@@ -479,6 +479,26 @@ def @o.to_ary; [self]; end
end
end
+describe "Database#disconnect_connection" do
+ specify "should call close on the connection" do
+ o = Object.new
+ def o.close() @closed=true end
+ Sequel::Database.new.disconnect_connection(o)
+ o.instance_variable_get(:@closed).should be_true
+ end
+end
+
+describe "Database#valid_connection?" do
+ specify "should issue a query to validate the connection" do
+ db = Sequel.mock
+ db.synchronize{|c| db.valid_connection?(c)}.should be_true
+ db.synchronize do |c|
+ def c.execute(*) raise Sequel::DatabaseError, "error" end
+ db.valid_connection?(c)
+ end.should be_false
+ end
+end
+
describe "Database#execute" do
specify "should raise Sequel::NotImplemented" do
proc {Sequel::Database.new.execute('blah blah')}.should raise_error(Sequel::NotImplemented)
@@ -2018,6 +2038,18 @@ def @db.dc; @dc end
end
end
+describe "Database#supports_deferrable_constraints?" do
+ specify "should be false by default" do
+ Sequel::Database.new.supports_deferrable_constraints?.should == false
+ end
+end
+
+describe "Database#supports_deferrable_foreign_key_constraints?" do
+ specify "should be false by default" do
+ Sequel::Database.new.supports_deferrable_foreign_key_constraints?.should == false
+ end
+end
+
describe "Database#supports_transactional_ddl?" do
specify "should be false by default" do
Sequel::Database.new.supports_transactional_ddl?.should == false
View
4 spec/core/schema_generator_spec.rb
@@ -19,6 +19,10 @@
@columns, @indexes, @constraints = @generator.columns, @generator.indexes, @generator.constraints
end
+ it "should respond to everything" do
+ @generator.respond_to?(:foo).should be_true
+ end if RUBY_VERSION >= '1.9'
+
it "should primary key column first" do
@columns.first[:name].should == :id
@columns.first[:primary_key].should == true

0 comments on commit 1c743b3

Please sign in to comment.
Something went wrong with that request. Please try again.