Sha256: cbb1ec19600ac9566ecbbc330bddcc669c4868b0e7c4fd967ac37ec45a33ec7a

Contents?: true

Size: 920 Bytes

Versions: 5

Compression:

Stored size: 920 Bytes

Contents

require_relative '../spec_helper'

describe Dependor::ClassNameResolver do
  class FooBarBaz
  end

  class FooBarBaz2
  end

  module Foo
    class FooBarBaz
    end
  end

  module Bar
    class FooBarBaz
    end
  end

  it "returns nil when the class could not be found" do
    resolver = Dependor::ClassNameResolver.new([])

    resolver.for_name(:something).should be_nil
  end

  it "uses global scope with no search_modules" do
    resolver = Dependor::ClassNameResolver.new([])

    resolver.for_name(:foo_bar_baz).should == FooBarBaz
  end

  it "searches modules in order specified" do
    resolver = Dependor::ClassNameResolver.new([Foo, Bar])

    resolver.for_name(:foo_bar_baz).should == Foo::FooBarBaz
  end

  it "searches in order specified, with the global scope last" do
    resolver = Dependor::ClassNameResolver.new([Foo, Bar])

    resolver.for_name(:foo_bar_baz_2).should == FooBarBaz2
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dependor-0.0.5 spec/dependor/class_name_resolver_spec.rb
dependor-0.0.4 spec/dependor/class_name_resolver_spec.rb
dependor-0.0.3 spec/dependor/class_name_resolver_spec.rb
dependor-0.0.2 spec/dependor/class_name_resolver_spec.rb
dependor-0.0.1 spec/dependor/class_name_resolver_spec.rb