greedy 0.0.4 → 0.0.5

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
data/greedy.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{greedy}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeremy Weiland"]
data/lib/greedy/stream.rb CHANGED
@@ -21,6 +21,7 @@ module Greedy
21
21
 
22
22
  # Continue fetching earlier entries from where the last request left off
23
23
  def continue!
24
+ return [] unless @continuation_token
24
25
  new_entries = pull!(endpoint(@state), @options.merge(:c => @continuation_token))
25
26
  @entries.concat new_entries
26
27
  new_entries
data/test/test_stream.rb CHANGED
@@ -30,25 +30,45 @@ class TestStream < Test::Unit::TestCase
30
30
  setup do
31
31
  assert_equal @reading_list.instance_variable_get("@continuation_token"), "continuationtoken"
32
32
  @continued_response_hash = eval(File.open('test/fixtures/another_success_hash.txt').read)
33
- @connection.expects(:fetch).with("stream/contents/user/-/state/com.google/reading-list",
34
- { :c => "continuationtoken" }).returns(@continued_response_hash)
35
33
  end
36
34
 
37
- should "send the continuation token on the next pull" do
38
- @reading_list.continue!
39
- @reading_list.instance_variable_get("@continuation_token").should == "CKXmmOLq_aIC"
40
- end
35
+ context "when there's more entries to get" do
36
+ setup do
37
+ @connection.expects(:fetch).with("stream/contents/user/-/state/com.google/reading-list",
38
+ { :c => "continuationtoken" }).returns(@continued_response_hash)
39
+ end
40
+
41
+ should "send the continuation token on the next pull" do
42
+ @reading_list.continue!
43
+ @reading_list.instance_variable_get("@continuation_token").should == "CKXmmOLq_aIC"
44
+ end
41
45
 
42
- should "increase the entries size" do
43
- entry_count = @reading_list.entries.size
44
- continued_count = @reading_list.continue!.size
45
- @reading_list.entries.size.should == (entry_count + continued_count)
46
+ should "increase the entries size" do
47
+ entry_count = @reading_list.entries.size
48
+ continued_count = @reading_list.continue!.size
49
+ @reading_list.entries.size.should == (entry_count + continued_count)
50
+ end
51
+
52
+ should "not change the last update token" do
53
+ token = @reading_list.instance_variable_get("@last_update_token")
54
+ @reading_list.continue!
55
+ @reading_list.instance_variable_get("@last_update_token").should == token
56
+ end
46
57
  end
58
+
59
+ context "when no more entries exist to fetch" do
60
+ setup do
61
+ @reading_list.instance_variable_set "@continuation_token", nil
62
+ end
63
+
64
+ should "return an empty array if no continuation token was set on last fetch" do
65
+ @reading_list.continue!.should == []
66
+ end
47
67
 
48
- should "not change the last update token" do
49
- token = @reading_list.instance_variable_get("@last_update_token")
50
- @reading_list.continue!
51
- @reading_list.instance_variable_get("@last_update_token").should == token
68
+ should "never attempt the continuation fetch" do
69
+ @connection.expects(:fetch).never
70
+ @reading_list.continue!
71
+ end
52
72
  end
53
73
  end
54
74
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: greedy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeremy Weiland