Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added specs for Hash#except #786

Merged
merged 1 commit into from
Sep 1, 2020
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
33 changes: 33 additions & 0 deletions core/hash/except_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require_relative '../../spec_helper'

ruby_version_is "3.0" do
describe "Hash#except" do
before :each do
@hash = { a: 1, b: 2, c: 3 }
end

it "returns a new duplicate hash without arguments" do
ret = @hash.except
ret.should_not equal(@hash)
ret.should == @hash
end

it "returns a hash without the requested subset" do
@hash.except(:c, :a).should == { b: 2 }
end

it "ignores keys not present in the original hash" do
@hash.except(:a, :chunky_bacon).should == { b: 2, c: 3 }
end

it "returns an instance of a subclass" do
klass = Class.new(Hash)
h = klass.new
h[:bar] = 12
h[:foo] = 42
r = h.except(:foo)
r.should == {bar: 12}
r.class.should == klass
end
end
end