totter 0.2.13 → 0.2.14

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.
data/lib/totter/client.rb CHANGED
@@ -22,6 +22,9 @@ module Totter
22
22
  attr_reader :api_version
23
23
  attr_reader :transport
24
24
 
25
+ # global stubbing toggle for use in tests
26
+ @@stubbed = false
27
+
25
28
  # Initialize a new client.
26
29
  #
27
30
  # @param options [Hash] optionally specify `:access_token`, `:api_scheme`, `:api_host`, `:api_version`, `:client_token`, or `:transport`.
@@ -61,5 +64,17 @@ module Totter
61
64
  def ssl?
62
65
  @api_scheme == 'https'
63
66
  end
67
+
68
+ def self.stub!
69
+ @@stubbed = true
70
+ end
71
+
72
+ def self.unstub!
73
+ @@stubbed = false
74
+ end
75
+
76
+ def self.stubbed?
77
+ @@stubbed
78
+ end
64
79
  end
65
80
  end
@@ -78,7 +78,9 @@ module Totter
78
78
  end
79
79
 
80
80
  def json_request(*args)
81
- # Preform request
81
+ return Hashie::Mash.new({}) if Totter::Client.stubbed?
82
+
83
+ # Perform request
82
84
  response = request(*args)
83
85
 
84
86
  # Parse JSON
@@ -1,4 +1,4 @@
1
1
  module Totter
2
2
  # Verion of the Totter gem
3
- VERSION = '0.2.13'
3
+ VERSION = '0.2.14'
4
4
  end
@@ -28,4 +28,15 @@ class ClientTest < Totter::TestCase
28
28
  client = Totter::Client.new(api_scheme: 'http')
29
29
  refute client.ssl?
30
30
  end
31
+
32
+ def test_stub!
33
+ client = Totter::Client.new
34
+ Totter::Client.stub!
35
+
36
+ assert Totter::Client.stubbed?
37
+ expected = {}
38
+ assert_equal expected, client.create_decision(1)
39
+
40
+ Totter::Client.unstub!
41
+ end
31
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: totter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.13
4
+ version: 0.2.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-02-18 00:00:00.000000000 Z
14
+ date: 2013-02-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: multi_json