Skip to content

Instantly share code, notes, and snippets.

@JasonSpatial
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JasonSpatial/2bad6ef29b647b4fff45 to your computer and use it in GitHub Desktop.
Save JasonSpatial/2bad6ef29b647b4fff45 to your computer and use it in GitHub Desktop.
copy_list_spec.rb
require 'rails_helper'
require './app/services/copy_list'
describe CopyList, type: :service do
describe 'given an existing list and a name' do
let(:list) { list = List.create(name: 'my list') }
let(:category) { Category.create(name: 'my category', list: list) }
let!(:item) { Item.create(name: 'my item', category: category) }
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
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment