55require "open3"
66require "tmpdir"
77require "rubygems/package"
8+ require "rubygems/installer"
89
910class EffectPayloadTypesTest < ActiveSupport ::TestCase
1011 test "packaged payload contracts check consumers and the actual constructors" do
@@ -31,7 +32,7 @@ class EffectPayloadTypesTest < ActiveSupport::TestCase
3132 configuration_path = File . join ( project , "Steepfile" )
3233 configuration = File . read ( configuration_path )
3334 File . write ( configuration_path , configuration . sub ( 'signature "sig"' , "library \" solid_objects\" \n signature \" sig/consumer.rbs\" " ) )
34- output , status = typecheck ( project )
35+ output , status = typecheck_installed ( project , package )
3536 assert status . success? , output
3637 File . write ( configuration_path , configuration )
3738
@@ -81,6 +82,26 @@ def typecheck(project)
8182 [ output + error_output , status ]
8283 end
8384
85+ def typecheck_installed ( project , package )
86+ gem_directory = File . join ( project , "gems" )
87+ specification = Gem ::Installer . at ( package , install_dir : gem_directory , ignore_dependencies : true ) . install
88+ script = <<~RUBY
89+ gem "solid_objects", #{ "= #{ SolidObjects ::VERSION } " . inspect }
90+ resolved = Gem.loaded_specs.fetch("solid_objects").full_gem_path
91+ abort "loaded signatures outside the built gem: \# {resolved}" unless resolved == #{ specification . full_gem_path . inspect }
92+ load ARGV.shift
93+ RUBY
94+ output , error_output , status = Open3 . capture3 (
95+ {
96+ "RUBYOPT" => nil , "BUNDLE_GEMFILE" => nil ,
97+ "GEM_HOME" => gem_directory , "GEM_PATH" => ( [ gem_directory ] + Gem . path ) . join ( File ::PATH_SEPARATOR )
98+ } ,
99+ Gem . ruby , "-e" , script , Gem . bin_path ( "steep" , "steep" ) , "check" , "--no-daemon" , "-j" , "1" ,
100+ chdir : project
101+ )
102+ [ output + error_output , status ]
103+ end
104+
84105 def root_path ( path )
85106 File . expand_path ( "../../#{ path } " , __dir__ )
86107 end
0 commit comments