Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions core/gc/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@
end

context "with a hash of options" do
it "allows to set GC implementation's options" do
# Remove global keys which are read-only.
it "allows to set GC implementation's options, returning the new config" do
config = GC.config({})
# Can't set anything if there are no options.
skip if config.empty?

# Try to find a boolean setting to reliably test changing it.
key, _value = config.find { |_k, v| v == true }
skip unless key
Expand All @@ -29,15 +25,19 @@
GC.config(key => true).should == config
GC.config[key].should == true
ensure
GC.config(config)
GC.config(config.except(:implementation))
end

it "does not change settings that aren't present in the hash" do
GC.config({}).should == GC.config.except(:implementation)
previous = GC.config
GC.config({})
GC.config.should == previous
end

it "ignores unknown keys" do
GC.config(foo: "bar").should == GC.config.except(:implementation)
previous = GC.config
GC.config(foo: "bar")
GC.config.should == previous
end

it "raises an ArgumentError if options include global keys" do
Expand All @@ -64,7 +64,7 @@
end

after do
GC.config(@default_config)
GC.config(@default_config.except(:implementation))
end

it "includes :rgengc_allow_full_mark option, true by default" do
Expand All @@ -75,7 +75,7 @@
it "allows to set :rgengc_allow_full_mark" do
# This key maps truthy and falsey values to true and false.
GC.config(rgengc_allow_full_mark: nil).should == @default_config.merge(rgengc_allow_full_mark: false)
GC.config(rgengc_allow_full_mark: 1.23).should == @default_config
GC.config(rgengc_allow_full_mark: 1.23).should == @default_config.merge(rgengc_allow_full_mark: true)
end
end
end
Expand Down