Sha256: 6fcdc9dbeaa22f3b237ea7803b75889d936f64baf29c2643ee4fdc1315f28eda

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

require 'test_helper'

class MirrorsTest < MiniTest::Test
  def test_modules
    modules = Mirrors.modules.collect(&:name)
    assert_includes(modules, "ReflectModule")
    refute_includes(modules, "ReflectClass")
  end

  def test_classes
    classes = Mirrors.classes.collect(&:name)
    refute_includes(classes, "ReflectModule")
    assert_includes(classes, "ReflectClass")
  end

  def test_instances_of
    klass1 = Class.new
    klass2 = Class.new(klass1)
    inst1 = klass1.new
    inst2 = klass2.new
    instances = Mirrors.instances_of(klass1).map(&:name)
    assert_includes(instances, inst1.inspect)
    refute_includes(instances, inst2.inspect)
  end

  def test_object_by_id
    o = Object.new
    assert_equal(o.inspect, Mirrors.object_by_id(o.object_id).name)
  end

  def test_implementations_of
    l = Mirrors.implementations_of("unique_reflect_fixture_method")
    assert_equal(Array, l.class)
    assert_equal(1, l.size)
    assert_equal("unique_reflect_fixture_method", l.first.selector)
    assert_equal("ReflectClass", l.first.defining_class.name)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mirrors-0.0.3 test/mirrors_test.rb
mirrors-0.0.2 test/mirrors_test.rb
mirrors-0.0.1 test/mirrors_test.rb