Skip to content

Commit

Permalink
Merge pull request #2 from bdurand/support_table_data_specs
Browse files Browse the repository at this point in the history
Add specs to confirm data is not shared
  • Loading branch information
bdurand authored Feb 9, 2023
2 parents 7502e35 + 1086f8e commit c115feb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions spec/support_table_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,26 @@
expect(SupportTableData.support_table_classes).to eq [Group, Hue, Color, Invalid]
end
end

describe "suppport_table_data" do
it "returns an array with all the attributes" do
data = Color.support_table_data
expect(data.size).to eq 11
expect(data).to include({
"id" => 1,
"name" => "Red",
"hex" => "0xFF0000",
"group_name" => "primary",
"hue_name" => "red"
})
end

it "returns a fresh copy every call" do
data_1 = Color.support_table_data
data_2 = Color.support_table_data
expect(data_1.object_id).to_not eq data_2.object_id
expect(data_1.map(&:object_id)).to_not match_array data_2.map(&:object_id)
expect(data_1.map { |attributes| attributes.values.map(&:object_id) }.flatten).to_not match_array data_2.map { |attributes| attributes.values.map(&:object_id) }.flatten
end
end
end

0 comments on commit c115feb

Please sign in to comment.