Commit ec558757 authored by Jason Goodman's avatar Jason Goodman

Refactor update_service_spec to use contains_exactly

parent 809a5f1d
......@@ -20,8 +20,11 @@ RSpec.describe EE::IpRestrictions::UpdateService do
end
it 'builds new ip_restriction records with the provided ranges' do
expect { subject }
.to(change { group.ip_restrictions.map(&:range) }.from([]).to(comma_separated_ranges.split(",")))
expect(group.ip_restrictions.map(&:range)).to be_empty
subject
expect(group.ip_restrictions.map(&:range)).to contain_exactly(*comma_separated_ranges.split(','))
end
end
end
......@@ -53,7 +56,7 @@ RSpec.describe EE::IpRestrictions::UpdateService do
shared_examples 'removes all existing ip_restriction records' do
it 'marks all the existing ip_restriction records for destruction' do
records_marked_for_destruction = group.ip_restrictions.select(&:marked_for_destruction?)
expect(records_marked_for_destruction.map(&:range)).to eq(ranges)
expect(records_marked_for_destruction.map(&:range)).to contain_exactly(*ranges)
end
end
......@@ -65,7 +68,7 @@ RSpec.describe EE::IpRestrictions::UpdateService do
it 'builds new ip_restriction records with all of the specified ranges' do
newly_built_ip_restriction_records = group.ip_restrictions.select { |ip_restriction| ip_restriction.id.nil? }
expect(newly_built_ip_restriction_records.map(&:range)).to eq(comma_separated_ranges.split(","))
expect(newly_built_ip_restriction_records.map(&:range)).to contain_exactly(*comma_separated_ranges.split(","))
end
end
......@@ -77,7 +80,7 @@ RSpec.describe EE::IpRestrictions::UpdateService do
it 'builds new ip_restriction records with only the unique ranges in the specified ranges' do
newly_built_ip_restriction_records = group.ip_restrictions.select { |ip_restriction| ip_restriction.id.nil? }
expect(newly_built_ip_restriction_records.map(&:range)).to eq(comma_separated_ranges.split(",").uniq)
expect(newly_built_ip_restriction_records.map(&:range)).to contain_exactly(*comma_separated_ranges.split(",").uniq)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment