open_graph 0.1.0 → 0.1.1

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.
@@ -38,6 +38,16 @@
38
38
  return getStatus().session;
39
39
  }
40
40
 
41
+ function api(location, callback){
42
+
43
+ if(!FBWorld.state('connected')){
44
+ callback(undefined);
45
+ }
46
+ if(location == '/me/friends'){
47
+ callback({data:FBWorld.friendList()});
48
+ }
49
+ }
50
+
41
51
  // FBWorld Functions
42
52
  //3 states: loggedOut, loggedIn, connected
43
53
  function state(){
@@ -84,12 +94,30 @@
84
94
  FBWorld.state('connected', false);
85
95
  }
86
96
 
97
+ function addFriend(id, name){
98
+ var friends = FBWorld.friendList();
99
+ friends.push({id: id, name: name});
100
+ FBWorld.Helpers.makeMeACookie('fb_friends', JSON.stringify(friends));
101
+ }
102
+
103
+ function friendList(){
104
+ return JSON.parse(FBWorld.Helpers.makeMeACookie('fb_friends') || '[]');
105
+ }
106
+
107
+ var XFBML = {
108
+ parse: function(element, callback){
109
+ callback();
110
+ }
111
+ };
112
+
87
113
  FB = { // Emulates the FB API
88
114
  getLoginStatus : getLoginStatus,
89
115
  logout : logout,
90
116
  login : login,
91
117
  init : init,
92
- getSession : getSession
118
+ getSession : getSession,
119
+ api : api,
120
+ XFBML : XFBML
93
121
  };
94
122
 
95
123
  FBWorld = { // used to set the state of Facebook
@@ -112,7 +140,11 @@
112
140
  beingPromptedToConnect : false,
113
141
  beingPromptedToConnectInCallback : undefined,
114
142
  allowConnection : allowConnection,
115
- denyConnection : denyConnection
143
+ denyConnection : denyConnection,
144
+
145
+ //friends
146
+ addFriend : addFriend,
147
+ friendList : friendList
116
148
  };
117
149
 
118
150
  // PRIVATE FUNCTIONS
@@ -1,3 +1,3 @@
1
1
  module OpenGraph
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe "OpenGraph::FBOpenGraph stub" do
4
+ context 'facebook positive stubs' do
5
+ before do
6
+ OpenGraph::FBOpenGraph.valid!
7
+ OpenGraph::FBOpenGraph.info_override!(:first_name, 'Curious')
8
+ OpenGraph::FBOpenGraph.info_override!(:last_name, 'George')
9
+ @f = OpenGraph::FBOpenGraph.new
10
+ end
11
+
12
+ it "should return user data" do
13
+ @f.valid?.should be_true
14
+ @f.info['first_name'].should == 'Curious'
15
+ @f.info['last_name'].should == 'George'
16
+ end
17
+
18
+ end
19
+
20
+ context 'facebook negative stubs' do
21
+ before do
22
+ OpenGraph::FBOpenGraph.invalid!
23
+ @f = OpenGraph::FBOpenGraph.new
24
+ end
25
+
26
+ it "should return false" do
27
+ @f.valid?.should be_false
28
+ @f.info.should be_false
29
+ end
30
+
31
+ end
32
+
33
+ context 'facebook unstubbed methods' do
34
+
35
+ before do
36
+ @f = OpenGraph::FBOpenGraph.new
37
+ end
38
+
39
+ it 'should raise an error' do
40
+ lambda { @f.checkins }.should raise_error
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'activesupport'
3
+ RAILS_ENV = 'test'
4
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'open_graph'))
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_graph
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Change.org Engineering
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-23 00:00:00 -08:00
18
+ date: 2011-03-24 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -42,6 +42,8 @@ files:
42
42
  - lib/open_graph/test/facebook_stub/picture.png
43
43
  - lib/open_graph/version.rb
44
44
  - open_graph.gemspec
45
+ - spec/open_graph_spec.rb
46
+ - spec/spec_helper.rb
45
47
  - facebook-stub/facebook-stub.js
46
48
  has_rdoc: true
47
49
  homepage: https://github.com/change/open_graph
@@ -77,5 +79,6 @@ rubygems_version: 1.5.0
77
79
  signing_key:
78
80
  specification_version: 3
79
81
  summary: A ruby wrapper for the new facebook graph api
80
- test_files: []
81
-
82
+ test_files:
83
+ - spec/open_graph_spec.rb
84
+ - spec/spec_helper.rb