polar-renren 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,7 @@ require 'polar/error/api_error'
13
13
 
14
14
  module Polar
15
15
  BASE_URL = "http://api.renren.com/restserver.do"
16
- VERSION = [0, 0, 4]
16
+ VERSION = [0, 0, 5]
17
17
 
18
18
  def self.version
19
19
  VERSION * "."
@@ -19,7 +19,7 @@ module Polar
19
19
 
20
20
  def next_page?
21
21
  if @items
22
- return @items.count <= ITEMS_PER_PAGE
22
+ return @items.count >= ITEMS_PER_PAGE
23
23
  elsif !@items && @current_page == 0
24
24
  return true
25
25
  else
@@ -15,12 +15,15 @@ describe Polar::Cursor do
15
15
  it do
16
16
  subject.class.should eql Polar::Cursor
17
17
 
18
- total_users = Array.new
18
+ total_users = []
19
19
  while subject.next_page?
20
20
  subject.each do |user|
21
21
  total_users << user
22
22
  end
23
23
  end
24
- total_users.count.should eql 500 * 50
24
+
25
+ #When we spec out pages we make the last page empty. Thats why this number is 499
26
+ total_users.count.should eql 49 * 500
27
+
25
28
  end
26
29
  end
@@ -7,10 +7,17 @@ class EndPointStub
7
7
  WebMock.reset!
8
8
  if @pages
9
9
  @pages.times do |count|
10
- stub_request(:post, "http://api.renren.com/restserver.do").with(:body => request_body_with_page(count + 1)).to_return(response(count + 1))
10
+ File.open(file_name(count + 1), 'w') do |file_response|
11
+ file_response.puts response(count + 1)
12
+ end
13
+
14
+ stub_request(:post, "http://api.renren.com/restserver.do")
15
+ .with(:body => request_body_with_page(count + 1))
16
+ .to_return(:body => File.new(file_name(count + 1)))
11
17
  end
12
18
  else
13
- stub_request(:post, "http://api.renren.com/restserver.do").to_return(response(1))
19
+ stub_request(:post, "http://api.renren.com/restserver.do")
20
+ .to_return(response(1))
14
21
  end
15
22
  end
16
23
 
@@ -28,6 +35,10 @@ class EndPointStub
28
35
  raise("Abstract Method")
29
36
  end
30
37
 
38
+ def file_name(counter)
39
+ "/tmp/#{self.class.to_s}_page_#{counter}.txt"
40
+ end
41
+
31
42
  def urlencode_params(params_hash)
32
43
  params = ''
33
44
  stack = []
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polar-renren
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-21 00:00:00.000000000Z
12
+ date: 2012-05-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -117,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  segments:
119
119
  - 0
120
- hash: 962871931374462761
120
+ hash: 629946179224843470
121
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  none: false
123
123
  requirements: