-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Avoid wrapping empty hash resource values in DeepHashAccessor (#190
- Loading branch information
1 parent
63f604a
commit 05573f9
Showing
2 changed files
with
40 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Seam::Resources::BaseResource do | ||
describe "hash handling" do | ||
let(:client) { Seam.new(api_key: "seam_some_api_key") } | ||
|
||
it "does not wrap empty hashes in DeepHashAccessor" do | ||
data = { | ||
device_id: "123", | ||
empty_hash: {}, | ||
non_empty_hash: {key: "value"} | ||
} | ||
|
||
resource = described_class.new(data, client) | ||
|
||
expect(resource.instance_variable_get(:@empty_hash)).to eq({}) | ||
expect(resource.instance_variable_get(:@empty_hash)).to be_a(Hash) | ||
expect(resource.instance_variable_get(:@empty_hash)).not_to be_a(Seam::DeepHashAccessor) | ||
|
||
expect(resource.instance_variable_get(:@non_empty_hash)).to be_a(Seam::DeepHashAccessor) | ||
end | ||
end | ||
end |