File tree Expand file tree Collapse file tree
fixtures/constant_discovery/valid/app/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ def coerce_load_paths(load_paths)
123123 load_paths = Hash [ load_paths . map { |p | [ p , "Object" ] } ] unless load_paths . respond_to? ( :transform_keys )
124124
125125 load_paths . transform_keys! { |p | p . end_with? ( "/" ) ? p : p + "/" }
126- load_paths . transform_values! { |ns | ns . delete_prefix ( "::" ) }
126+ load_paths . transform_values! { |ns | ns . to_s . delete_prefix ( "::" ) }
127127
128128 load_paths
129129 end
Original file line number Diff line number Diff line change @@ -43,11 +43,14 @@ def test_discovers_simple_constant
4343 end
4444
4545 def test_resolves_constants_from_non_default_root_path_namespace
46+ Object . const_set ( :Api , Module . new )
47+
4648 resolver = ConstantResolver . new (
4749 root_path : "test/fixtures/constant_discovery/valid/" ,
4850 load_paths : {
49- "app/models" => "::Object" ,
50- "app/rest_api" => "::Api" ,
51+ "app/models" => Object ,
52+ "app/rest_api" => Api ,
53+ "app/internal" => "::Company::Internal" ,
5154 } ,
5255 )
5356
@@ -58,6 +61,10 @@ def test_resolves_constants_from_non_default_root_path_namespace
5861 constant = resolver . resolve ( "Api::Repositories" )
5962 assert_equal ( "::Api::Repositories" , constant . name )
6063 assert_equal ( "app/rest_api/repositories.rb" , constant . location )
64+
65+ constant = resolver . resolve ( "Company::Internal::Main" )
66+ assert_equal ( "::Company::Internal::Main" , constant . name )
67+ assert_equal ( "app/internal/main.rb" , constant . location )
6168 end
6269
6370 def test_resolve_returns_constant_context
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ module Company
4+ module Internal
5+ class Main
6+ end
7+ end
8+ end
You can’t perform that action at this time.
0 commit comments