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

add spec for ENV.except #826

Merged
merged 1 commit into from
Jan 30, 2021
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
36 changes: 36 additions & 0 deletions core/env/except_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require_relative 'spec_helper'
require_relative 'shared/to_hash'

ruby_version_is "3.0" do
describe "ENV.except" do
before do
@orig_hash = ENV.to_hash
end

after do
ENV.replace @orig_hash
end

# Testing the method without arguments is covered via
it_behaves_like :env_to_hash, :except

it "returns a hash without the requested subset" do
ENV.clear

ENV['one'] = '1'
ENV['two'] = '2'
ENV['three'] = '3'

ENV.except('one', 'three').should == { 'two' => '2' }
end

it "ignores keys not present in the original hash" do
ENV.clear

ENV['one'] = '1'
ENV['two'] = '2'

ENV.except('one', 'three').should == { 'two' => '2' }
end
end
end