spec/csl/info_spec.rb in csl-1.1.0 vs spec/csl/info_spec.rb in csl-1.2.0
- old
+ new
@@ -143,10 +143,34 @@
it 'prints the category if present' do
Info.new { |i| i.category = {:'citation-format' => 'author'} }.to_xml.should == '<info><category citation-format="author"/></info>'
end
end
+ describe '#dup' do
+ it 'does not copy ancestors' do
+ apa = Style.load(:apa).info
+ apa.should be_a(Info)
+
+ apa.should_not be_root
+ apa.dup.should be_root
+ end
+ end
+
+ describe '#deep_copy' do
+ it 'copies the full sub-tree' do
+ apa = Style.load(:apa).info
+ apa.should be_a(Info)
+
+ xml = apa.to_xml
+
+ copy = apa.deep_copy
+
+ apa.to_xml.should == xml # original unchanged!
+ copy.to_xml.should == xml
+ end
+ end
+
describe '#pretty_print' do
it 'returns an empty info element by default' do
subject.pretty_print.should == '<info/>'
end
@@ -170,12 +194,12 @@
describe Info::Author do
it { should_not be_nil }
let(:poe) {
Info::Author.new { |a|
- a.email = 'poe@baltimore.com'
a.name = 'E. A. Poe'
+ a.email = 'poe@baltimore.com'
}
}
describe '#name' do
it 'returns nil by default' do
@@ -234,6 +258,21 @@
end
end
end
-end
\ No newline at end of file
+ describe Info::Rights do
+ it { should_not be_nil }
+
+ describe '#dup' do
+ it 'copies attributes and text' do
+ r = Info::Rights.new('foo')
+ r[:license] = 'bar'
+
+ c = r.dup
+ c.text.should == 'foo'
+ c[:license].should == 'bar'
+ end
+ end
+ end
+
+end