webvalve 1.0.2 → 1.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
  SHA256:
3
- metadata.gz: c27cfca3646bee0e4a3405dfd89591a279d39ec26693689953bc47bb887c860d
4
- data.tar.gz: 372b6c3d9f1ea51b9ba7313ad8836a1c926dbcb1b67c32a348a81522ba9c0b17
3
+ metadata.gz: 258ab9f12c33a103010fd6ae0fde275dda425623699c792bf6f5652ed8bb065c
4
+ data.tar.gz: 02ea9901da037bbc16ddf4be606c5f2aa71a91320378192cef0b3da8a21d470a
5
5
  SHA512:
6
- metadata.gz: 75425fd1a5e8b11a40863e375b64a2c71a8f7f5a9399d8dc3bc0bc86aba4241a9b210c2c384db54e33960aa67906ffd14195a3b289fc81b61212182497a5d667
7
- data.tar.gz: 67598716476b08fddfea8de71321660fe3b3af454fb133cf4968c37ac958eda9daebc724961c534dcb8a13dfab315b1ce7bc12ee65807d2d6733a86eec7e102d
6
+ metadata.gz: '09ca5fd0597e1620d06f05db92f27a05e01ed20320a644ae5c08615ac6dc7bcb46210fc142b708fd5a42dbb207cd6da112417286c4194734b29f0a32e49951dd'
7
+ data.tar.gz: bb1a313e30a0b1c0df6148abee38194666d3013625ee9d042816af461afa8e90567a438f6f49c3e8cd287ecb75dfec6d2a0b88e21371e97e2894b424fdbab32d
@@ -9,6 +9,14 @@ and this project aims to adhere to [Semantic Versioning](http://semver.org/spec/
9
9
  ### Added
10
10
  ### Removed
11
11
 
12
+ ## [1.1.0] - 2020-04-27
13
+ ### Changed
14
+ - Allow the same URL for services as long as basic auth is different
15
+ (https://github.com/Betterment/webvalve/pull/46)
16
+ - Introduce `reset!` and `clear!` to replace `reset`
17
+ https://github.com/Betterment/webvalve/pull/45)
18
+
19
+
12
20
  ## [1.0.2] - 2020-04-27
13
21
  ### Changed
14
22
  - Fix an issue with setup / reset
@@ -68,7 +76,8 @@ and this project aims to adhere to [Semantic Versioning](http://semver.org/spec/
68
76
  ### Changed
69
77
  - WebMock 3+ support from @messanjah (https://github.com/Betterment/webvalve/pull/22)
70
78
 
71
- [Unreleased]: https://github.com/Betterment/webvalve/compare/v1.0.2...HEAD
79
+ [Unreleased]: https://github.com/Betterment/webvalve/compare/v1.1.0...HEAD
80
+ [1.1.0]: https://github.com/Betterment/webvalve/compare/v1.0.2...v1.1.0
72
81
  [1.0.2]: https://github.com/Betterment/webvalve/compare/v1.0.1...v1.0.2
73
82
  [1.0.1]: https://github.com/Betterment/webvalve/compare/v1.0.0...v1.0.1
74
83
  [1.0.0]: https://github.com/Betterment/webvalve/compare/v0.12.0...v1.0.0
data/README.md CHANGED
@@ -170,8 +170,7 @@ RSpec.configure do |config|
170
170
  end
171
171
 
172
172
  config.around :each do |ex|
173
- WebValve.reset
174
- WebValve.setup
173
+ WebValve.reset!
175
174
  ex.run
176
175
  end
177
176
  end
@@ -10,11 +10,13 @@ module WebValve
10
10
  # @see WebValve::Manager#register
11
11
  # @!method allow_url
12
12
  # @see WebValve::Manager#allow_url
13
- # @!method reset
14
- # @see WebValve::Manager#reset
13
+ # @!method reset!
14
+ # @see WebValve::Manager#reset!
15
+ # @!method clear!
16
+ # @see WebValve::Manager#clear!
15
17
  # @!method enabled?
16
18
  # @see WebValve::Manager#enabled?
17
- delegate :setup, :register, :allow_url, :reset, :enabled?, to: :manager
19
+ delegate :setup, :register, :allow_url, :reset!, :clear!, :enabled?, to: :manager
18
20
  attr_writer :logger
19
21
 
20
22
  def config_paths
@@ -52,6 +54,15 @@ module WebValve
52
54
  def manager
53
55
  WebValve::Manager.instance
54
56
  end
57
+
58
+ def reset
59
+ ActiveSupport::Deprecation.warn <<~WARN.squish
60
+ `WebValve.reset` is deprecated.
61
+ Please use `WebValve.clear!` (the old 'reset' behavior)
62
+ or `WebValve.reset!` (which also runs 'setup')
63
+ WARN
64
+ clear!
65
+ end
55
66
  end
56
67
  end
57
68
 
@@ -15,11 +15,14 @@ module WebValve
15
15
  value_from_env.present? && WebValve::DISABLED_VALUES.include?(value_from_env.to_s)
16
16
  end
17
17
 
18
+ def full_url
19
+ @full_url ||= custom_service_url || default_service_url
20
+ end
21
+
18
22
  def service_url
19
23
  @service_url ||= begin
20
- url = custom_service_url || default_service_url
21
- raise missing_url_message if url.blank?
22
- strip_basic_auth url
24
+ raise missing_url_message if full_url.blank?
25
+ strip_basic_auth full_url
23
26
  end
24
27
  end
25
28
 
@@ -67,7 +67,13 @@ module WebValve
67
67
  end
68
68
 
69
69
  # @api private
70
- def reset
70
+ def reset!
71
+ clear!
72
+ setup
73
+ end
74
+
75
+ # @api private
76
+ def clear!
71
77
  allowlisted_urls.clear
72
78
  fake_service_configs.clear
73
79
  stubbed_urls.clear
@@ -146,8 +152,8 @@ module WebValve
146
152
  end
147
153
 
148
154
  def ensure_non_duplicate_stub(config)
149
- raise "Invalid config for #{config.service_class_name}. Already stubbed url #{config.service_url}" if stubbed_urls.include?(config.service_url)
150
- stubbed_urls << config.service_url
155
+ raise "Invalid config for #{config.service_class_name}. Already stubbed url #{config.full_url}" if stubbed_urls.include?(config.full_url)
156
+ stubbed_urls << config.full_url
151
157
  end
152
158
 
153
159
  def load_configs!
@@ -3,8 +3,7 @@ require 'webmock/rspec'
3
3
 
4
4
  RSpec.configure do |c|
5
5
  c.around do |example|
6
- WebValve.reset
7
- WebValve.setup
6
+ WebValve.reset!
8
7
  example.run
9
8
  end
10
9
  end
@@ -1,3 +1,3 @@
1
1
  module WebValve
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -23,7 +23,7 @@ RSpec.describe WebValve::FakeService do
23
23
 
24
24
  describe 'integrated behavior' do
25
25
  after do
26
- WebValve.reset
26
+ WebValve.reset!
27
27
  end
28
28
 
29
29
  context 'when the service is at a root path' do
@@ -141,6 +141,21 @@ RSpec.describe WebValve::Manager do
141
141
  expect { subject.setup }.to raise_error('Invalid config for FakeOtherThing. Already stubbed url http://something.dev')
142
142
  end
143
143
  end
144
+
145
+ it 'does not raise with different HTTP auth patterns' do
146
+ disabled_service = class_double(WebValve::FakeService, name: 'FakeSomething')
147
+ other_disabled_service = class_double(WebValve::FakeService, name: 'FakeOtherThing')
148
+ web_mock_stubble = double(to_rack: true)
149
+ allow(WebMock).to receive(:stub_request).and_return(web_mock_stubble)
150
+
151
+ with_env 'SOMETHING_API_URL' => 'http://user1@something.dev', 'OTHER_THING_API_URL' => 'http://user2@something.dev' do
152
+ subject.register disabled_service.name
153
+ subject.register other_disabled_service.name
154
+
155
+ expect { subject.setup }.to_not raise_error
156
+ expect(WebMock).to have_received(:stub_request).with(:any, %r{\Ahttp://something\.dev}).twice
157
+ end
158
+ end
144
159
  end
145
160
 
146
161
  context 'when WebValve is on and allowing traffic' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webvalve
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Moore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-27 00:00:00.000000000 Z
11
+ date: 2020-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport