diff --git a/lib/instapaper/bookmark_list.rb b/lib/instapaper/bookmark_list.rb index deb95da..2832e74 100644 --- a/lib/instapaper/bookmark_list.rb +++ b/lib/instapaper/bookmark_list.rb @@ -12,5 +12,9 @@ module Instapaper attribute :highlights, Array[Instapaper::Highlight] attribute :delete_ids, Array[Integer] end + + def each + bookmarks.each { |bookmark| yield(bookmark) } + end end end diff --git a/spec/instapaper/bookmark_list_spec.rb b/spec/instapaper/bookmark_list_spec.rb new file mode 100644 index 0000000..d0e9260 --- /dev/null +++ b/spec/instapaper/bookmark_list_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe Instapaper::BookmarkList do + describe '#each' do + it 'yields a list of bookmarks' do + list = Instapaper::BookmarkList.new(JSON.parse(fixture('bookmarks_list.json').read)) + list.each do |bookmark| + expect(bookmark).to be_an Instapaper::Bookmark + end + end + end +end