fake_stripe 0.0.12 → 0.1.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
  SHA1:
3
- metadata.gz: acd65407043a5ac202af43ed614414014be5a291
4
- data.tar.gz: 69fdbf9d57d9e1d51c4149fd5fc8a8ba8697e147
3
+ metadata.gz: a3e83c6e7c0077e6017382efc3785916d7e9c8ed
4
+ data.tar.gz: 72c506491392d9ee13eb6d000342cca5946d4c1c
5
5
  SHA512:
6
- metadata.gz: 14d904ff7e1a87c473a3b611d04b32de32c121ede19a0b0a4caf8d9a7e95b822979b638d8e2c42f20b998053f757dea2af93aca5b95a364966d5f06d74ba6cac
7
- data.tar.gz: d032e798bc9eba47313a5fa63c0b9c4cc88be36cd3e124a79c9320e169522f9bcb64c29afa3d7a5968e96a902f41a4661129061e79dc3ba37bcb964d42ce794a
6
+ metadata.gz: 8b62fe6dae65655deb06638bb064cf0136848ac65c2fc0bd9697143c47928835e1c3b36a72f51de710655cf20fe5bd9c18f870a652ae005327f8f18c55b41a9b
7
+ data.tar.gz: b993495c1dabda170cb5f2bb4c160749ba55989fadb0d2ea2b19e08a7b1b5a56d09e0d2e91401bd9c33741a09d4c7b7d042e683e7a4739a2d1a1075a63488956
data/README.md CHANGED
@@ -21,13 +21,6 @@ end
21
21
 
22
22
  Remember to run `bundle install`.
23
23
 
24
- ### Rails 5 Compatibility
25
-
26
- `fake_stripe` depends on Sinatra, which is currently in the process of being
27
- upgraded to use Rack 2.0, a requirement for compatibility with Rails 5. This
28
- should be resolved once Sinatra 2.0 is officially released; in the meantime,
29
- you can add `gem 'sinatra', '2.0.0.beta2'` to the `:test` group in your Gemfile.
30
-
31
24
  ### Stripe settings
32
25
 
33
26
  Set the `STRIPE_JS_HOST` constant in an initializer:
@@ -32,9 +32,9 @@ module FakeStripe
32
32
  def self.stub_stripe
33
33
  Stripe.api_key = 'FAKE_STRIPE_API_KEY'
34
34
  FakeStripe.reset
35
+ FakeStripe::StubStripeJS.boot_once
35
36
  stub_request(:any, /api.stripe.com/).to_rack(FakeStripe::StubApp)
36
37
  end
37
38
  end
38
39
 
39
- server = FakeStripe::StubStripeJS.boot
40
- STRIPE_JS_HOST = "http://#{server.host}:#{server.port}"
40
+ STRIPE_JS_HOST = "http://localhost:#{FakeStripe::StubStripeJS.server_port}"
@@ -1,5 +1,6 @@
1
1
  require 'capybara'
2
2
  require 'capybara/server'
3
+ require 'fake_stripe/utils'
3
4
  require 'sinatra/base'
4
5
 
5
6
  module FakeStripe
@@ -21,9 +22,17 @@ module FakeStripe
21
22
  IO.read(file_path) + IO.read(mock_file_path)
22
23
  end
23
24
 
24
- def self.boot
25
+ def self.boot(port = FakeStripe::Utils.find_available_port)
25
26
  instance = new
26
- Capybara::Server.new(instance).tap { |server| server.boot }
27
+ Capybara::Server.new(instance, port).tap { |server| server.boot }
28
+ end
29
+
30
+ def self.boot_once
31
+ @@stripe_js_server ||= FakeStripe::StubStripeJS.boot(self.server_port)
32
+ end
33
+
34
+ def self.server_port
35
+ @@stripe_js_port ||= FakeStripe::Utils.find_available_port
27
36
  end
28
37
  end
29
38
  end
@@ -0,0 +1,14 @@
1
+ require 'socket'
2
+
3
+ module FakeStripe
4
+ class Utils
5
+ FIND_AVAILABLE_PORT = 0
6
+
7
+ def self.find_available_port
8
+ server = TCPServer.new(FIND_AVAILABLE_PORT)
9
+ server.addr[1]
10
+ ensure
11
+ server.close if server
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module FakeStripe
2
- VERSION = '0.0.12'
2
+ VERSION = '0.1.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.0.12
4
+ version: 0.1.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: 2017-03-13 00:00:00.000000000 Z
11
+ date: 2017-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -187,6 +187,7 @@ files:
187
187
  - lib/fake_stripe/initializers/webmock.rb
188
188
  - lib/fake_stripe/stub_app.rb
189
189
  - lib/fake_stripe/stub_stripe_js.rb
190
+ - lib/fake_stripe/utils.rb
190
191
  - lib/fake_stripe/version.rb
191
192
  homepage: https://github.com/thoughtbot/fake_stripe
192
193
  licenses: []
@@ -207,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
208
  version: '0'
208
209
  requirements: []
209
210
  rubyforge_project:
210
- rubygems_version: 2.6.8
211
+ rubygems_version: 2.6.13
211
212
  signing_key:
212
213
  specification_version: 4
213
214
  summary: A fake Stripe server.