Sha256: bae462d008161ccf1feac079714fecd6de3bd8ac7867c448a2922f9689386949

Contents?: true

Size: 1.11 KB

Versions: 19

Compression:

Stored size: 1.11 KB

Contents

module ARTest
  module SQLServer
    module CoerceableTest

      extend ActiveSupport::Concern

      included do
        cattr_accessor :coerced_tests, instance_accessor: false
        self.coerced_tests = []
      end

      module ClassMethods

        def coerce_tests!(*methods)
          methods.each do |method|
            self.coerced_tests.push(method)
            coerced_test_warning(method)
          end
        end

        def coerce_all_tests!
          once = false
          instance_methods(false).each do |method|
            next unless method.to_s =~ /\Atest/
            undef_method(method)
            once = true
          end
          STDOUT.puts "Info: Undefined all tests: #{self.name}"
        end

        private

        def coerced_test_warning(method)
          method = instance_methods(false).select { |m| m =~ method } if method.is_a?(Regexp)
          Array(method).each do |m|
            result = undef_method(m) if m && method_defined?(m)
            STDOUT.puts "Info: Undefined coerced test: #{self.name}##{m}" unless result.blank?
          end
        end

      end

    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
activerecord-sqlserver-adapter-4.2.18 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.17 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.16 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter_new-4.2.15 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.15 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.13 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.12 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.11 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.10 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.9 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.8 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.6 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.5 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.4 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.3 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.2 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.1 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.0 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-4.2.0.pre test/support/coerceable_test_sqlserver.rb