hashblue 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/hashblue/collection.rb +5 -0
- data/lib/hashblue/version.rb +1 -1
- data/lib/hashblue.rb +0 -1
- data/spec/models/collection_spec.rb +26 -0
- metadata +3 -3
data/lib/hashblue/collection.rb
CHANGED
data/lib/hashblue/version.rb
CHANGED
data/lib/hashblue.rb
CHANGED
@@ -35,6 +35,16 @@ describe Hashblue::Collection do
|
|
35
35
|
subject.next_page.should be_false
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
describe '#each_page(&block)' do
|
40
|
+
it 'yields itself' do
|
41
|
+
pages = []
|
42
|
+
subject.each_page do |page|
|
43
|
+
pages << page
|
44
|
+
end
|
45
|
+
pages.should eql([subject])
|
46
|
+
end
|
47
|
+
end
|
38
48
|
end
|
39
49
|
|
40
50
|
describe "a collection with a next_page_uri" do
|
@@ -58,6 +68,22 @@ describe Hashblue::Collection do
|
|
58
68
|
subject.next_page.should eql(collection)
|
59
69
|
end
|
60
70
|
end
|
71
|
+
|
72
|
+
describe '#each_page(&block)' do
|
73
|
+
it 'yields each page in turn' do
|
74
|
+
subject
|
75
|
+
response = {"contacts" => []}
|
76
|
+
client.stubs(:get).with("https://api.example.com/contacts/more").returns(response)
|
77
|
+
collection = Hashblue::Collection.new(client, Hashblue::Contact, {"contacts" => []}, "contacts")
|
78
|
+
Hashblue::Collection.expects(:new).with(client, Hashblue::Contact, response, "contacts").returns(collection)
|
79
|
+
|
80
|
+
pages = []
|
81
|
+
subject.each_page do |page|
|
82
|
+
pages << page
|
83
|
+
end
|
84
|
+
pages.should eql([subject, collection])
|
85
|
+
end
|
86
|
+
end
|
61
87
|
end
|
62
88
|
|
63
89
|
describe "a collection without a previous_page_uri" do
|
metadata
CHANGED