2014-09-24 18:10:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
require_relative 'spec_helper'
|
|
|
|
|
2014-09-25 08:02:08 +00:00
|
|
|
require 'timecost/author_list'
|
2014-09-25 06:05:05 +00:00
|
|
|
|
|
|
|
describe TimeCost::AuthorList do
|
2014-09-25 08:02:08 +00:00
|
|
|
let(:list) { TimeCost::AuthorList.new }
|
|
|
|
let(:first) { "Foo <foo@example.com>" }
|
|
|
|
let(:second) { "Bar <bar@example.com>" }
|
2014-09-25 06:05:05 +00:00
|
|
|
|
|
|
|
describe '.new' do
|
|
|
|
it "can be created without arguments" do
|
2014-09-25 08:02:08 +00:00
|
|
|
assert_instance_of TimeCost::AuthorList, list
|
2014-09-25 06:05:05 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.add' do
|
|
|
|
it "must accept adding authors" do
|
2014-09-25 08:02:08 +00:00
|
|
|
assert_respond_to list, :add
|
2014-09-25 06:05:05 +00:00
|
|
|
|
2014-09-25 08:02:08 +00:00
|
|
|
list.add first
|
|
|
|
list.add second
|
2014-09-25 06:05:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "must assign a different id to different authors" do
|
2014-09-25 08:02:08 +00:00
|
|
|
list.add first
|
|
|
|
list.add second
|
|
|
|
id_foo = list.parse first
|
|
|
|
id_bar = list.parse second
|
2014-09-25 06:05:05 +00:00
|
|
|
refute_equal id_foo, id_bar
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-26 06:35:26 +00:00
|
|
|
describe '.size' do
|
|
|
|
it "must be zero in the beginning" do
|
|
|
|
assert_equal list.size, 0
|
|
|
|
end
|
|
|
|
|
|
|
|
it "must grow while adding authors" do
|
|
|
|
list.add first
|
|
|
|
assert_equal list.size, 1
|
|
|
|
list.add second
|
|
|
|
assert_equal list.size, 2
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-25 06:05:05 +00:00
|
|
|
describe '.alias' do
|
|
|
|
it "must accept aliases for authors" do
|
2014-09-25 08:02:08 +00:00
|
|
|
assert_respond_to list, :alias
|
2014-09-25 06:05:05 +00:00
|
|
|
|
2014-09-25 08:02:08 +00:00
|
|
|
list.add first
|
|
|
|
list.alias first, second
|
2014-09-25 06:05:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "must assign the same id to aliases authors" do
|
2014-09-25 08:02:08 +00:00
|
|
|
list.add first
|
|
|
|
list.alias first, second
|
2014-09-25 06:05:05 +00:00
|
|
|
|
2014-09-25 08:02:08 +00:00
|
|
|
id_foo = list.parse first
|
|
|
|
id_bar = list.parse second
|
2014-09-25 06:05:05 +00:00
|
|
|
refute_equal id_foo, id_bar
|
|
|
|
end
|
2014-09-24 18:10:12 +00:00
|
|
|
end
|
|
|
|
end
|