facebook-stub 0.0.1.14 → 0.0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/facebook-stub.js +36 -2
- data/lib/facebook_stub/core.js +36 -2
- data/lib/facebook_stub/version.rb +1 -1
- data/spec/javascripts/FBApiSpec.js +29 -0
- metadata +22 -22
data/bin/facebook-stub.js
CHANGED
@@ -269,12 +269,20 @@
|
|
269
269
|
perms = {data:[theState.perms.data]};
|
270
270
|
callback(perms);
|
271
271
|
} else if(/\/.+\/feed/.test(path) && method == 'post') { // /me/feed or /123/feed
|
272
|
-
|
272
|
+
FBWorld.posted({path: path, params: params});
|
273
|
+
callback({id: randomPostId()});
|
274
|
+
} else if(/\/me\/.+:.+/.test(path) && method == 'post') {
|
275
|
+
FBWorld.posted({path: path, params: params});
|
276
|
+
callback({id: randomPostId()});
|
273
277
|
} else {
|
274
278
|
callback(apiFailMessage(path));
|
275
279
|
}
|
276
280
|
}
|
277
281
|
|
282
|
+
function randomPostId() {
|
283
|
+
return Math.floor(Math.random() * 100000);
|
284
|
+
}
|
285
|
+
|
278
286
|
function apiUnconnectedMessage() {
|
279
287
|
return {
|
280
288
|
"error": {
|
@@ -426,12 +434,34 @@
|
|
426
434
|
FBWorld.Helpers.makeMeACookie('fb-stub', null);
|
427
435
|
}
|
428
436
|
|
437
|
+
function posted(){
|
438
|
+
var p = state('posted') || [];
|
439
|
+
if (arguments.length == 1){
|
440
|
+
p.push(arguments[0]);
|
441
|
+
}
|
442
|
+
state('posted', p);
|
443
|
+
return p;
|
444
|
+
}
|
445
|
+
|
446
|
+
// Give list of params posted on path
|
447
|
+
function lastPostForPath(path) {
|
448
|
+
var results = [];
|
449
|
+
var posted = state('posted') || [];
|
450
|
+
for (var i = posted.length - 1; i >= 0; i--) {
|
451
|
+
var post = posted[i];
|
452
|
+
if (post.path == path)
|
453
|
+
return post.params;
|
454
|
+
}
|
455
|
+
return undefined;
|
456
|
+
}
|
457
|
+
|
429
458
|
var XFBML = {
|
430
459
|
parse: function(element, callback) {
|
431
460
|
callback();
|
432
461
|
}
|
433
462
|
};
|
434
463
|
|
464
|
+
|
435
465
|
FB = { // Emulates the FB API
|
436
466
|
getLoginStatus : getLoginStatus,
|
437
467
|
logout : logout,
|
@@ -501,7 +531,11 @@
|
|
501
531
|
|
502
532
|
//friends
|
503
533
|
addFriend : addFriend,
|
504
|
-
friendList : friendList
|
534
|
+
friendList : friendList,
|
535
|
+
|
536
|
+
// posted
|
537
|
+
posted : posted,
|
538
|
+
lastPostForPath : lastPostForPath
|
505
539
|
};
|
506
540
|
|
507
541
|
|
data/lib/facebook_stub/core.js
CHANGED
@@ -269,12 +269,20 @@
|
|
269
269
|
perms = {data:[theState.perms.data]};
|
270
270
|
callback(perms);
|
271
271
|
} else if(/\/.+\/feed/.test(path) && method == 'post') { // /me/feed or /123/feed
|
272
|
-
|
272
|
+
FBWorld.posted({path: path, params: params});
|
273
|
+
callback({id: randomPostId()});
|
274
|
+
} else if(/\/me\/.+:.+/.test(path) && method == 'post') {
|
275
|
+
FBWorld.posted({path: path, params: params});
|
276
|
+
callback({id: randomPostId()});
|
273
277
|
} else {
|
274
278
|
callback(apiFailMessage(path));
|
275
279
|
}
|
276
280
|
}
|
277
281
|
|
282
|
+
function randomPostId() {
|
283
|
+
return Math.floor(Math.random() * 100000);
|
284
|
+
}
|
285
|
+
|
278
286
|
function apiUnconnectedMessage() {
|
279
287
|
return {
|
280
288
|
"error": {
|
@@ -426,12 +434,34 @@
|
|
426
434
|
FBWorld.Helpers.makeMeACookie('fb-stub', null);
|
427
435
|
}
|
428
436
|
|
437
|
+
function posted(){
|
438
|
+
var p = state('posted') || [];
|
439
|
+
if (arguments.length == 1){
|
440
|
+
p.push(arguments[0]);
|
441
|
+
}
|
442
|
+
state('posted', p);
|
443
|
+
return p;
|
444
|
+
}
|
445
|
+
|
446
|
+
// Give list of params posted on path
|
447
|
+
function lastPostForPath(path) {
|
448
|
+
var results = [];
|
449
|
+
var posted = state('posted') || [];
|
450
|
+
for (var i = posted.length - 1; i >= 0; i--) {
|
451
|
+
var post = posted[i];
|
452
|
+
if (post.path == path)
|
453
|
+
return post.params;
|
454
|
+
}
|
455
|
+
return undefined;
|
456
|
+
}
|
457
|
+
|
429
458
|
var XFBML = {
|
430
459
|
parse: function(element, callback) {
|
431
460
|
callback();
|
432
461
|
}
|
433
462
|
};
|
434
463
|
|
464
|
+
|
435
465
|
FB = { // Emulates the FB API
|
436
466
|
getLoginStatus : getLoginStatus,
|
437
467
|
logout : logout,
|
@@ -501,7 +531,11 @@
|
|
501
531
|
|
502
532
|
//friends
|
503
533
|
addFriend : addFriend,
|
504
|
-
friendList : friendList
|
534
|
+
friendList : friendList,
|
535
|
+
|
536
|
+
// posted
|
537
|
+
posted : posted,
|
538
|
+
lastPostForPath : lastPostForPath
|
505
539
|
};
|
506
540
|
|
507
541
|
|
@@ -66,7 +66,36 @@ describe("FB.api", function() {
|
|
66
66
|
expect(r.id).toBeDefined();
|
67
67
|
});
|
68
68
|
});
|
69
|
+
it("should push onto FBWorld.published", function() {
|
70
|
+
var path = '/me/feed';
|
71
|
+
var params = {
|
72
|
+
bar: 'baz',
|
73
|
+
foobar: 'foo'
|
74
|
+
};
|
75
|
+
FB.api(path, 'post', params, function (r) {
|
76
|
+
expect(FBWorld.lastPostForPath(path)).toEqual(params);
|
77
|
+
});
|
78
|
+
});
|
69
79
|
});
|
80
|
+
|
81
|
+
describe("when I call FB.api('/me/APP_NAMESPACE:ACTION', 'post', params, callback)", function() {
|
82
|
+
it("should callback with a random id", function() {
|
83
|
+
FB.api('/me/foo:bar', 'post', {}, function (r) {
|
84
|
+
expect(r.id).toBeDefined();
|
85
|
+
});
|
86
|
+
});
|
87
|
+
it("should push onto FBWorld.published", function() {
|
88
|
+
var path = '/me/foo:bar';
|
89
|
+
var params = {
|
90
|
+
bar: 'baz',
|
91
|
+
foobar: 'foo'
|
92
|
+
};
|
93
|
+
FB.api(path, 'post', params, function (r) {
|
94
|
+
expect(FBWorld.lastPostForPath(path)).toEqual(params);
|
95
|
+
});
|
96
|
+
});
|
97
|
+
});
|
98
|
+
|
70
99
|
});
|
71
100
|
|
72
101
|
describe("when not connected", function () {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facebook-stub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.15
|
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-05-
|
12
|
+
date: 2012-05-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: debugger
|
16
|
-
requirement: &
|
16
|
+
requirement: &70349102469860 !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: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70349102469860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sprockets
|
27
|
-
requirement: &
|
27
|
+
requirement: &70349102469440 !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: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70349102469440
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70349102511760 !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: *
|
46
|
+
version_requirements: *70349102511760
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: sinatra
|
49
|
-
requirement: &
|
49
|
+
requirement: &70349102511020 !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: *
|
57
|
+
version_requirements: *70349102511020
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: shotgun
|
60
|
-
requirement: &
|
60
|
+
requirement: &70349102508840 !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: *
|
68
|
+
version_requirements: *70349102508840
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: haml
|
71
|
-
requirement: &
|
71
|
+
requirement: &70349102506340 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70349102506340
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &70349102505000 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70349102505000
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: capybara
|
93
|
-
requirement: &
|
93
|
+
requirement: &70349102504580 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70349102504580
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: jasmine
|
104
|
-
requirement: &
|
104
|
+
requirement: &70349091360720 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70349091360720
|
113
113
|
description: facebook-stub is a gem for stubbing out the Facebook JavaScript API in
|
114
114
|
acceptance and integration tests.
|
115
115
|
email:
|
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
160
|
version: '0'
|
161
161
|
segments:
|
162
162
|
- 0
|
163
|
-
hash:
|
163
|
+
hash: 3233229171749605837
|
164
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
165
|
none: false
|
166
166
|
requirements:
|
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
169
|
version: '0'
|
170
170
|
segments:
|
171
171
|
- 0
|
172
|
-
hash:
|
172
|
+
hash: 3233229171749605837
|
173
173
|
requirements: []
|
174
174
|
rubyforge_project: facebook-stub
|
175
175
|
rubygems_version: 1.8.11
|