Sha256: 38d02c5013f7855fd9f8137ce8af9340cecbf5ed9e45a4ad7cbca57d84d57976

Contents?: true

Size: 1.23 KB

Versions: 23

Compression:

Stored size: 1.23 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 "🙉 🙈 🙊  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)
            if result.blank?
              STDOUT.puts "🐳  Unfound coerced test: #{self.name}##{m}"
            else
              STDOUT.puts "🐵  Undefined coerced test: #{self.name}##{m}"
            end
          end
        end

      end

    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
activerecord-jdbcsqlserver-adapter-52.0.0 test/support/coerceable_test_sqlserver.rb
activerecord-jdbcsqlserver-adapter-51.1.0 test/support/coerceable_test_sqlserver.rb
activerecord-jdbcsqlserver-adapter-50.1.0 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-5.2.1 test/support/coerceable_test_sqlserver.rb
activerecord-jdbcsqlserver-adapter-51.0.1 test/support/coerceable_test_sqlserver.rb
activerecord-jdbcsqlserver-adapter-51.0.0 test/support/coerceable_test_sqlserver.rb
activerecord-jdbcsqlserver-adapter-50.0.0 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-5.2.0 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-5.2.0.rc2 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-5.2.0.rc1 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-5.1.6 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-5.0.8 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-5.1.5 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-5.1.2 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-5.1.1 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-5.1.0 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-5.0.7 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-5.0.6 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-5.0.5 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-5.0.4 test/support/coerceable_test_sqlserver.rb