fake_stripe 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 413ab3d5a27b5f4ae2a6be8cb3bfa8b16630bd06e6e2d34a5b96ce206cf06e1b
4
- data.tar.gz: 4c110b55b4c1677b7070d76fd99eee063bbd186dc463a1e50249996341e7fd04
3
+ metadata.gz: 95608f72cf54e33d771f23240b0a404a5ad5048d29a72715ae6bace87bd3b1f1
4
+ data.tar.gz: 0a674d0aefda0dc92596bad72dddb0b9030fb36c171c08a8111ec844cb92ee2e
5
5
  SHA512:
6
- metadata.gz: b9a000e2733d4a823c2de60d55f9b53f75261799c05cdae3546603040bc1ad1561c69ee28b713e78c75fd7498bd0a68d0aa395102253120936a918eb2b49a65b
7
- data.tar.gz: 45ed28b5046d62eb4001cec3581578dd62b912c130d31eeaa57c2ab081d25beabb3bc725d7992240838736a52ba72eede1aa2409031e88cf6fa418018f4815e5
6
+ metadata.gz: d4744a1e8c3908b102f66715831dd6f94d5352a2b898a96465ae9c987753903e392aea45f9883b69abd85840a2d11678e00bcf6f31e61b92d8bc4dd7e475062f
7
+ data.tar.gz: 3ab46254d45a9f961572b1fe26d766fcad63a190d4cfce3a12f5015a08903d6aa3b0cf900316a6fcb539cf4633bf5ca2a0bfe099697190ffba2eb86a037f3df5
@@ -2,6 +2,7 @@ require 'fake_stripe/configuration'
2
2
  require 'fake_stripe/initializers/webmock'
3
3
  require 'fake_stripe/stub_app'
4
4
  require 'fake_stripe/stub_stripe_js'
5
+ require 'fake_stripe/stub_stripe_connect'
5
6
 
6
7
  module FakeStripe
7
8
  extend Configuration
@@ -33,8 +34,10 @@ module FakeStripe
33
34
  Stripe.api_key = 'FAKE_STRIPE_API_KEY'
34
35
  FakeStripe.reset
35
36
  FakeStripe::StubStripeJS.boot_once
37
+ FakeStripe::StubStripeConnect.boot_once
36
38
  stub_request(:any, /api.stripe.com/).to_rack(FakeStripe::StubApp)
37
39
  end
38
40
  end
39
41
 
40
42
  STRIPE_JS_HOST = "http://localhost:#{FakeStripe::StubStripeJS.server_port}"
43
+ STRIPE_CONNECT_HOST = "http://localhost:#{FakeStripe::StubStripeConnect.server_port}"
@@ -1,7 +1,7 @@
1
1
  class Element {
2
2
  mount(el) {
3
3
  if (typeof el === "string") {
4
- el = document.querySelector(el)[0];
4
+ el = document.querySelector(el);
5
5
  }
6
6
 
7
7
  el.innerHTML = `
@@ -0,0 +1,18 @@
1
+ require "capybara"
2
+ require "capybara/server"
3
+ require "fake_stripe/utils"
4
+
5
+ module Bootable
6
+ def boot(port = FakeStripe::Utils.find_available_port)
7
+ instance = new
8
+ Capybara::Server.new(instance, port: port).tap(&:boot)
9
+ end
10
+
11
+ def boot_once
12
+ @boot_once ||= boot(server_port)
13
+ end
14
+
15
+ def server_port
16
+ @server_port ||= FakeStripe::Utils.find_available_port
17
+ end
18
+ end
@@ -0,0 +1,37 @@
1
+ require "fake_stripe/bootable"
2
+ require "sinatra/base"
3
+
4
+ module FakeStripe
5
+ class StubStripeConnect < Sinatra::Base
6
+ extend Bootable
7
+
8
+ CODE = "stripe_connect_express_oauth_authorization_code".freeze
9
+
10
+ post "/oauth/token" do
11
+ code = params[:code]
12
+ if code == CODE
13
+ {
14
+ access_token: "ACCESS_TOKEN",
15
+ livemode: false,
16
+ refresh_token: "REFRESH_TOEKN",
17
+ token_type: "bearer",
18
+ stripe_publishable_key: "PUBLISHABLE_KEY",
19
+ stripe_user_id: "acc_stripe_user_id",
20
+ scope: "express",
21
+ }.to_json
22
+ else
23
+ status 400
24
+ {
25
+ error: "invalid_grant",
26
+ error_description: "Authorization code does not exist: #{code}",
27
+ }.to_json
28
+ end
29
+ end
30
+
31
+ get "/express/oauth/authorize" do
32
+ uri = URI(params[:redirect_uri])
33
+ uri.query = URI.encode_www_form(state: params[:state], code: CODE)
34
+ redirect uri
35
+ end
36
+ end
37
+ end
@@ -1,10 +1,10 @@
1
- require "capybara"
2
- require "capybara/server"
3
- require "fake_stripe/utils"
1
+ require "fake_stripe/bootable"
4
2
  require "sinatra/base"
5
3
 
6
4
  module FakeStripe
7
5
  class StubStripeJS < Sinatra::Base
6
+ extend Bootable
7
+
8
8
  get "/v1/" do
9
9
  file_path = File.join(File.dirname(__FILE__), "/assets/v1.js")
10
10
 
@@ -29,18 +29,5 @@ module FakeStripe
29
29
  status 200
30
30
  IO.read(file_path)
31
31
  end
32
-
33
- def self.boot(port = FakeStripe::Utils.find_available_port)
34
- instance = new
35
- Capybara::Server.new(instance, port: port).tap(&:boot)
36
- end
37
-
38
- def self.boot_once
39
- @@stripe_js_server ||= FakeStripe::StubStripeJS.boot(server_port)
40
- end
41
-
42
- def self.server_port
43
- @@stripe_js_port ||= FakeStripe::Utils.find_available_port
44
- end
45
32
  end
46
33
  end
@@ -1,3 +1,3 @@
1
1
  module FakeStripe
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fake_stripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harlow Ward
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-25 00:00:00.000000000 Z
11
+ date: 2019-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -128,6 +128,7 @@ files:
128
128
  - lib/fake_stripe/assets/v2-mock.js
129
129
  - lib/fake_stripe/assets/v2.js
130
130
  - lib/fake_stripe/assets/v3.js
131
+ - lib/fake_stripe/bootable.rb
131
132
  - lib/fake_stripe/configuration.rb
132
133
  - lib/fake_stripe/fixtures/cancel_subscription.json
133
134
  - lib/fake_stripe/fixtures/cancel_transfer.json
@@ -202,6 +203,7 @@ files:
202
203
  - lib/fake_stripe/fixtures/update_transfer.json
203
204
  - lib/fake_stripe/initializers/webmock.rb
204
205
  - lib/fake_stripe/stub_app.rb
206
+ - lib/fake_stripe/stub_stripe_connect.rb
205
207
  - lib/fake_stripe/stub_stripe_js.rb
206
208
  - lib/fake_stripe/utils.rb
207
209
  - lib/fake_stripe/version.rb
@@ -223,8 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
225
  - !ruby/object:Gem::Version
224
226
  version: '0'
225
227
  requirements: []
226
- rubyforge_project:
227
- rubygems_version: 2.7.7
228
+ rubygems_version: 3.0.3
228
229
  signing_key:
229
230
  specification_version: 4
230
231
  summary: A fake Stripe server.