Sha256: d9b913523ebf4ecde92ed2bc20d4ad9507eed1c668a22b7fa1f708c91761ac40

Contents?: true

Size: 1.82 KB

Versions: 4

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

old_verbose = $VERBOSE
$VERBOSE = false
begin
  require "test-prof"

  TestProf::RubyProf.configure do |config|
    config.min_percent = 0.5
  end
rescue LoadError
  warn "test-prof not available"
end
$VERBOSE = old_verbose

if ENV["CI"]
  begin
    require "coveralls"
    Coveralls.wear!
  rescue LoadError
    nil
  end
end

require "minitest/autorun"
require "rspec/mocks/minitest_integration"

Thread.abort_on_exception = true

module BaseTestExtensions
  def assert_defines_singleton_method(klass, method, msg = nil)
    method = method.to_sym
    methods = klass.singleton_methods(false).map(&:to_sym)
    msg = message(msg) do
      "Expected #{mu_pp(klass)} to define singleton method #{mu_pp(method)}, " \
        "but only found #{mu_pp(methods)}"
    end
    assert_includes methods, method, msg
  end

  def refute_defines_singleton_method(klass, method, msg = nil)
    method = method.to_sym
    methods = klass.singleton_methods(false).map(&:to_sym)
    msg = message(msg) do
      "Expected #{mu_pp(klass)} not to define singleton method #{mu_pp(method)}"
    end
    refute_includes methods, method, msg
  end

  def assert_defines_instance_method(klass, method, msg = nil)
    method = method.to_sym
    methods = klass.instance_methods(false).map(&:to_sym)
    msg = message(msg) do
      "Expected #{mu_pp(klass)} to define instance method #{mu_pp(method)}, " \
        "but only found #{mu_pp(methods)}"
    end
    assert_includes methods, method, msg
  end

  def refute_defines_instance_method(klass, method, msg = nil)
    method = method.to_sym
    methods = klass.instance_methods(false).map(&:to_sym)
    msg = message(msg) do
      "Expected #{mu_pp(klass)} not to define instance method #{mu_pp(method)}"
    end
    refute_includes methods, method, msg
  end
end

Minitest::Test.include BaseTestExtensions

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gir_ffi-0.15.3 test/base_test_helper.rb
gir_ffi-0.15.2 test/base_test_helper.rb
gir_ffi-0.15.1 test/base_test_helper.rb
gir_ffi-0.15.0 test/base_test_helper.rb