drip-ruby 3.2.0 → 3.4.2

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.
Files changed (104) hide show
  1. checksums.yaml +5 -5
  2. data/.github/pull_request_template.md +39 -0
  3. data/.rubocop.yml +5 -1
  4. data/.rubocop_todo.yml +17 -9
  5. data/.travis.yml +2 -4
  6. data/CHANGELOG.md +51 -1
  7. data/Gemfile +12 -0
  8. data/README.md +6 -0
  9. data/Rakefile +2 -0
  10. data/drip-ruby.gemspec +4 -11
  11. data/lib/drip.rb +2 -0
  12. data/lib/drip/client.rb +48 -66
  13. data/lib/drip/client/accounts.rb +4 -2
  14. data/lib/drip/client/broadcasts.rb +4 -2
  15. data/lib/drip/client/campaign_subscriptions.rb +3 -1
  16. data/lib/drip/client/campaigns.rb +7 -5
  17. data/lib/drip/client/configuration.rb +30 -0
  18. data/lib/drip/client/conversions.rb +4 -2
  19. data/lib/drip/client/custom_fields.rb +3 -1
  20. data/lib/drip/client/events.rb +6 -4
  21. data/lib/drip/client/forms.rb +4 -2
  22. data/lib/drip/client/http_client.rb +66 -0
  23. data/lib/drip/client/orders.rb +5 -3
  24. data/lib/drip/client/shopper_activity.rb +80 -0
  25. data/lib/drip/client/subscribers.rb +30 -16
  26. data/lib/drip/client/tags.rb +5 -3
  27. data/lib/drip/client/users.rb +17 -0
  28. data/lib/drip/client/webhooks.rb +7 -5
  29. data/lib/drip/client/workflow_triggers.rb +5 -3
  30. data/lib/drip/client/workflows.rb +8 -6
  31. data/lib/drip/collection.rb +2 -0
  32. data/lib/drip/collections.rb +2 -0
  33. data/lib/drip/collections/accounts.rb +2 -0
  34. data/lib/drip/collections/broadcasts.rb +2 -0
  35. data/lib/drip/collections/campaign_subscriptions.rb +2 -0
  36. data/lib/drip/collections/campaigns.rb +2 -0
  37. data/lib/drip/collections/errors.rb +2 -0
  38. data/lib/drip/collections/orders.rb +2 -0
  39. data/lib/drip/collections/purchases.rb +2 -0
  40. data/lib/drip/collections/subscribers.rb +2 -0
  41. data/lib/drip/collections/tags.rb +2 -0
  42. data/lib/drip/collections/webhooks.rb +2 -0
  43. data/lib/drip/collections/workflow_triggers.rb +2 -0
  44. data/lib/drip/collections/workflows.rb +2 -0
  45. data/lib/drip/errors.rb +2 -0
  46. data/lib/drip/request.rb +33 -0
  47. data/lib/drip/resource.rb +2 -0
  48. data/lib/drip/resources.rb +2 -0
  49. data/lib/drip/resources/account.rb +2 -0
  50. data/lib/drip/resources/broadcast.rb +2 -0
  51. data/lib/drip/resources/campaign.rb +2 -0
  52. data/lib/drip/resources/campaign_subscription.rb +2 -0
  53. data/lib/drip/resources/error.rb +2 -0
  54. data/lib/drip/resources/order.rb +2 -0
  55. data/lib/drip/resources/purchase.rb +2 -0
  56. data/lib/drip/resources/subscriber.rb +2 -0
  57. data/lib/drip/resources/tag.rb +2 -0
  58. data/lib/drip/resources/webhook.rb +2 -0
  59. data/lib/drip/resources/workflow.rb +2 -0
  60. data/lib/drip/resources/workflow_trigger.rb +2 -0
  61. data/lib/drip/response.rb +15 -13
  62. data/lib/drip/version.rb +3 -1
  63. data/test/drip/client/accounts_test.rb +2 -0
  64. data/test/drip/client/broadcasts_test.rb +2 -0
  65. data/test/drip/client/campaign_subscriptions_test.rb +2 -0
  66. data/test/drip/client/campaigns_test.rb +2 -0
  67. data/test/drip/client/configuration_test.rb +112 -0
  68. data/test/drip/client/conversions_test.rb +2 -0
  69. data/test/drip/client/custom_fields_test.rb +2 -0
  70. data/test/drip/client/events_test.rb +2 -0
  71. data/test/drip/client/forms_test.rb +2 -0
  72. data/test/drip/client/http_client_test.rb +98 -0
  73. data/test/drip/client/orders_test.rb +2 -0
  74. data/test/drip/client/shopper_activity_test.rb +189 -0
  75. data/test/drip/client/subscribers_test.rb +8 -0
  76. data/test/drip/client/tags_test.rb +2 -0
  77. data/test/drip/client/users_test.rb +24 -0
  78. data/test/drip/client/webhooks_test.rb +2 -0
  79. data/test/drip/client/workflow_triggers_test.rb +2 -0
  80. data/test/drip/client/workflows_test.rb +2 -0
  81. data/test/drip/client_test.rb +34 -97
  82. data/test/drip/collection_test.rb +16 -0
  83. data/test/drip/collections/account_test.rb +10 -0
  84. data/test/drip/collections/broadcasts_test.rb +10 -0
  85. data/test/drip/collections/campaign_subscriptions_test.rb +10 -0
  86. data/test/drip/collections/campaigns_test.rb +10 -0
  87. data/test/drip/collections/errors_test.rb +10 -0
  88. data/test/drip/collections/orders_test.rb +10 -0
  89. data/test/drip/collections/purchases_test.rb +10 -0
  90. data/test/drip/collections/tags_test.rb +10 -0
  91. data/test/drip/collections/webhooks_test.rb +10 -0
  92. data/test/drip/collections/workflow_triggers_test.rb +10 -0
  93. data/test/drip/collections/workflows_test.rb +10 -0
  94. data/test/drip/collections_test.rb +2 -0
  95. data/test/drip/request_test.rb +60 -0
  96. data/test/drip/resource_test.rb +14 -0
  97. data/test/drip/resources/account_test.rb +2 -0
  98. data/test/drip/resources/order_test.rb +2 -0
  99. data/test/drip/resources/subscriber_test.rb +2 -0
  100. data/test/drip/resources/tag_test.rb +15 -0
  101. data/test/drip/resources_test.rb +2 -0
  102. data/test/drip/response_test.rb +35 -0
  103. data/test/test_helper.rb +5 -0
  104. metadata +50 -109
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.dirname(__FILE__) + '/../../test_helper.rb'
2
4
 
3
5
  class Drip::Client::SubscribersTest < Drip::TestCase
@@ -82,6 +84,12 @@ class Drip::Client::SubscribersTest < Drip::TestCase
82
84
  assert_equal expected, @client.create_or_update_subscriber(id: 123456)
83
85
  assert_requested :post, "https://api.getdrip.com/v2/12345/subscribers", body: '{"subscribers":[{"id":123456}]}', times: 1
84
86
  end
87
+
88
+ should "allow request with bigcommerce_subscriber_id keyword argument" do
89
+ expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
90
+ assert_equal expected, @client.create_or_update_subscriber(external_ids: { "bigcommerce_subscriber_id" => "2" })
91
+ assert_requested :post, "https://api.getdrip.com/v2/12345/subscribers", body: '{"subscribers":[{"external_ids":{"bigcommerce_subscriber_id":"2"}}]}', times: 1
92
+ end
85
93
  end
86
94
 
87
95
  context "#create_or_update_subscribers" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.dirname(__FILE__) + '/../../test_helper.rb'
2
4
 
3
5
  class Drip::Client::TagsTest < Drip::TestCase
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.dirname(__FILE__) + '/../../test_helper.rb'
4
+
5
+ class Drip::Client::UsersTest < Drip::TestCase
6
+ def setup
7
+ @client = Drip::Client.new { |c| c.account_id = "12345" }
8
+ end
9
+
10
+ context "#user" do
11
+ setup do
12
+ @response_status = 200
13
+ @response_body = "{}"
14
+
15
+ stub_request(:get, "https://api.getdrip.com/v2/user").
16
+ to_return(status: @response_status, body: @response_body, headers: {})
17
+ end
18
+
19
+ should "send the right request" do
20
+ expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
21
+ assert_equal expected, @client.user
22
+ end
23
+ end
24
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.dirname(__FILE__) + '/../../test_helper.rb'
2
4
 
3
5
  class Drip::Client::WebhooksTest < Drip::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.dirname(__FILE__) + '/../../test_helper.rb'
2
4
 
3
5
  class Drip::Client::WorkflowTriggersTest < Drip::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.dirname(__FILE__) + '/../../test_helper.rb'
2
4
 
3
5
  class Drip::Client::WorkflowsTest < Drip::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.dirname(__FILE__) + '/../test_helper.rb'
2
4
  require "base64"
3
5
 
@@ -19,11 +21,6 @@ class Drip::ClientTest < Drip::TestCase
19
21
  assert_equal "aaaa", client.url_prefix
20
22
  end
21
23
 
22
- should "have default url prefix" do
23
- client = Drip::Client.new
24
- assert_equal "https://api.getdrip.com/v2/", client.url_prefix
25
- end
26
-
27
24
  should "accept access token" do
28
25
  client = Drip::Client.new do |config|
29
26
  config.access_token = "aaaa"
@@ -55,36 +52,12 @@ class Drip::ClientTest < Drip::TestCase
55
52
  assert_equal 20, client.http_open_timeout
56
53
  assert_equal 25, client.http_timeout
57
54
  end
58
- end
59
-
60
- context "#generate_resource" do
61
- setup do
62
- @key = "subscribers"
63
- @data = { "email" => "foo" }
64
- @client = Drip::Client.new
65
- end
66
-
67
- should "return a JSON API payload" do
68
- assert_equal({ @key => [@data] }, @client.generate_resource(@key, @data))
69
- end
70
- end
71
-
72
- context "given a personal api key" do
73
- setup do
74
- @key = "aaaa"
75
- @client = Drip::Client.new do |config|
76
- config.api_key = @key
77
- end
78
- end
79
55
 
80
- should "use Basic authentication" do
81
- stub_request(:get, "https://api.getdrip.com/v2/testpath").
82
- to_return(status: 200, body: "", headers: {})
83
-
84
- @client.get("testpath")
85
-
86
- header = "Basic #{Base64.encode64(@key + ':')}".strip
87
- assert_requested :get, "https://api.getdrip.com/v2/testpath", headers: { 'Authorization' => header }
56
+ should "accept options after initialization" do
57
+ # Deprecated
58
+ client = Drip::Client.new
59
+ assert_output(nil, /^\[DEPRECATED\] Setting configuration/) { client.account_id = "12345" }
60
+ assert_equal "12345", client.account_id
88
61
  end
89
62
  end
90
63
 
@@ -98,6 +71,7 @@ class Drip::ClientTest < Drip::TestCase
98
71
 
99
72
  should "return objects" do
100
73
  stub_request(:get, "https://api.getdrip.com/v2/12345/subscribers/jdoe%40example.com").
74
+ with(headers: { "Content-Type" => "application/vnd.api+json" }).
101
75
  to_return(status: 200, body: "{\"links\":{\"subscribers.account\":\"https://api.getdrip.com/v2/accounts/{subscribers.account}\"},\"subscribers\":[{\"id\":\"randomid\",\"href\":\"https://api.getdrip.com/v2/1234/subscribers/randomid\",\"status\":\"active\",\"email\":\"jdoe@example.com\",\"time_zone\":null,\"utc_offset\":0,\"visitor_uuid\":null,\"custom_fields\":{\"first_name\":\"John\"},\"tags\":[\"customer\"],\"created_at\":\"2018-06-04T21:29:49Z\",\"ip_address\":null,\"user_agent\":null,\"lifetime_value\":null,\"original_referrer\":null,\"landing_url\":null,\"prospect\":null,\"base_lead_score\":null,\"eu_consent\":\"unknown\",\"lead_score\":null,\"user_id\":\"123\",\"links\":{\"account\":\"1234\"}}]}")
102
76
 
103
77
  response = @client.subscriber('jdoe@example.com')
@@ -120,85 +94,48 @@ class Drip::ClientTest < Drip::TestCase
120
94
  @client = Drip::Client.new do |config|
121
95
  config.api_key = @key
122
96
  config.url_prefix = @url_prefix
97
+ config.account_id = "12345"
123
98
  end
124
99
  end
125
100
 
126
- should "connect to alternate prefix" do
127
- stub_request(:get, "https://api.example.com/v9001/testpath").
101
+ should "connect to alternate prefix with prepended v2" do
102
+ stub_request(:get, "https://api.example.com/v9001/v2/12345/subscribers/blah").
128
103
  to_return(status: 200, body: "", headers: {})
129
- @client.get("testpath")
104
+ @client.subscriber("blah")
130
105
 
131
- assert_requested :get, "https://api.example.com/v9001/testpath"
106
+ assert_requested :get, "https://api.example.com/v9001/v2/12345/subscribers/blah"
132
107
  end
133
108
  end
134
109
 
135
- context "given a OAuth access token" do
136
- setup do
137
- @key = "aaaa"
138
- @client = Drip::Client.new do |config|
139
- config.access_token = @key
140
- end
141
- end
142
-
143
- should "use Bearer token authentication" do
144
- stub_request(:get, "https://api.getdrip.com/v2/testpath").
145
- to_return(status: 200, body: "", headers: {})
146
- @client.get("testpath")
147
- header = "Bearer #{@key}"
148
- assert_requested :get, "https://api.getdrip.com/v2/testpath", headers: { 'Authorization' => header }
110
+ context "#generate_resource" do
111
+ # Deprecated
112
+ should "return a resource and note deprecation" do
113
+ client = Drip::Client.new
114
+ resource = nil
115
+ assert_output(nil, /^\[DEPRECATED\] Drip\:\:Client\#generate_resource is deprecated/) { resource = client.generate_resource("hello", {}) }
116
+ assert_equal({ "hello" => [{}] }, resource)
149
117
  end
150
118
  end
151
119
 
152
- context "given a redirecting url" do
153
- setup do
154
- @client = Drip::Client.new
120
+ context "#content_type" do
121
+ # Deprecated
122
+ should "return default content type and print warning" do
123
+ client = Drip::Client.new
124
+ content_type = nil
125
+ assert_output(nil, /^\[DEPRECATED\] Drip\:\:Client\#content_type is deprecated/) { content_type = client.content_type }
126
+ assert_equal "application/vnd.api+json", content_type
155
127
  end
128
+ end
156
129
 
157
- should "follow redirect" do
130
+ context "#get et all" do
131
+ # Deprecated
132
+ should "delegate with v2 and print deprecation warning" do
158
133
  stub_request(:get, "https://api.getdrip.com/v2/testpath").
159
- to_return(status: 301, body: "", headers: { "Location" => "https://api.example.com/mytestpath" })
160
- stub_request(:get, "https://api.example.com/mytestpath").
161
134
  to_return(status: 200, body: "{}")
162
- response = @client.get("testpath")
163
- assert_requested :get, "https://api.getdrip.com/v2/testpath"
164
- assert_requested :get, "https://api.example.com/mytestpath"
165
- assert_equal({}, response.body)
166
- end
167
135
 
168
- should "not follow too many redirects" do
169
- stub_request(:get, "https://api.getdrip.com/v2/testpath").
170
- to_return(status: 301, body: "", headers: { "Location" => "https://api.example.com/mytestpath" })
171
- stub_request(:get, "https://api.example.com/mytestpath").
172
- to_return(status: 302, body: "", headers: { "Location" => "https://api.getdrip.com/v2/testpath" })
173
- assert_raises(Drip::TooManyRedirectsError) { @client.get("testpath") }
174
- assert_requested :get, "https://api.getdrip.com/v2/testpath", times: 5
175
- assert_requested :get, "https://api.example.com/mytestpath", times: 5
176
- end
177
- end
178
-
179
- context "given a get request" do
180
- setup do
181
- @client = Drip::Client.new
182
- @response = mock
183
- @response.stubs(:code).returns('200')
184
- @response.stubs(:body).returns('{}')
185
-
186
- @http = mock
187
- @http.expects(:request).returns(@response)
188
-
189
- @request = mock
190
- @request.stubs(:[]=)
191
- @request.stubs(:basic_auth)
192
- end
193
-
194
- should "encode query and not set body" do
195
- Net::HTTP::Get.expects(:new).returns(@request)
196
- Net::HTTP.expects(:start).yields(@http).returns(@response)
197
-
198
- @request.expects(:body=).never
199
- URI.expects(:encode_www_form).once
200
-
201
- response = @client.get("testpath")
136
+ client = Drip::Client.new
137
+ response = nil
138
+ assert_output(nil, /^\[DEPRECATED\] Drip\:\:Client\#get please use the API endpoint specific methods/) { response = client.get("testpath") }
202
139
  assert_equal({}, response.body)
203
140
  end
204
141
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.dirname(__FILE__) + '/../test_helper.rb'
2
4
 
3
5
  class Drip::CollectionTest < Drip::TestCase
@@ -42,6 +44,19 @@ class Drip::CollectionTest < Drip::TestCase
42
44
  end
43
45
  end
44
46
 
47
+ context ".collection_name" do
48
+ should "return default value" do
49
+ assert_equal "resources", Drip::Collection.collection_name
50
+ end
51
+ end
52
+
53
+ context ".resource_name" do
54
+ should "return default value" do
55
+ assert_equal "resource", Drip::Collection.resource_name
56
+ end
57
+ end
58
+
59
+ # :nocov:
45
60
  class TestCollection < Drip::Collection
46
61
  def self.collection_name
47
62
  "subscribers"
@@ -51,4 +66,5 @@ class Drip::CollectionTest < Drip::TestCase
51
66
  "subscriber"
52
67
  end
53
68
  end
69
+ # :nocov:
54
70
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.dirname(__FILE__) + '/../../test_helper.rb'
4
+ require "drip/collections/accounts"
5
+
6
+ class Drip::AccountsTest < Drip::TestCase
7
+ should "have a resource name" do
8
+ assert_equal "account", Drip::Accounts.resource_name
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.dirname(__FILE__) + '/../../test_helper.rb'
4
+ require "drip/collections/broadcasts"
5
+
6
+ class Drip::BroadcastsTest < Drip::TestCase
7
+ should "have a resource name" do
8
+ assert_equal "broadcast", Drip::Broadcasts.resource_name
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.dirname(__FILE__) + '/../../test_helper.rb'
4
+ require "drip/collections/campaign_subscriptions"
5
+
6
+ class Drip::CampaignSubscriptionsTest < Drip::TestCase
7
+ should "have a resource name" do
8
+ assert_equal "campaign_subscription", Drip::CampaignSubscriptions.resource_name
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.dirname(__FILE__) + '/../../test_helper.rb'
4
+ require "drip/collections/campaigns"
5
+
6
+ class Drip::CampaignsTest < Drip::TestCase
7
+ should "have a resource name" do
8
+ assert_equal "campaign", Drip::Campaigns.resource_name
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.dirname(__FILE__) + '/../../test_helper.rb'
4
+ require "drip/collections/errors"
5
+
6
+ class Drip::ErrorsTest < Drip::TestCase
7
+ should "have a resource name" do
8
+ assert_equal "error", Drip::Errors.resource_name
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.dirname(__FILE__) + '/../../test_helper.rb'
4
+ require "drip/collections/orders"
5
+
6
+ class Drip::OrdersTest < Drip::TestCase
7
+ should "have a resource name" do
8
+ assert_equal "order", Drip::Orders.resource_name
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.dirname(__FILE__) + '/../../test_helper.rb'
4
+ require "drip/collections/purchases"
5
+
6
+ class Drip::PurchasesTest < Drip::TestCase
7
+ should "have a resource name" do
8
+ assert_equal "purchase", Drip::Purchases.resource_name
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.dirname(__FILE__) + '/../../test_helper.rb'
4
+ require "drip/collections/tags"
5
+
6
+ class Drip::TagsTest < Drip::TestCase
7
+ should "have a resource name" do
8
+ assert_equal "tag", Drip::Tags.resource_name
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.dirname(__FILE__) + '/../../test_helper.rb'
4
+ require "drip/collections/webhooks"
5
+
6
+ class Drip::WebhooksTest < Drip::TestCase
7
+ should "have a resource name" do
8
+ assert_equal "webhook", Drip::Webhooks.resource_name
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.dirname(__FILE__) + '/../../test_helper.rb'
4
+ require "drip/collections/workflow_triggers"
5
+
6
+ class Drip::WorkflowTriggersTest < Drip::TestCase
7
+ should "have a resource name" do
8
+ assert_equal "workflow_trigger", Drip::WorkflowTriggers.resource_name
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.dirname(__FILE__) + '/../../test_helper.rb'
4
+ require "drip/collections/workflows"
5
+
6
+ class Drip::WorkflowsTest < Drip::TestCase
7
+ should "have a resource name" do
8
+ assert_equal "workflow", Drip::Workflows.resource_name
9
+ end
10
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.dirname(__FILE__) + '/../test_helper.rb'
2
4
 
3
5
  class Drip::CollectionsTest < Drip::TestCase
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.dirname(__FILE__) + '/../test_helper.rb'
4
+ require "drip/request"
5
+
6
+ class Drip::RequestTest < Drip::TestCase
7
+ context "basic data" do
8
+ should "pass through data" do
9
+ request = Drip::Request.new(:get, "https://www.example.com/blah", { hello: "world" }, "application/vnd.visio")
10
+ assert_equal :get, request.http_verb
11
+ assert_equal "https://www.example.com/blah", request.url
12
+ assert_equal({ hello: "world" }, request.options)
13
+ assert_equal "application/vnd.visio", request.content_type
14
+ end
15
+ end
16
+
17
+ context "#verb_klass" do
18
+ context "when a supported verb" do
19
+ setup do
20
+ @subject = Drip::Request.new(:get, "https://www.example.com/blah", { hello: "world" }, "application/vnd.visio")
21
+ end
22
+
23
+ should "return a useful http class" do
24
+ assert_equal Net::HTTP::Get, @subject.verb_klass
25
+ end
26
+ end
27
+
28
+ context "when an unsupported verb" do
29
+ setup do
30
+ @subject = Drip::Request.new(:garbage, "https://www.example.com/blah", { hello: "world" }, "application/vnd.visio")
31
+ end
32
+
33
+ should "return nil" do
34
+ assert_nil @subject.verb_klass
35
+ end
36
+ end
37
+ end
38
+
39
+ context "#body" do
40
+ context "when HTTP GET" do
41
+ setup do
42
+ @subject = Drip::Request.new(:get, "https://www.example.com/blah", { hello: "world" }, "application/vnd.visio")
43
+ end
44
+
45
+ should "return nil" do
46
+ assert_nil @subject.body
47
+ end
48
+ end
49
+
50
+ context "when HTTP POST" do
51
+ setup do
52
+ @subject = Drip::Request.new(:post, "https://www.example.com/blah", { hello: "world" }, "application/vnd.visio")
53
+ end
54
+
55
+ should "return JSON" do
56
+ assert_equal '{"hello":"world"}', @subject.body
57
+ end
58
+ end
59
+ end
60
+ end