Last active
August 29, 2015 14:18
-
-
Save jasononaquest/f3dfc337575b75a08f59 to your computer and use it in GitHub Desktop.
copy_list_spec.rb
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
require 'rails_helper' | |
require './app/services/copy_list' | |
describe CopyList, type: :service do | |
describe 'given an existing list and a name' do | |
let(:list) do | |
list = List.create(name: 'my list') | |
category = list.categories.create(name: 'my category') | |
category.items.create(name: 'my item') | |
list | |
end | |
let(:new_name) { 'my new list' } | |
subject(:new_list) { CopyList.call(list, new_name) } | |
it 'copies a list using the new name' do | |
expect(new_list.name).to eq 'my new list' | |
end | |
it 'copies the list categories' do | |
expect(new_list.categories.first.name).to eq 'my category' | |
end | |
it 'copies the list items' do | |
expect(new_list.categories.first.items.first.name).to eq 'my item' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment