lib/ardb/adapter_spy.rb in ardb-0.26.0 vs lib/ardb/adapter_spy.rb in ardb-0.27.0

- old
+ new

@@ -1,28 +1,29 @@ +require 'much-plugin' + module Ardb module AdapterSpy + include MuchPlugin def self.new(&block) block ||= proc{ } record_spy = Class.new{ include Ardb::AdapterSpy } record_spy.class_eval(&block) record_spy end - def self.included(klass) - klass.class_eval do - include InstanceMethods - end + plugin_included do + include InstanceMethods end module InstanceMethods attr_accessor :drop_tables_called_count attr_accessor :dump_schema_called_count, :load_schema_called_count attr_accessor :drop_db_called_count, :create_db_called_count - attr_accessor :migrate_db_called_count + attr_accessor :connect_db_called_count, :migrate_db_called_count def drop_tables_called_count @drop_tables_called_count ||= 0 end @@ -78,9 +79,21 @@ self.create_db_called_count > 0 end def create_db(*args, &block) self.create_db_called_count += 1 + end + + def connect_db_called_count + @connect_db_called_count ||= 0 + end + + def connect_db_called? + self.connect_db_called_count > 0 + end + + def connect_db(*args, &block) + self.connect_db_called_count += 1 end def migrate_db_called_count @migrate_db_called_count ||= 0 end