@@ -7,11 +7,9 @@ class GemTest < Minitest::Spec
77 describe TinyTds ::Gem do
88 # We're going to muck with some system globals so lets make sure
99 # they get set back later
10- original_platform = RbConfig ::CONFIG [ "arch" ]
1110 original_pwd = Dir . pwd
1211
1312 after do
14- RbConfig ::CONFIG [ "arch" ] = original_platform
1513 Dir . chdir original_pwd
1614 end
1715
@@ -43,56 +41,53 @@ class GemTest < Minitest::Spec
4341 end
4442 end
4543
46- describe "#ports_bin_paths " do
47- let ( :ports_bin_paths ) { TinyTds ::Gem . ports_bin_paths }
44+ describe "#ports_bin_and_lib_paths " do
45+ let ( :ports_bin_and_lib_paths ) { TinyTds ::Gem . ports_bin_and_lib_paths }
4846
4947 describe "when the ports directories exist" do
50- let ( :fake_bin_paths ) do
51- ports_host_root = File . join ( gem_root , "ports" , "fake-host-with-dirs" )
52- [
53- File . join ( "a" , "bin" ) ,
54- File . join ( "a" , "inner" , "bin" ) ,
55- File . join ( "b" , "bin" )
56- ] . map do |p |
48+ let ( :fake_bin_and_lib_path ) do
49+ ports_host_root = File . join ( gem_root , "ports" , "x86_64-unknown" )
50+ [ "bin" , "lib" ] . map do |p |
5751 File . join ( ports_host_root , p )
5852 end
5953 end
6054
6155 before do
62- RbConfig ::CONFIG [ "arch" ] = "fake-host-with-dirs"
63- fake_bin_paths . each do |path |
56+ fake_bin_and_lib_path . each do |path |
6457 FileUtils . mkdir_p ( path )
6558 end
6659 end
6760
6861 after do
6962 FileUtils . remove_entry_secure (
70- File . join ( gem_root , "ports" , "fake-host-with-dirs " ) , true
63+ File . join ( gem_root , "ports" , "x86_64-unknown " ) , true
7164 )
7265 end
7366
7467 it "should return all the bin directories" do
75- _ ( ports_bin_paths . sort ) . must_equal fake_bin_paths . sort
76- end
68+ fake_platform = Gem ::Platform . new ( "x86_64-unknown" )
69+
70+ Gem ::Platform . stub ( :local , fake_platform ) do
71+ _ ( ports_bin_and_lib_paths . sort ) . must_equal fake_bin_and_lib_path . sort
7772
78- it "should return all the bin directories regardless of cwd" do
79- Dir . chdir "/"
80- _ ( ports_bin_paths . sort ) . must_equal fake_bin_paths . sort
73+ # should return the same regardless of path
74+ Dir . chdir "/"
75+ _ ( ports_bin_and_lib_paths . sort ) . must_equal fake_bin_and_lib_path . sort
76+ end
8177 end
8278 end
8379
8480 describe "when the ports directories are missing" do
85- before do
86- RbConfig ::CONFIG [ "arch" ] = "fake-host-without-dirs"
87- end
88-
8981 it "should return no directories" do
90- _ ( ports_bin_paths ) . must_be_empty
91- end
82+ fake_platform = Gem ::Platform . new ( "x86_64-unknown" )
9283
93- it "should return no directories regardless of cwd" do
94- Dir . chdir "/"
95- _ ( ports_bin_paths ) . must_be_empty
84+ Gem ::Platform . stub ( :local , fake_platform ) do
85+ _ ( ports_bin_and_lib_paths ) . must_be_empty
86+
87+ # should be empty regardless of path
88+ Dir . chdir "/"
89+ _ ( ports_bin_and_lib_paths ) . must_be_empty
90+ end
9691 end
9792 end
9893 end
0 commit comments