Sha256: b08e1b4f957a21905afbb55f275ec664218cbd1206858548493813c37d8fd177

Contents?: true

Size: 1.43 KB

Versions: 33

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

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|
            coerced_tests.push(method)
            coerced_test_warning(method)
          end
        end

        def coerce_all_tests!
          instance_methods(false).each do |method|
            next unless method.to_s =~ /\Atest/

            undef_method(method)
          end
          STDOUT.puts "🙉 🙈 🙊  Undefined all tests: #{name}"
        end

        private

        def coerced_test_warning(test_to_coerce)
          if test_to_coerce.is_a?(Regexp)
            method = instance_methods(false).select { |m| m =~ test_to_coerce }
          else
            method = test_to_coerce
          end

          Array(method).each do |m|
            result = if m && method_defined?(m)
                       alias_method("original_#{test_to_coerce.inspect.tr('/\:"', '')}", m)
                       undef_method(m)
                     end

            if result.blank?
              STDOUT.puts "🐳  Unfound coerced test: #{name}##{m}"
            else
              STDOUT.puts "🐵  Undefined coerced test: #{name}##{m}"
            end
          end
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
activerecord-sqlserver-adapter-7.1.11 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.2.4 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-8.0.2 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.1.10 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.2.3 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-8.0.1 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-8.0.0 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.2.2 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.1.9 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.1.8 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.2.1 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.2.0 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.1.7 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.1.6 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.1.5 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.1.4 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.0.7 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.1.3 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.1.2 test/support/coerceable_test_sqlserver.rb
activerecord-sqlserver-adapter-7.1.1 test/support/coerceable_test_sqlserver.rb