http_stub 0.14.1 → 0.14.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.
- checksums.yaml +4 -4
- data/lib/http_stub.rb +3 -0
- data/lib/http_stub/extensions/rack/handler.rb +30 -0
- data/lib/http_stub/version.rb +1 -1
- data/spec/lib/http_stub/extensions/rack/handler_spec.rb +64 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 462d586bf168313bf0a34ff8549b6120d336503a
|
4
|
+
data.tar.gz: 1ea3c26af008e2a0fe3339c7827e170ecf252648
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c6a2fbd7db3b9e04d4b7ebdd52b7a4fe910001a1d11474962a532a61d5c1a86f7ed193891ff69aa701a724c7362ecbab5a2aed3ee84260208243547fa5a770c
|
7
|
+
data.tar.gz: 0fdb121126205ad0628b2aead6012ae5c6dd7828c1d5bedcfc726739f77cbadd5f1ffeb22c98819e316316f08f0b8343033c570375ca3a3efbe091168d7cbd29
|
data/lib/http_stub.rb
CHANGED
@@ -5,10 +5,13 @@ require 'sass'
|
|
5
5
|
require 'net/http'
|
6
6
|
require 'json'
|
7
7
|
require 'http_server_manager'
|
8
|
+
|
9
|
+
require 'active_support/core_ext/module/aliasing'
|
8
10
|
require 'active_support/core_ext/module/delegation'
|
9
11
|
require 'active_support/core_ext/hash/slice'
|
10
12
|
require 'active_support/core_ext/hash/deep_merge'
|
11
13
|
|
14
|
+
require_relative 'http_stub/extensions/rack/handler'
|
12
15
|
require_relative 'http_stub/hash_extensions'
|
13
16
|
require_relative 'http_stub/models/headers'
|
14
17
|
require_relative 'http_stub/models/response'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module HttpStub
|
2
|
+
module Extensions
|
3
|
+
module Rack
|
4
|
+
module Handler
|
5
|
+
|
6
|
+
def self.included(mod)
|
7
|
+
mod.extend(ClassMethods)
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
|
12
|
+
def self.extended(mod)
|
13
|
+
mod.singleton_class.alias_method_chain :get, :run_check
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_with_run_check(server)
|
17
|
+
handler = get_without_run_check(server)
|
18
|
+
raise NameError.new("#{server} Rack handler is invalid") unless handler.respond_to?(:run)
|
19
|
+
handler
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
::Rack::Handler.send(:include, ::HttpStub::Extensions::Rack::Handler)
|
data/lib/http_stub/version.rb
CHANGED
@@ -0,0 +1,64 @@
|
|
1
|
+
describe HttpStub::Extensions::Rack::Handler do
|
2
|
+
|
3
|
+
it "patches Rack::Handler" do
|
4
|
+
expect(::Rack::Handler.included_modules).to include(HttpStub::Extensions::Rack::Handler)
|
5
|
+
end
|
6
|
+
|
7
|
+
context "when mixed in to a module" do
|
8
|
+
|
9
|
+
module HttpStub::TestableRackHandler
|
10
|
+
|
11
|
+
class << self
|
12
|
+
|
13
|
+
attr_writer :handler
|
14
|
+
|
15
|
+
def get(server)
|
16
|
+
@handler
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
HttpStub::TestableRackHandler.send(:include, HttpStub::Extensions::Rack::Handler)
|
24
|
+
|
25
|
+
describe "the modules ::get" do
|
26
|
+
|
27
|
+
context "when the handler is runnable" do
|
28
|
+
|
29
|
+
module HttpStub::SomeRunnableRackHandler
|
30
|
+
|
31
|
+
def self.run
|
32
|
+
# Intentionally blank
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
before(:example) { HttpStub::TestableRackHandler.handler = HttpStub::SomeRunnableRackHandler }
|
38
|
+
|
39
|
+
it "returns the handler" do
|
40
|
+
expect(HttpStub::TestableRackHandler.get("SomeHandler")).to eql(HttpStub::SomeRunnableRackHandler)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when the handler is not runnable" do
|
46
|
+
|
47
|
+
module HttpStub::SomeUnRunnableRackHandler
|
48
|
+
end
|
49
|
+
|
50
|
+
before(:example) { HttpStub::TestableRackHandler.handler = HttpStub::SomeUnRunnableRackHandler }
|
51
|
+
|
52
|
+
it "raises a NameError indicating the handler is invalid" do
|
53
|
+
expect { HttpStub::TestableRackHandler.get("SomeHandler") }.to(
|
54
|
+
raise_error(NameError, /SomeHandler Rack handler is invalid/)
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_stub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ueckerman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-04-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -259,6 +259,7 @@ files:
|
|
259
259
|
- "./lib/http_stub/configurer/server/request_processor.rb"
|
260
260
|
- "./lib/http_stub/controllers/stub_activator_controller.rb"
|
261
261
|
- "./lib/http_stub/controllers/stub_controller.rb"
|
262
|
+
- "./lib/http_stub/extensions/rack/handler.rb"
|
262
263
|
- "./lib/http_stub/hash_extensions.rb"
|
263
264
|
- "./lib/http_stub/models/exact_value_matcher.rb"
|
264
265
|
- "./lib/http_stub/models/hash_with_string_value_matchers.rb"
|
@@ -307,6 +308,7 @@ files:
|
|
307
308
|
- "./spec/lib/http_stub/configurer_spec.rb"
|
308
309
|
- "./spec/lib/http_stub/controllers/stub_activator_controller_spec.rb"
|
309
310
|
- "./spec/lib/http_stub/controllers/stub_controller_spec.rb"
|
311
|
+
- "./spec/lib/http_stub/extensions/rack/handler_spec.rb"
|
310
312
|
- "./spec/lib/http_stub/hash_extensions_spec.rb"
|
311
313
|
- "./spec/lib/http_stub/models/exact_value_matcher_spec.rb"
|
312
314
|
- "./spec/lib/http_stub/models/hash_with_string_value_matchers_spec.rb"
|
@@ -356,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
356
358
|
version: '0'
|
357
359
|
requirements: []
|
358
360
|
rubyforge_project: http_stub
|
359
|
-
rubygems_version: 2.
|
361
|
+
rubygems_version: 2.2.2
|
360
362
|
signing_key:
|
361
363
|
specification_version: 4
|
362
364
|
summary: A HTTP Server replaying configured stub responses
|
@@ -380,6 +382,7 @@ test_files:
|
|
380
382
|
- "./spec/lib/http_stub/configurer_spec.rb"
|
381
383
|
- "./spec/lib/http_stub/controllers/stub_activator_controller_spec.rb"
|
382
384
|
- "./spec/lib/http_stub/controllers/stub_controller_spec.rb"
|
385
|
+
- "./spec/lib/http_stub/extensions/rack/handler_spec.rb"
|
383
386
|
- "./spec/lib/http_stub/hash_extensions_spec.rb"
|
384
387
|
- "./spec/lib/http_stub/models/exact_value_matcher_spec.rb"
|
385
388
|
- "./spec/lib/http_stub/models/hash_with_string_value_matchers_spec.rb"
|