git-timecost/spec/author_list_spec.nok

66 lines
1.2 KiB
Text
Raw Permalink Normal View History

2014-09-24 18:10:12 +00:00
2023-07-11 16:52:48 +00:00
require "./spec_helper"
2014-09-24 18:10:12 +00:00
2023-07-11 16:52:48 +00:00
require "../src/timecost/author_list"
2014-09-25 06:05:05 +00:00
describe TimeCost::AuthorList do
2023-07-11 16:52:48 +00:00
list= TimeCost::AuthorList.new
first= "Foo <foo@example.com>"
second= "Bar <bar@example.com>"
2014-09-25 06:05:05 +00:00
2023-07-11 16:52:48 +00:00
describe ".new" do
2014-09-25 06:05:05 +00:00
it "can be created without arguments" do
2023-07-11 16:52:48 +00:00
list.should be_a(TimeCost::AuthorList)
2014-09-25 06:05:05 +00:00
end
end
2023-07-11 16:52:48 +00:00
describe ".add" do
2014-09-25 06:05:05 +00:00
it "must accept adding authors" do
2023-07-11 16:52:48 +00:00
list.responds_to?(:add).should be_true
2014-09-25 06:05:05 +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
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
2023-07-11 16:52:48 +00:00
describe ".size" do
2014-09-26 06:35:26 +00:00
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
2023-07-11 16:52:48 +00:00
describe ".alias" do
2014-09-25 06:05:05 +00:00
it "must accept aliases for authors" do
assert_respond_to list, :alias
2014-09-25 06:05:05 +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
list.add first
list.alias first, second
2014-09-25 06:05:05 +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