browshot 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/browshot.rb +4 -3
  3. data/test/test_browshot.rb +157 -27
  4. metadata +19 -19
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.0
1
+ 1.7.0
@@ -34,7 +34,7 @@ class Browshot
34
34
 
35
35
  # Return the API version handled by the library. Note that this library can usually handle new arguments in requests without requiring an update.
36
36
  def api_version()
37
- return "1.6"
37
+ return "1.7"
38
38
  end
39
39
 
40
40
  # Retrieve a screenshot with one call. See http://browshot.com/api/documentation#simple for the full list of possible arguments.
@@ -116,8 +116,9 @@ class Browshot
116
116
  # Get information about a screenshot requested previously. See http://browshot.com/api/documentation#screenshot_info for the response format.
117
117
  #
118
118
  # +id+:: screenshot ID
119
- def screenshot_info(id=0)
120
- return return_reply('screenshot/info', { 'id' => id })
119
+ def screenshot_info(id=0, parameters={})
120
+ parameters[:id] = id
121
+ return return_reply('screenshot/info', parameters)
121
122
  end
122
123
 
123
124
  # Get details about screenshots requested. See http://browshot.com/api/documentation#screenshot_list for the response format.
@@ -14,7 +14,7 @@ class TestBrowshot < Test::Unit::TestCase
14
14
  end
15
15
 
16
16
  should "get the API version" do
17
- assert_equal '1.6', @browshot.api_version()
17
+ assert_equal '1.7', @browshot.api_version()
18
18
  end
19
19
 
20
20
  should "get a screenshot with the simple method" do
@@ -56,8 +56,6 @@ class TestBrowshot < Test::Unit::TestCase
56
56
  assert_equal false, free['browser']['flash'].nil?, "Missing instance browser flash capability"
57
57
  assert_equal false, free['browser']['mobile'].nil?, "Missing instance browser mobile capability"
58
58
  assert_equal false, free['type'].nil?, "Missing instance type"
59
- assert_equal false, free['active'].nil?, "Missing instance active"
60
- assert_equal 1, free['active'].to_i, "Free instance should be active"
61
59
  assert_equal false, free['screenshot_cost'].nil?, "Missing instance cost"
62
60
  assert_equal 0, free['screenshot_cost'].to_i, "Cost should be 0"
63
61
  end
@@ -77,7 +75,6 @@ class TestBrowshot < Test::Unit::TestCase
77
75
  assert_equal free['browser']['flash'], instance['browser']['flash'], "Mismatch instance browser flash capability"
78
76
  assert_equal free['browser']['mobile'], instance['browser']['mobile'], "Mismatch instance browser mobile capability"
79
77
  assert_equal free['type'], instance['type'], "Mismatch instance type"
80
- assert_equal free['active'], instance['active'], "Mismatch instance active"
81
78
  assert_equal free['screenshot_cost'], instance['screenshot_cost'], "Mismatch instance cost"
82
79
  end
83
80
 
@@ -99,17 +96,17 @@ class TestBrowshot < Test::Unit::TestCase
99
96
  assert_equal false, instance['error'].nil?, "Instance browser ID should be invalid"
100
97
  end
101
98
 
102
- should "create a new instance (sort of)" do
103
- # Instance is not actually created for test account, so the reply may not match our parameters
99
+ should "create a new instance" do
100
+ # Option disabled for most accounts
104
101
  instance = @browshot.instance_create()
105
102
 
106
- assert_equal false, instance['id'].nil?, "Instance ID should be present"
107
- assert_equal false, instance['width'].nil?, "Instance screen width should be present"
108
- assert_equal false, instance['height'].nil?, "Instance screen height should be present"
109
- assert_equal false, instance['active'].nil?, "Instance active should be present"
110
- assert_equal 1, instance['active'].to_i, "Instance should be active"
111
- assert_equal false, instance['browser'].nil?, "Instance browser should be present"
112
- assert_equal false, instance['browser']['id'].nil?, "Instance browser ID should be present"
103
+ # assert_equal false, instance['error'].nil?, "Instance cannot be created for this account"
104
+ # assert_equal false, instance['id'].nil?, "Instance ID should be present"
105
+ # assert_equal false, instance['width'].nil?, "Instance screen width should be present"
106
+ # assert_equal false, instance['height'].nil?, "Instance screen height should be present"
107
+ # assert_equal 1, instance['active'].to_i, "Instance should be active"
108
+ # assert_equal false, instance['browser'].nil?, "Instance browser should be present"
109
+ # assert_equal false, instance['browser']['id'].nil?, "Instance browser ID should be present"
113
110
  end
114
111
 
115
112
  should "get the list of browsers" do
@@ -122,7 +119,7 @@ class TestBrowshot < Test::Unit::TestCase
122
119
  break
123
120
  end
124
121
 
125
- assert_equal true, browser_id.to_i > 0, "Browser ID should be positive"
122
+ assert_equal true, browser_id.to_i > 0, "Browser ID should be positive"
126
123
  browser = browsers[browser_id]
127
124
 
128
125
  assert_equal false, browser['name'].nil?, "Browser name should be present"
@@ -139,20 +136,21 @@ class TestBrowshot < Test::Unit::TestCase
139
136
  end
140
137
 
141
138
  should "create a browser" do
142
- # browser is not actually created for test account, so the reply may not match our parameters
139
+ # Option disabled for most accounts
143
140
  browser = @browshot.browser_create({'mobile' => 1, 'flash' => 1, 'user_agent' => 'test'})
144
141
 
145
- assert_equal false, browser['name'].nil?, "Browser name should be present"
146
- assert_equal false, browser['user_agent'].nil?, "Browser user_agent should be present"
147
- assert_equal false, browser['appname'].nil?, "Browser appname should be present"
148
- assert_equal false, browser['vendorsub'].nil?, "Browser vendorsub should be present"
149
- assert_equal false, browser['appcodename'].nil?, "Browser appcodename should be present"
150
- assert_equal false, browser['platform'].nil?, "Browser platform should be present"
151
- assert_equal false, browser['vendor'].nil?, "Browser vendor should be present"
152
- assert_equal false, browser['appversion'].nil?, "Browser appversion should be present"
153
- assert_equal false, browser['javascript'].nil?, "Browser javascript capability should be present"
154
- assert_equal false, browser['mobile'].nil?, "Browser mobile capability should be present"
155
- assert_equal false, browser['flash'].nil?, "Browser flash capability should be present"
142
+ # assert_equal false, browser['error'].nil?, "Browser cannot be created for this account"
143
+ # assert_equal false, browser['name'].nil?, "Browser name should be present"
144
+ # assert_equal false, browser['user_agent'].nil?, "Browser user_agent should be present"
145
+ # assert_equal false, browser['appname'].nil?, "Browser appname should be present"
146
+ # assert_equal false, browser['vendorsub'].nil?, "Browser vendorsub should be present"
147
+ # assert_equal false, browser['appcodename'].nil?, "Browser appcodename should be present"
148
+ # assert_equal false, browser['platform'].nil?, "Browser platform should be present"
149
+ # assert_equal false, browser['vendor'].nil?, "Browser vendor should be present"
150
+ # assert_equal false, browser['appversion'].nil?, "Browser appversion should be present"
151
+ # assert_equal false, browser['javascript'].nil?, "Browser javascript capability should be present"
152
+ # assert_equal false, browser['mobile'].nil?, "Browser mobile capability should be present"
153
+ # assert_equal false, browser['flash'].nil?, "Browser flash capability should be present"
156
154
  end
157
155
 
158
156
  should "fail to create screenshot" do
@@ -197,7 +195,7 @@ class TestBrowshot < Test::Unit::TestCase
197
195
  assert_equal false, screenshot['error'].nil?, "Screenshot should have failed"
198
196
  end
199
197
 
200
- should "to retrieve a screenshot" do
198
+ should "retrieve a screenshot" do
201
199
  screenshot = @browshot.screenshot_create('http://browshot.com/')
202
200
  info = @browshot.screenshot_info(screenshot['id'])
203
201
 
@@ -225,6 +223,138 @@ class TestBrowshot < Test::Unit::TestCase
225
223
  end
226
224
  end
227
225
 
226
+ should "to retrieve a screenshot with details==0" do
227
+ screenshot = @browshot.screenshot_create('http://browshot.com/')
228
+ info = @browshot.screenshot_info(screenshot['id'], { 'details' => 0 })
229
+
230
+ assert_equal false, info['id'].nil?, "Screenshot ID should be present"
231
+ assert_equal false, info['status'].nil?, "Screenshot status should be present"
232
+ assert_equal false, info['priority'].nil?, "Screenshot priority should be present"
233
+ assert_equal false, info['cost'].nil?, "Screenshot cost should be present"
234
+
235
+ if (info['status'] == 'finished')
236
+ assert_equal false, info['screenshot_url'].nil?, "Screenshot screenshot_url should be present"
237
+ assert_equal false, info['url'].nil?, "Screenshot url should be present"
238
+ assert_equal false, info['size'].nil?, "Screenshot size should be present"
239
+ assert_equal false, info['width'].nil?, "Screenshot width should be present"
240
+ assert_equal false, info['height'].nil?, "Screenshot height should be present"
241
+ assert_equal false, info['instance_id'].nil?, "Screenshot instance_id should be present"
242
+ assert_equal false, info['final_url'].nil?, "Screenshot final_url should be present"
243
+ assert_equal false, info['scale'].nil?, "Screenshot scale should be present"
244
+
245
+ assert_equal true, info['response_code'].nil?, "Screenshot response_code should NOT be present"
246
+ assert_equal true, info['content_type'].nil?, "Screenshot content_type should NOT be present"
247
+
248
+ assert_equal true, info['started'].nil?, "Screenshot started should NOT be present"
249
+ assert_equal true, info['finished'].nil?, "Screenshot finished should NOT be present"
250
+ assert_equal true, info['load'].nil?, "Screenshot load should NOT be present"
251
+ assert_equal true, info['request_time'].nil?, "Screenshot request_time should NOT be present"
252
+ assert_equal true, info['content'].nil?, "Screenshot content should NOT be present"
253
+
254
+ assert_equal true, info['images'].nil?, "Screenshot images should NOT be present"
255
+ end
256
+ end
257
+
258
+ should "to retrieve a screenshot with details==1" do
259
+ screenshot = @browshot.screenshot_create('http://browshot.com/')
260
+ info = @browshot.screenshot_info(screenshot['id'], { 'details' => 1 })
261
+
262
+ assert_equal false, info['id'].nil?, "Screenshot ID should be present"
263
+ assert_equal false, info['status'].nil?, "Screenshot status should be present"
264
+ assert_equal false, info['priority'].nil?, "Screenshot priority should be present"
265
+ assert_equal false, info['cost'].nil?, "Screenshot cost should be present"
266
+
267
+ if (info['status'] == 'finished')
268
+ assert_equal false, info['screenshot_url'].nil?, "Screenshot screenshot_url should be present"
269
+ assert_equal false, info['url'].nil?, "Screenshot url should be present"
270
+ assert_equal false, info['size'].nil?, "Screenshot size should be present"
271
+ assert_equal false, info['width'].nil?, "Screenshot width should be present"
272
+ assert_equal false, info['height'].nil?, "Screenshot height should be present"
273
+ assert_equal false, info['instance_id'].nil?, "Screenshot instance_id should be present"
274
+ assert_equal false, info['final_url'].nil?, "Screenshot final_url should be present"
275
+ assert_equal false, info['scale'].nil?, "Screenshot scale should be present"
276
+
277
+ assert_equal false, info['response_code'].nil?, "Screenshot response_code should be present"
278
+ assert_equal false, info['content_type'].nil?, "Screenshot content_type should be present"
279
+
280
+ assert_equal true, info['started'].nil?, "Screenshot started should NOT be present"
281
+ assert_equal true, info['finished'].nil?, "Screenshot finished should NOT be present"
282
+ assert_equal true, info['load'].nil?, "Screenshot load should NOT be present"
283
+ assert_equal true, info['request_time'].nil?, "Screenshot request_time should NOT be present"
284
+ assert_equal true, info['content'].nil?, "Screenshot content should NOT be present"
285
+
286
+ assert_equal true, info['images'].nil?, "Screenshot images should NOT be present"
287
+ end
288
+ end
289
+
290
+ should "to retrieve a screenshot with details==2" do
291
+ screenshot = @browshot.screenshot_create('http://browshot.com/')
292
+ info = @browshot.screenshot_info(screenshot['id'], { 'details' => 2 })
293
+
294
+ assert_equal false, info['id'].nil?, "Screenshot ID should be present"
295
+ assert_equal false, info['status'].nil?, "Screenshot status should be present"
296
+ assert_equal false, info['priority'].nil?, "Screenshot priority should be present"
297
+ assert_equal false, info['cost'].nil?, "Screenshot cost should be present"
298
+
299
+ if (info['status'] == 'finished')
300
+ assert_equal false, info['screenshot_url'].nil?, "Screenshot screenshot_url should be present"
301
+ assert_equal false, info['url'].nil?, "Screenshot url should be present"
302
+ assert_equal false, info['size'].nil?, "Screenshot size should be present"
303
+ assert_equal false, info['width'].nil?, "Screenshot width should be present"
304
+ assert_equal false, info['height'].nil?, "Screenshot height should be present"
305
+ assert_equal false, info['instance_id'].nil?, "Screenshot instance_id should be present"
306
+ assert_equal false, info['final_url'].nil?, "Screenshot final_url should be present"
307
+ assert_equal false, info['scale'].nil?, "Screenshot scale should be present"
308
+
309
+ assert_equal false, info['response_code'].nil?, "Screenshot response_code should be present"
310
+ assert_equal false, info['content_type'].nil?, "Screenshot content_type should be present"
311
+
312
+ assert_equal false, info['started'].nil?, "Screenshot started should be present"
313
+ assert_equal false, info['finished'].nil?, "Screenshot finished should be present"
314
+ assert_equal false, info['load'].nil?, "Screenshot load should be present"
315
+ assert_equal false, info['request_time'].nil?, "Screenshot request_time should be present"
316
+ assert_equal false, info['content'].nil?, "Screenshot content should be present"
317
+
318
+ assert_equal true, info['images'].nil?, "Screenshot images should NOT be present"
319
+ end
320
+ end
321
+
322
+ should "to retrieve a screenshot with details==3" do
323
+ screenshot = @browshot.screenshot_create('http://browshot.com/')
324
+ info = @browshot.screenshot_info(screenshot['id'], { 'details' => 3 })
325
+
326
+ assert_equal false, info['id'].nil?, "Screenshot ID should be present"
327
+ assert_equal false, info['status'].nil?, "Screenshot status should be present"
328
+ assert_equal false, info['priority'].nil?, "Screenshot priority should be present"
329
+ assert_equal false, info['cost'].nil?, "Screenshot cost should be present"
330
+
331
+ if (info['status'] == 'finished')
332
+ assert_equal false, info['screenshot_url'].nil?, "Screenshot screenshot_url should be present"
333
+ assert_equal false, info['url'].nil?, "Screenshot url should be present"
334
+ assert_equal false, info['size'].nil?, "Screenshot size should be present"
335
+ assert_equal false, info['width'].nil?, "Screenshot width should be present"
336
+ assert_equal false, info['height'].nil?, "Screenshot height should be present"
337
+ assert_equal false, info['instance_id'].nil?, "Screenshot instance_id should be present"
338
+ assert_equal false, info['final_url'].nil?, "Screenshot final_url should be present"
339
+ assert_equal false, info['scale'].nil?, "Screenshot scale should be present"
340
+
341
+ assert_equal false, info['response_code'].nil?, "Screenshot response_code should be present"
342
+ assert_equal false, info['content_type'].nil?, "Screenshot content_type should be present"
343
+
344
+ assert_equal false, info['started'].nil?, "Screenshot started should be present"
345
+ assert_equal false, info['finished'].nil?, "Screenshot finished should be present"
346
+ assert_equal false, info['load'].nil?, "Screenshot load should be present"
347
+ assert_equal false, info['request_time'].nil?, "Screenshot request_time should be present"
348
+ assert_equal false, info['content'].nil?, "Screenshot content should be present"
349
+
350
+ assert_equal false, info['images'].nil?, "Screenshot images should be present"
351
+ assert_equal true, info['images'].length > 0, "Screenshot images should be present"
352
+ assert_equal false, info['scripts'].nil?, "Screenshot scripts should be present"
353
+ assert_equal false, info['iframes'].nil?, "Screenshot iframes should be present"
354
+ assert_equal false, info['embeds'].nil?, "Screenshot embeds should be present"
355
+ end
356
+ end
357
+
228
358
  should "retrieve the list of screenshots" do
229
359
  screenshots = @browshot.screenshot_list()
230
360
  assert_equal true, screenshots.length > 0, "There should be multiple screenshots"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-18 00:00:00.000000000 Z
12
+ date: 2012-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70154160 !ruby/object:Gem::Requirement
16
+ requirement: &96980520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70154160
24
+ version_requirements: *96980520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: url
27
- requirement: &70153360 !ruby/object:Gem::Requirement
27
+ requirement: &96979780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70153360
35
+ version_requirements: *96979780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: json
38
- requirement: &70152680 !ruby/object:Gem::Requirement
38
+ requirement: &96979040 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70152680
46
+ version_requirements: *96979040
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: url
49
- requirement: &70151980 !ruby/object:Gem::Requirement
49
+ requirement: &96978400 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70151980
57
+ version_requirements: *96978400
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: shoulda
60
- requirement: &70151260 !ruby/object:Gem::Requirement
60
+ requirement: &96977720 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70151260
68
+ version_requirements: *96977720
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
- requirement: &70188060 !ruby/object:Gem::Requirement
71
+ requirement: &97827640 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.0.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70188060
79
+ version_requirements: *97827640
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &70187440 !ruby/object:Gem::Requirement
82
+ requirement: &97826880 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.6.4
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70187440
90
+ version_requirements: *97826880
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rcov
93
- requirement: &70186540 !ruby/object:Gem::Requirement
93
+ requirement: &97826140 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70186540
101
+ version_requirements: *97826140
102
102
  description: ! 'Browshot (http://www.browshot.com/) is a web service to easily make
103
103
  screenshots of web pages in any screen size, as any device: iPhone©, iPad©, Android©,
104
104
  Nook©, PC, etc. Browshot has full Flash, JavaScript, CSS, & HTML5 support. The latest
@@ -141,7 +141,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
141
  version: '0'
142
142
  segments:
143
143
  - 0
144
- hash: 2431786324878126114
144
+ hash: -653828520181139472
145
145
  required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  none: false
147
147
  requirements: