Sha256: 97989c9eb742e92f4abce1e42193ce624b52e0459f260d6db30b3af7114ac7c0

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require 'test_helper'

class AutoloadingTest < Minitest::Test
  include FakesFilesystem
  include TestsAutoloading

  def test_simple_case
    assert_equal 'hello from A::AA', Foo::A.references_aa
  end

  def test_negative_case
    assert_raises NameError do
      Foo::A.references_abracadabra
    end
  end

  def test_deeply_nested_module_with_implicit_namespaces
    assert_equal 'hello from C::CA::CAA::CAAA', Foo::A.references_caaa
  end

  def test_reference_from_within_constant
    assert_equal 'hello from A', Foo::D.references_a
    assert_equal 'hello from B::BA', Foo::D.new.references_b_ba
  end

  def test_invoking_method_inside_implicit_namespace_raises_error
    exception = assert_raises NameError do
      Foo::C.hello
    end
    assert_equal "uninitialized constant C (in Foo)", exception.message
  end

  def test_raises_name_error_if_no_context_found
    exception = assert_raises NameError do
      Abracadabra
    end
    assert_equal "uninitialized constant Abracadabra", exception.message
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
truck-0.8.0 test/integration/autoloading_test.rb