fb_rails 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ require 'rails/all'
2
+
1
3
  module FbRails
2
4
  extend ActiveSupport::Autoload
3
5
 
@@ -11,4 +13,5 @@ module FbRails
11
13
  autoload :TestHelper
12
14
  end
13
15
 
16
+ require 'fb_rails/errors'
14
17
  require 'fb_rails/engine'
@@ -0,0 +1,14 @@
1
+ module FbRails
2
+ class GraphError < StandardError
3
+ def initialize(message)
4
+ @message = message
5
+ end
6
+ def to_s; @message ;end
7
+ end
8
+
9
+ class TimeoutError < GraphError
10
+ end
11
+
12
+ class ResponseError < GraphError
13
+ end
14
+ end
@@ -4,13 +4,6 @@ require 'uri'
4
4
  require 'fb_rails/log_subscriber'
5
5
 
6
6
  module FbRails
7
- class TimeoutError < StandardError
8
- def initialize(message)
9
- @message = message
10
- end
11
- def to_s; @message ;end
12
- end
13
-
14
7
  class Graph
15
8
  class << self
16
9
  def facebook_uri
@@ -38,7 +31,11 @@ module FbRails
38
31
 
39
32
  def json_request(http_verb, path, *arguments)
40
33
  response = request(http_verb, path, *arguments)
41
- ActiveSupport::JSON.decode(response.body)
34
+ begin
35
+ ActiveSupport::JSON.decode(response.body)
36
+ rescue => e
37
+ raise ResponseError.new(e.message)
38
+ end
42
39
  end
43
40
 
44
41
  def http
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class FbRails::ErrorTest < ActiveSupport::TestCase
4
+ test 'to_s' do
5
+ assert_equal 'hello', FbRails::GraphError.new('hello').to_s
6
+ end
7
+ end
@@ -14,4 +14,13 @@ class FbRails::GraphTest < ActiveSupport::TestCase
14
14
  FbRails::Graph.get 'foo'
15
15
  end
16
16
  end
17
+
18
+ test 'rescue response error' do
19
+ http = stub(get: stub(body: "false"))
20
+ FbRails::Graph.expects(:http).returns(http)
21
+
22
+ assert_raise FbRails::ResponseError do
23
+ FbRails::Graph.get 'foo'
24
+ end
25
+ end
17
26
  end
@@ -1,10 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
-
3
+ Bundler.require(:default, :test)
4
4
  require 'test/unit'
5
- require 'rails/all'
6
- require 'fb_rails'
7
- require 'mocha'
8
5
 
9
6
  require 'sample/user'
10
7
  require 'sample/test_controller'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.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: 2011-09-22 00:00:00.000000000Z
12
+ date: 2011-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70118718756760 !ruby/object:Gem::Requirement
16
+ requirement: &70111865339960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,18 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70118718756760
24
+ version_requirements: *70111865339960
25
+ - !ruby/object:Gem::Dependency
26
+ name: fakeweb
27
+ requirement: &70111865339500 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70111865339500
25
36
  description: A Rails 3 gem for the latest facebook API
26
37
  email: developer@matthewhiggins.com
27
38
  executables: []
@@ -36,6 +47,7 @@ files:
36
47
  - lib/fb_rails/connect.rb
37
48
  - lib/fb_rails/cookie.rb
38
49
  - lib/fb_rails/engine.rb
50
+ - lib/fb_rails/errors.rb
39
51
  - lib/fb_rails/fb.rb
40
52
  - lib/fb_rails/graph.rb
41
53
  - lib/fb_rails/integration/action_controller.rb
@@ -48,6 +60,7 @@ files:
48
60
  - test/config_test.rb
49
61
  - test/connect_test.rb
50
62
  - test/cookie_test.rb
63
+ - test/error_test.rb
51
64
  - test/fb_test.rb
52
65
  - test/graph_test.rb
53
66
  - test/helpers/action_controller_test.rb