|
1 | 1 | # rbs_inline: enabled |
2 | 2 |
|
3 | 3 | require "test_helper" |
4 | | -require "fileutils" |
5 | | -require "open3" |
6 | 4 | require "tmpdir" |
7 | | -require "rubygems/package" |
8 | | -require "rubygems/installer" |
| 5 | +require "packaged_type_check" |
9 | 6 |
|
10 | 7 | class EffectPayloadTypesTest < ActiveSupport::TestCase |
| 8 | + include PackagedTypeCheck |
| 9 | + |
11 | 10 | test "packaged payload contracts check consumers and the actual constructors" do |
12 | 11 | Dir.mktmpdir("solid-objects-effect-types") do |directory| |
13 | 12 | package = build_package(directory) |
@@ -74,47 +73,4 @@ class EffectPayloadTypesTest < ActiveSupport::TestCase |
74 | 73 | end |
75 | 74 | end |
76 | 75 | end |
77 | | - |
78 | | - private |
79 | | - |
80 | | - def build_package(directory) |
81 | | - artifact = File.join(directory, "solid_objects.gem") |
82 | | - specification = Gem::Specification.load(root_path("solid_objects.gemspec")) |
83 | | - Gem::DefaultUserInteraction.use_ui(Gem::SilentUI.new) do |
84 | | - Gem::Package.build(specification, false, false, artifact) |
85 | | - end |
86 | | - artifact |
87 | | - end |
88 | | - |
89 | | - def typecheck(project) |
90 | | - output, error_output, status = Open3.capture3( |
91 | | - Gem.ruby, Gem.bin_path("steep", "steep"), "check", "--no-daemon", "-j", "1", |
92 | | - chdir: project |
93 | | - ) |
94 | | - [ output + error_output, status ] |
95 | | - end |
96 | | - |
97 | | - def typecheck_installed(project, package) |
98 | | - gem_directory = File.join(project, "gems") |
99 | | - specification = Gem::Installer.at(package, install_dir: gem_directory, ignore_dependencies: true).install |
100 | | - script = <<~RUBY |
101 | | - gem "solid_objects", #{"= #{SolidObjects::VERSION}".inspect} |
102 | | - resolved = Gem.loaded_specs.fetch("solid_objects").full_gem_path |
103 | | - abort "loaded signatures outside the built gem: \#{resolved}" unless resolved == #{specification.full_gem_path.inspect} |
104 | | - load ARGV.shift |
105 | | - RUBY |
106 | | - output, error_output, status = Open3.capture3( |
107 | | - { |
108 | | - "RUBYOPT" => nil, "BUNDLE_GEMFILE" => nil, |
109 | | - "GEM_HOME" => gem_directory, "GEM_PATH" => ([ gem_directory ] + Gem.path).join(File::PATH_SEPARATOR) |
110 | | - }, |
111 | | - Gem.ruby, "-e", script, Gem.bin_path("steep", "steep"), "check", "--no-daemon", "-j", "1", |
112 | | - chdir: project |
113 | | - ) |
114 | | - [ output + error_output, status ] |
115 | | - end |
116 | | - |
117 | | - def root_path(path) |
118 | | - File.expand_path("../../#{path}", __dir__) |
119 | | - end |
120 | 76 | end |
0 commit comments