webvalve 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -2
- data/Rakefile +10 -17
- data/lib/webvalve.rb +26 -4
- data/lib/webvalve/fake_service_config.rb +1 -1
- data/lib/webvalve/instrumentation/log_subscriber.rb +2 -0
- data/lib/webvalve/instrumentation/middleware.rb +2 -0
- data/lib/webvalve/manager.rb +1 -1
- data/lib/webvalve/{engine.rb → railtie.rb} +3 -5
- data/lib/webvalve/version.rb +1 -1
- data/spec/dummy/config/routes.rb +0 -1
- data/spec/dummy/log/test.log +36 -0
- data/spec/examples.txt +32 -0
- data/spec/spec_helper.rb +11 -1
- data/spec/support/helpers.rb +3 -3
- data/spec/webvalve/fake_service_config_spec.rb +1 -1
- data/spec/webvalve/fake_service_spec.rb +1 -1
- data/spec/webvalve/manager_spec.rb +1 -1
- data/spec/webvalve_spec.rb +1 -1
- metadata +9 -8
- data/lib/tasks/webvalve_tasks.rake +0 -0
- data/spec/rails_helper.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e60a2b347e2feeac25e77f2f00ea08bd47a21ac
|
4
|
+
data.tar.gz: f24d8a35e41dcb5bb9ddf34c5bc6462a2a0ac2d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e683adde8772005f7128f32cc5bed08477acf771bece27ebd18248eddbd90137e2ff18e9a38363ab84b51611d2da5ecde1f7cb3321944bae770e3af99e5df76
|
7
|
+
data.tar.gz: 6398326ced19332fd63ba9d1eac2dd69de6a3f1970c2186690f46479ad1d4f3a4735a357a34c5aaae89670c87b287af7c7ec086fa48561306fd65308327a849d
|
data/README.md
CHANGED
@@ -18,7 +18,8 @@ Check out [the Rails at Scale talk](https://www.youtube.com/watch?v=Nd9hnffxCP8)
|
|
18
18
|
|
19
19
|
## Getting Started
|
20
20
|
|
21
|
-
WebValve is designed to work with Rails 4
|
21
|
+
WebValve is designed to work with Rails 4+, but it also should work with
|
22
|
+
non-Rails apps and gems.
|
22
23
|
|
23
24
|
### Installation
|
24
25
|
|
@@ -75,6 +76,8 @@ This will drop a new file in your config directory.
|
|
75
76
|
# WebValve.whitelist_url 'https://example.com'
|
76
77
|
```
|
77
78
|
|
79
|
+
If you're not using Rails, you can create this file for yourself.
|
80
|
+
|
78
81
|
### Registering a service
|
79
82
|
|
80
83
|
Next, you will want create a `FakeService` and register
|
@@ -113,6 +116,9 @@ And it will automatically register it in `config/webvalve.rb`
|
|
113
116
|
WebValve.register FakeBank
|
114
117
|
```
|
115
118
|
|
119
|
+
Again, if you're not using Rails, you'll have to create this file
|
120
|
+
yourself and update the config file manually.
|
121
|
+
|
116
122
|
You'll also want to define an environment variable for the base url of
|
117
123
|
your service.
|
118
124
|
|
@@ -141,7 +147,7 @@ have to configure WebValve at the beginning of each test. For RSpec, there
|
|
141
147
|
is a configuration provided.
|
142
148
|
|
143
149
|
```ruby
|
144
|
-
# spec/
|
150
|
+
# spec/spec_helper.rb
|
145
151
|
require 'webvalve/rspec'
|
146
152
|
```
|
147
153
|
|
@@ -202,6 +208,13 @@ environments; however, it can be enabled in other environments by
|
|
202
208
|
setting `WEBVALVE_ENABLED=true`. This can be useful for spinning up
|
203
209
|
cheap, one-off environments for user-testing or demos.
|
204
210
|
|
211
|
+
> Can I use WebValve without Rails?
|
212
|
+
|
213
|
+
Yep! If you're not using Rails, you'll have to load the config file
|
214
|
+
yourself. You will want to explicitly `require` each of your fake
|
215
|
+
services in your `config/webvalve.rb`, `require` your config file, and
|
216
|
+
call `WebValve.setup` during your app's boot-up process.
|
217
|
+
|
205
218
|
## How to Contribute
|
206
219
|
|
207
220
|
We would love for you to contribute! Anything that benefits the majority
|
data/Rakefile
CHANGED
@@ -4,25 +4,18 @@ rescue LoadError
|
|
4
4
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
5
|
end
|
6
6
|
|
7
|
-
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
8
|
-
load 'rails/tasks/engine.rake'
|
9
|
-
|
10
7
|
Bundler::GemHelper.install_tasks
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
Appraisal::Task.new
|
23
|
-
task default: :appraisal
|
24
|
-
end
|
25
|
-
end
|
9
|
+
task(:default).clear
|
10
|
+
if ENV['APPRAISAL_INITIALIZED'] || ENV['TRAVIS']
|
11
|
+
require 'rspec/core'
|
12
|
+
require 'rspec/core/rake_task'
|
13
|
+
RSpec::Core::RakeTask.new(:spec)
|
14
|
+
task default: :spec
|
15
|
+
else
|
16
|
+
require 'appraisal'
|
17
|
+
Appraisal::Task.new
|
18
|
+
task default: :appraisal
|
26
19
|
end
|
27
20
|
|
28
21
|
require 'yard'
|
data/lib/webvalve.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'set'
|
2
|
+
require 'active_support'
|
3
|
+
require 'active_support/core_ext'
|
2
4
|
|
3
5
|
module WebValve
|
4
6
|
ALWAYS_ENABLED_ENVS = %w(development test).freeze
|
@@ -16,9 +18,9 @@ module WebValve
|
|
16
18
|
delegate :setup, :register, :whitelist_url, :reset, to: :manager
|
17
19
|
|
18
20
|
def enabled?
|
19
|
-
if
|
21
|
+
if env.in?(ALWAYS_ENABLED_ENVS)
|
20
22
|
if ENV.key? 'WEBVALVE_ENABLED'
|
21
|
-
|
23
|
+
logger.warn(<<~MESSAGE)
|
22
24
|
WARNING: Ignoring WEBVALVE_ENABLED environment variable setting (#{ENV['WEBVALVE_ENABLED']})
|
23
25
|
WebValve is always enabled in development and test environments.
|
24
26
|
MESSAGE
|
@@ -33,7 +35,27 @@ module WebValve
|
|
33
35
|
@config_paths ||= Set.new
|
34
36
|
end
|
35
37
|
|
36
|
-
|
38
|
+
if defined?(::Rails)
|
39
|
+
delegate :env, :env=, :logger, :logger=, to: ::Rails
|
40
|
+
else
|
41
|
+
def env
|
42
|
+
@env ||= (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development').inquiry
|
43
|
+
end
|
44
|
+
|
45
|
+
def env=(env)
|
46
|
+
@env = env&.inquiry
|
47
|
+
end
|
48
|
+
|
49
|
+
def logger
|
50
|
+
@logger ||= ActiveSupport::Logger.new(STDOUT).tap do |l|
|
51
|
+
l.formatter = ::Logger::Formatter.new
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def logger=(logger)
|
56
|
+
@logger = logger
|
57
|
+
end
|
58
|
+
end
|
37
59
|
|
38
60
|
def manager
|
39
61
|
WebValve::Manager.instance
|
@@ -41,8 +63,8 @@ module WebValve
|
|
41
63
|
end
|
42
64
|
end
|
43
65
|
|
66
|
+
require 'webvalve/railtie' if defined?(::Rails)
|
44
67
|
require 'webvalve/instrumentation'
|
45
|
-
require 'webvalve/engine'
|
46
68
|
require 'webvalve/fake_service'
|
47
69
|
require 'webvalve/fake_service_wrapper'
|
48
70
|
require 'webvalve/fake_service_config'
|
data/lib/webvalve/manager.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
module WebValve
|
2
|
-
class
|
3
|
-
isolate_namespace WebValve
|
4
|
-
|
2
|
+
class Railtie < ::Rails::Railtie
|
5
3
|
if WebValve.enabled?
|
6
|
-
initializer
|
4
|
+
initializer 'webvalve.set_autoload_paths', before: :set_autoload_paths do |app|
|
7
5
|
WebValve.config_paths << app.root
|
8
6
|
|
9
7
|
WebValve.config_paths.each do |root|
|
@@ -11,7 +9,7 @@ module WebValve
|
|
11
9
|
end
|
12
10
|
end
|
13
11
|
|
14
|
-
initializer
|
12
|
+
initializer 'webvalve.setup' do
|
15
13
|
WebValve.config_paths.each do |root|
|
16
14
|
path = root.join('config', 'webvalve.rb').to_s
|
17
15
|
load path if File.exist?(path)
|
data/lib/webvalve/version.rb
CHANGED
data/spec/dummy/config/routes.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
[1m[33mWebValve Request Captured (0.4ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
2
|
+
[1m[33mWebValve Request Captured (4.8ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
3
|
+
[1m[33mWebValve Request Captured (3.0ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
4
|
+
[1m[33mWebValve Request Captured (0.8ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
5
|
+
[1m[33mWebValve Request Captured (3.9ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
6
|
+
[1m[33mWebValve Request Captured (0.4ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
7
|
+
[1m[33mWebValve Request Captured (2.6ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
8
|
+
[1m[33mWebValve Request Captured (0.5ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
9
|
+
[1m[33mWebValve Request Captured (0.4ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
10
|
+
[1m[33mWebValve Request Captured (2.2ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
11
|
+
[1m[33mWebValve Request Captured (0.5ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
12
|
+
[1m[33mWebValve Request Captured (3.9ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
13
|
+
[1m[33mWebValve Request Captured (2.1ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
14
|
+
[1m[33mWebValve Request Captured (0.3ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
15
|
+
[1m[33mWebValve Request Captured (2.9ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
16
|
+
[1m[33mWebValve Request Captured (0.4ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
17
|
+
[1m[33mWebValve Request Captured (0.4ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
18
|
+
[1m[33mWebValve Request Captured (4.9ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
19
|
+
[1m[33mWebValve Request Captured (2.1ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
20
|
+
[1m[33mWebValve Request Captured (0.4ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
21
|
+
[1m[33mWebValve Request Captured (0.5ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
22
|
+
[1m[33mWebValve Request Captured (2.2ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
23
|
+
[1m[33mWebValve Request Captured (0.5ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
24
|
+
[1m[33mWebValve Request Captured (2.6ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
25
|
+
[1m[33mWebValve Request Captured (6.6ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
26
|
+
[1m[33mWebValve Request Captured (0.4ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
27
|
+
[1m[33mWebValve Request Captured (0.5ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
28
|
+
[1m[33mWebValve Request Captured (2.5ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
29
|
+
[1m[33mWebValve Request Captured (0.4ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
30
|
+
[1m[33mWebValve Request Captured (2.2ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
31
|
+
[1m[33mWebValve Request Captured (2.1ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
32
|
+
[1m[33mWebValve Request Captured (0.3ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
33
|
+
[1m[33mWebValve Request Captured (2.4ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
34
|
+
[1m[33mWebValve Request Captured (0.3ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
35
|
+
[1m[33mWebValve Request Captured (0.4ms)[0m [1m[1mdummy.dev GET /foos [][0m
|
36
|
+
[1m[33mWebValve Request Captured (2.2ms)[0m [1m[1mdummy.dev GET /widgets [200][0m
|
data/spec/examples.txt
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
example_id | status | run_time |
|
2
|
+
------------------------------------------------------ | ------ | --------------- |
|
3
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:1:1] | passed | 0.00015 seconds |
|
4
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:1:2] | passed | 0.00014 seconds |
|
5
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:2:1] | passed | 0.00019 seconds |
|
6
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:2:2] | passed | 0.00026 seconds |
|
7
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:2:3] | passed | 0.00024 seconds |
|
8
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:3:1] | passed | 0.00016 seconds |
|
9
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:3:2] | passed | 0.00021 seconds |
|
10
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:3:3:1] | passed | 0.00019 seconds |
|
11
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:3:3:2] | passed | 0.00027 seconds |
|
12
|
+
./spec/webvalve/fake_service_config_spec.rb[1:2:1] | passed | 0.0002 seconds |
|
13
|
+
./spec/webvalve/fake_service_config_spec.rb[1:2:2] | passed | 0.0002 seconds |
|
14
|
+
./spec/webvalve/fake_service_config_spec.rb[1:2:3] | passed | 0.00016 seconds |
|
15
|
+
./spec/webvalve/fake_service_spec.rb[1:1] | passed | 0.00236 seconds |
|
16
|
+
./spec/webvalve/fake_service_spec.rb[1:2:1] | passed | 0.00387 seconds |
|
17
|
+
./spec/webvalve/fake_service_spec.rb[1:2:2] | passed | 0.02133 seconds |
|
18
|
+
./spec/webvalve/manager_spec.rb[1:1] | passed | 0.00005 seconds |
|
19
|
+
./spec/webvalve/manager_spec.rb[1:2:1] | passed | 0.00213 seconds |
|
20
|
+
./spec/webvalve/manager_spec.rb[1:3:1] | passed | 0.00019 seconds |
|
21
|
+
./spec/webvalve/manager_spec.rb[1:4:1] | passed | 0.00011 seconds |
|
22
|
+
./spec/webvalve/manager_spec.rb[1:5:1] | passed | 0.00024 seconds |
|
23
|
+
./spec/webvalve/manager_spec.rb[1:5:2] | passed | 0.0084 seconds |
|
24
|
+
./spec/webvalve/manager_spec.rb[1:5:3] | passed | 0.00052 seconds |
|
25
|
+
./spec/webvalve/manager_spec.rb[1:5:4:1] | passed | 0.00049 seconds |
|
26
|
+
./spec/webvalve/manager_spec.rb[1:5:5:1] | passed | 0.0006 seconds |
|
27
|
+
./spec/webvalve/manager_spec.rb[1:5:5:2] | passed | 0.00079 seconds |
|
28
|
+
./spec/webvalve/manager_spec.rb[1:5:5:3] | passed | 0.0019 seconds |
|
29
|
+
./spec/webvalve_spec.rb[1:1] | passed | 0.00012 seconds |
|
30
|
+
./spec/webvalve_spec.rb[1:2] | passed | 0.00006 seconds |
|
31
|
+
./spec/webvalve_spec.rb[1:3] | passed | 0.00006 seconds |
|
32
|
+
./spec/webvalve_spec.rb[1:4] | passed | 0.00107 seconds |
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
require File.expand_path('dummy/config/environment', __dir__) if ENV['BUNDLE_GEMFILE'] =~ /rails/
|
3
|
+
require 'rspec'
|
4
|
+
require 'pry'
|
5
|
+
require 'webvalve'
|
6
|
+
|
7
|
+
Dir[File.join(__dir__, 'support/**/*.rb')].each { |f| require f }
|
8
|
+
|
1
9
|
RSpec.configure do |config|
|
2
10
|
config.expect_with :rspec do |expectations|
|
3
11
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
@@ -18,5 +26,7 @@ RSpec.configure do |config|
|
|
18
26
|
config.order = :random
|
19
27
|
Kernel.srand config.seed
|
20
28
|
|
21
|
-
|
29
|
+
config.profile_examples = 10
|
30
|
+
|
31
|
+
config.include Helpers
|
22
32
|
end
|
data/spec/support/helpers.rb
CHANGED
data/spec/webvalve_spec.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webvalve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Moore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -93,7 +93,7 @@ dependencies:
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: 2.2.0
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
|
-
name: rspec
|
96
|
+
name: rspec
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
99
|
- - ">="
|
@@ -147,9 +147,7 @@ files:
|
|
147
147
|
- Rakefile
|
148
148
|
- lib/generators/webvalve/fake_service_generator.rb
|
149
149
|
- lib/generators/webvalve/install_generator.rb
|
150
|
-
- lib/tasks/webvalve_tasks.rake
|
151
150
|
- lib/webvalve.rb
|
152
|
-
- lib/webvalve/engine.rb
|
153
151
|
- lib/webvalve/fake_service.rb
|
154
152
|
- lib/webvalve/fake_service_config.rb
|
155
153
|
- lib/webvalve/fake_service_wrapper.rb
|
@@ -157,6 +155,7 @@ files:
|
|
157
155
|
- lib/webvalve/instrumentation/log_subscriber.rb
|
158
156
|
- lib/webvalve/instrumentation/middleware.rb
|
159
157
|
- lib/webvalve/manager.rb
|
158
|
+
- lib/webvalve/railtie.rb
|
160
159
|
- lib/webvalve/rspec.rb
|
161
160
|
- lib/webvalve/version.rb
|
162
161
|
- spec/dummy/README.rdoc
|
@@ -189,11 +188,12 @@ files:
|
|
189
188
|
- spec/dummy/config/locales/en.yml
|
190
189
|
- spec/dummy/config/routes.rb
|
191
190
|
- spec/dummy/config/secrets.yml
|
191
|
+
- spec/dummy/log/test.log
|
192
192
|
- spec/dummy/public/404.html
|
193
193
|
- spec/dummy/public/422.html
|
194
194
|
- spec/dummy/public/500.html
|
195
195
|
- spec/dummy/public/favicon.ico
|
196
|
-
- spec/
|
196
|
+
- spec/examples.txt
|
197
197
|
- spec/spec_helper.rb
|
198
198
|
- spec/support/helpers.rb
|
199
199
|
- spec/webvalve/fake_service_config_spec.rb
|
@@ -259,10 +259,11 @@ test_files:
|
|
259
259
|
- spec/dummy/public/422.html
|
260
260
|
- spec/dummy/public/500.html
|
261
261
|
- spec/dummy/public/404.html
|
262
|
+
- spec/dummy/log/test.log
|
262
263
|
- spec/dummy/README.rdoc
|
264
|
+
- spec/examples.txt
|
263
265
|
- spec/webvalve/fake_service_spec.rb
|
264
266
|
- spec/webvalve/fake_service_config_spec.rb
|
265
267
|
- spec/webvalve/manager_spec.rb
|
266
268
|
- spec/webvalve_spec.rb
|
267
269
|
- spec/support/helpers.rb
|
268
|
-
- spec/rails_helper.rb
|
File without changes
|
data/spec/rails_helper.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
ENV['RAILS_ENV'] ||= 'test'
|
2
|
-
require File.expand_path('../dummy/config/environment', __FILE__)
|
3
|
-
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
4
|
-
require 'spec_helper'
|
5
|
-
require 'rspec/rails'
|
6
|
-
require 'pry'
|
7
|
-
Dir[Rails.root.join("#{WebValve::Engine.root}/spec/support/**/*.rb")].each { |f| require f }
|
8
|
-
|
9
|
-
RSpec.configure do |config|
|
10
|
-
config.use_transactional_fixtures = true
|
11
|
-
config.infer_spec_type_from_file_location!
|
12
|
-
config.filter_rails_from_backtrace!
|
13
|
-
config.include Helpers
|
14
|
-
end
|