1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/spec/interactors/merge_contact_lists_spec.rb

42 lines
1.1 KiB
Ruby
Raw Normal View History

2019-08-14 09:10:09 -04:00
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe MergeContactLists do
2019-08-14 10:55:00 -04:00
subject do
described_class.call old_contact_list: old_contact_list,
new_contact_list: new_contact_list
end
2019-08-14 09:10:09 -04:00
2019-08-14 10:55:00 -04:00
let(:old_contact_list) { create :some_contact_list }
let(:new_contact_list) { create :some_contact_list }
2019-08-14 09:10:09 -04:00
specify do
expect { subject }.to \
2019-08-14 10:55:00 -04:00
change(old_contact_list.contacts, :count)
.from(old_contact_list.contacts.count)
2019-08-14 09:10:09 -04:00
.to(0)
end
specify do
expect { subject }.to \
2019-08-14 10:55:00 -04:00
change(new_contact_list.contacts, :count)
.from(new_contact_list.contacts.count)
.to(old_contact_list.contacts.count + new_contact_list.contacts.count)
2019-08-14 09:10:09 -04:00
end
specify do
expect { subject }.to \
2019-08-14 10:55:00 -04:00
change(old_contact_list.contacts, :to_a)
.from(old_contact_list.contacts.to_a)
2019-08-14 09:10:09 -04:00
.to([])
end
specify do
expect { subject }.to \
2019-08-14 10:55:00 -04:00
change(new_contact_list.contacts, :to_a)
.from(new_contact_list.contacts.to_a)
.to(new_contact_list.contacts.to_a + old_contact_list.contacts.to_a)
2019-08-14 09:10:09 -04:00
end
end