spec/unit/resync/shared/augmented_examples.rb in resync-0.1.3 vs spec/unit/resync/shared/augmented_examples.rb in resync-0.2.0
- old
+ new
@@ -11,33 +11,32 @@
end
describe 'links' do
it 'accepts a list of links' do
links = [Link.new(rel: 'describedby', uri: 'http://example.org/'), Link.new(rel: 'duplicate', uri: 'http://example.com/')]
- list = new_instance(links: links)
- expect(list.links).to eq(links)
+ augmented = new_instance(links: links)
+ expect(augmented.links).to eq(links)
end
- it 'defaults to an empty list if no links are specified' do
- list = new_instance
- expect(list.links).to eq([])
+ it 'defaults to an empty augmented if no links are specified' do
+ augmented = new_instance
+ expect(augmented.links).to eq([])
end
-
end
describe '#links_for' do
it 'can retrieve a list of links by rel' do
links = [
Link.new(rel: 'describedby', uri: 'http://example.org/desc1'),
Link.new(rel: 'duplicate', uri: 'http://example.com/dup1'),
Link.new(rel: 'describedby', uri: 'http://example.org/desc2'),
Link.new(rel: 'duplicate', uri: 'http://example.com/dup2')
]
- list = new_instance(links: links)
- expect(list.links_for(rel: 'describedby')).to eq([links[0], links[2]])
- expect(list.links_for(rel: 'duplicate')).to eq([links[1], links[3]])
- expect(list.links_for(rel: 'elvis')).to eq([])
+ augmented = new_instance(links: links)
+ expect(augmented.links_for(rel: 'describedby')).to eq([links[0], links[2]])
+ expect(augmented.links_for(rel: 'duplicate')).to eq([links[1], links[3]])
+ expect(augmented.links_for(rel: 'elvis')).to eq([])
end
end
describe '#link_for' do
it 'can retrieve the first link for a rel' do
@@ -45,13 +44,30 @@
Link.new(rel: 'describedby', uri: 'http://example.org/desc1'),
Link.new(rel: 'duplicate', uri: 'http://example.com/dup1'),
Link.new(rel: 'describedby', uri: 'http://example.org/desc2'),
Link.new(rel: 'duplicate', uri: 'http://example.com/dup2')
]
- list = new_instance(links: links)
- expect(list.link_for(rel: 'describedby')).to eq(links[0])
- expect(list.link_for(rel: 'duplicate')).to eq(links[1])
- expect(list.link_for(rel: 'elvis')).to eq(nil)
+ augmented = new_instance(links: links)
+ expect(augmented.link_for(rel: 'describedby')).to eq(links[0])
+ expect(augmented.link_for(rel: 'duplicate')).to eq(links[1])
+ expect(augmented.link_for(rel: 'elvis')).to eq(nil)
+ end
+ end
+
+ describe 'additional time attributes' do
+ it 'extracts the at_time, from_time, until_time, and completed_time from the metadata' do
+ capability = described_class::CAPABILITY if defined?(described_class::CAPABILITY)
+ md = Metadata.new(
+ at_time: Time.utc(1999, 1, 1),
+ from_time: Time.utc(2001, 1, 1),
+ until_time: Time.utc(2003, 1, 1),
+ completed_time: Time.utc(2005, 1, 1),
+ capability: capability
+ )
+ augmented = new_instance(metadata: md)
+ [:at_time, :from_time, :until_time, :completed_time].each do |t|
+ expect(augmented.send(t)).to be_time(md.send(t))
+ end
end
end
end
end