Skip to content

Commit

Permalink
Merge pull request #705 from ruby/support-bundled-gems
Browse files Browse the repository at this point in the history
Support bundled gems like pstore and ostruct
  • Loading branch information
hsbt authored Jan 10, 2025
2 parents 22cc79d + ac0d0af commit b96a661
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
11 changes: 8 additions & 3 deletions test/psych/test_yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# frozen_string_literal: true

require_relative 'helper'
require 'ostruct'

# [ruby-core:01946]
module Psych_Tests
Expand All @@ -15,8 +14,14 @@ def teardown
end

def test_y_method
assert_raise(NoMethodError) do
OpenStruct.new.y 1
begin
require 'ostruct'

assert_raise(NoMethodError) do
OpenStruct.new.y 1
end
rescue LoadError
omit("OpenStruct is not available")
end
end

Expand Down
16 changes: 10 additions & 6 deletions test/psych/test_yamlstore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ def load(content)

class YAMLStoreTest < TestCase
def setup
@dir = Dir.mktmpdir("rubytest-file")
File.chown(-1, Process.gid, @dir)
@yamlstore_file = make_tmp_filename("yamlstore")
@yamlstore = YAML::Store.new(@yamlstore_file)
if defined?(::PStore)
@dir = Dir.mktmpdir("rubytest-file")
File.chown(-1, Process.gid, @dir)
@yamlstore_file = make_tmp_filename("yamlstore")
@yamlstore = YAML::Store.new(@yamlstore_file)
else
omit "PStore is not available"
end
end

def teardown
FileUtils.remove_entry_secure @dir
FileUtils.remove_entry_secure(@dir) if @dir
end

def make_tmp_filename(prefix)
Expand Down Expand Up @@ -97,5 +101,5 @@ def test_writing_inside_readonly_transaction_raises_error
end
end
end
end
end if defined?(::PStore)
end if defined?(Psych)

0 comments on commit b96a661

Please sign in to comment.