Sha256: b342359751331d1752eac2da3c36ba688ee1627aa38433c80284bc442f934d65

Contents?: true

Size: 1.15 KB

Versions: 16

Compression:

Stored size: 1.15 KB

Contents

module Ardb

  module AdapterSpy

    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
    end

    module InstanceMethods

      attr_accessor :drop_tables_called_count, :load_schema_called_count
      attr_accessor :drop_db_called_count, :create_db_called_count

      def drop_tables_called_count
        @drop_tables_called_count ||= 0
      end

      def drop_tables(*args, &block)
        self.drop_tables_called_count += 1
      end

      def load_schema_called_count
        @load_schema_called_count ||= 0
      end

      def load_schema(*args, &block)
        self.load_schema_called_count += 1
      end

      def drop_db_called_count
        @drop_db_called_count ||= 0
      end

      def drop_db(*args, &block)
        self.drop_db_called_count += 1
      end

      def create_db_called_count
        @create_db_called_count ||= 0
      end

      def create_db(*args, &block)
        self.create_db_called_count += 1
      end

    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ardb-0.24.0 lib/ardb/adapter_spy.rb
ardb-0.23.0 lib/ardb/adapter_spy.rb
ardb-0.22.1 lib/ardb/adapter_spy.rb
ardb-0.22.0 lib/ardb/adapter_spy.rb
ardb-0.21.0 lib/ardb/adapter_spy.rb
ardb-0.20.0 lib/ardb/adapter_spy.rb
ardb-0.19.0 lib/ardb/adapter_spy.rb
ardb-0.18.0 lib/ardb/adapter_spy.rb
ardb-0.17.0 lib/ardb/adapter_spy.rb
ardb-0.16.0 lib/ardb/adapter_spy.rb
ardb-0.15.0 lib/ardb/adapter_spy.rb
ardb-0.14.0 lib/ardb/adapter_spy.rb
ardb-0.13.0 lib/ardb/adapter_spy.rb
ardb-0.12.0 lib/ardb/adapter_spy.rb
ardb-0.11.0 lib/ardb/adapter_spy.rb
ardb-0.10.0 lib/ardb/adapter_spy.rb