-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(utils): move hash specs into separate files
- Loading branch information
Showing
7 changed files
with
94 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
require "convenient_service" | ||
|
||
RSpec.describe ConvenientService::Utils::Hash::Except do | ||
describe ".call" do | ||
let(:hash) { {foo: "foo", bar: "bar", baz: "baz"} } | ||
let(:result) { described_class.call(hash, keys) } | ||
|
||
context "when hash does NOT contain any key from `keys`" do | ||
let(:keys) { [:qux] } | ||
|
||
it "returns hash with same keys as original hash" do | ||
expect(result.keys).to eq(hash.keys) | ||
end | ||
|
||
it "copies hash" do | ||
expect(result.object_id).not_to eq(hash.object_id) | ||
end | ||
end | ||
|
||
context "when hash contain single key from `keys`" do | ||
let(:keys) { [:baz] } | ||
|
||
it "returns hash without that key" do | ||
expect(result.keys).to eq(hash.keys - keys) | ||
end | ||
|
||
it "copies hash" do | ||
expect(result.object_id).not_to eq(hash.object_id) | ||
end | ||
end | ||
|
||
context "when hash contain multiple keys from `keys`" do | ||
let(:keys) { [:foo, :baz] } | ||
|
||
it "returns hash without those keys" do | ||
expect(result.keys).to eq(hash.keys - keys) | ||
end | ||
|
||
it "copies hash" do | ||
expect(result.object_id).not_to eq(hash.object_id) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters