http_stub 0.7.4 → 0.8.0
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.
- data/lib/http_stub.rb +1 -0
- data/lib/http_stub/configurer/request/stub.rb +2 -1
- data/lib/http_stub/models/request_pipeline.rb +10 -0
- data/lib/http_stub/models/response.rb +4 -1
- data/lib/http_stub/rake/server_tasks.rb +33 -0
- data/lib/http_stub/rake/task_generators.rb +1 -1
- data/lib/http_stub/server.rb +1 -0
- data/lib/http_stub/version.rb +1 -1
- data/spec/lib/http_stub/configurer/request/stub_activator_spec.rb +1 -1
- data/spec/lib/http_stub/configurer/request/stub_spec.rb +1 -1
- data/spec/lib/http_stub/configurer_integration_spec.rb +20 -1
- data/spec/lib/http_stub/controllers/stub_activator_controller_spec.rb +4 -4
- data/spec/lib/http_stub/controllers/stub_controller_spec.rb +4 -4
- data/spec/lib/http_stub/models/hash_with_regexpable_values_spec.rb +6 -6
- data/spec/lib/http_stub/models/registry_spec.rb +2 -2
- data/spec/lib/http_stub/models/request_pipeline_spec.rb +24 -0
- data/spec/lib/http_stub/models/stub_activator_spec.rb +1 -1
- data/spec/lib/http_stub/models/stub_headers_spec.rb +3 -3
- data/spec/lib/http_stub/models/stub_parameters_spec.rb +1 -1
- data/spec/lib/http_stub/models/stub_spec.rb +9 -9
- data/spec/lib/http_stub/models/stub_uri_spec.rb +1 -1
- data/spec/lib/http_stub/rake/server_tasks_integration_spec.rb +21 -0
- data/spec/lib/http_stub/rake/server_tasks_spec.rb +38 -0
- data/spec/lib/http_stub/server_integration_spec.rb +1 -1
- data/spec/lib/http_stub/server_spec.rb +30 -20
- data/spec/spec_helper.rb +2 -1
- metadata +52 -31
- data/lib/http_stub/rake/start_server_task.rb +0 -21
- data/spec/lib/http_stub/rake/start_server_rake_integration_spec.rb +0 -17
data/lib/http_stub.rb
CHANGED
|
@@ -20,6 +20,7 @@ require File.expand_path('../http_stub/models/stub_parameters', __FILE__)
|
|
|
20
20
|
require File.expand_path('../http_stub/models/stub', __FILE__)
|
|
21
21
|
require File.expand_path('../http_stub/models/stub_activator', __FILE__)
|
|
22
22
|
require File.expand_path('../http_stub/models/registry', __FILE__)
|
|
23
|
+
require File.expand_path('../http_stub/models/request_pipeline', __FILE__)
|
|
23
24
|
require File.expand_path('../http_stub/controllers/stub_controller', __FILE__)
|
|
24
25
|
require File.expand_path('../http_stub/controllers/stub_activator_controller', __FILE__)
|
|
25
26
|
require File.expand_path('../http_stub/server', __FILE__)
|
|
@@ -14,7 +14,8 @@ module HttpStub
|
|
|
14
14
|
"parameters" => HttpStub::Configurer::Request::Regexpable.format(options[:parameters] || {}),
|
|
15
15
|
"response" => {
|
|
16
16
|
"status" => options[:response][:status] || 200,
|
|
17
|
-
"body" => options[:response][:body]
|
|
17
|
+
"body" => options[:response][:body],
|
|
18
|
+
"delay_in_seconds" => options[:response][:delay_in_seconds]
|
|
18
19
|
}
|
|
19
20
|
}.to_json
|
|
20
21
|
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module HttpStub
|
|
2
|
+
|
|
3
|
+
module Rake
|
|
4
|
+
|
|
5
|
+
class ServerTasks < ::Rake::TaskLib
|
|
6
|
+
|
|
7
|
+
def initialize(options)
|
|
8
|
+
define_start_task(options)
|
|
9
|
+
define_initialize_task(options) if options[:configurer]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def define_start_task(options)
|
|
15
|
+
desc "Starts stub #{options[:name]}"
|
|
16
|
+
task "start_#{options[:name]}" do
|
|
17
|
+
HttpStub::Server.instance_eval do
|
|
18
|
+
set :port, options[:port]
|
|
19
|
+
run!
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def define_initialize_task(options)
|
|
25
|
+
desc "Configures stub #{options[:name]}"
|
|
26
|
+
task("configure_#{options[:name]}") { options[:configurer].initialize! }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
data/lib/http_stub/server.rb
CHANGED
|
@@ -95,6 +95,7 @@ module HttpStub
|
|
|
95
95
|
response = @stub_controller.replay(request)
|
|
96
96
|
response = @stub_activator_controller.activate(request) if response.empty?
|
|
97
97
|
response = HttpStub::Models::Response::ERROR if response.empty?
|
|
98
|
+
HttpStub::Models::RequestPipeline.before_halt(response)
|
|
98
99
|
halt(response.status, response.body)
|
|
99
100
|
end
|
|
100
101
|
|
data/lib/http_stub/version.rb
CHANGED
|
@@ -6,7 +6,7 @@ describe HttpStub::Configurer::Request::StubActivator do
|
|
|
6
6
|
let(:stub_request_content_type) { "Some content type" }
|
|
7
7
|
let(:stub_request) { double("StubRequest", :content_type => stub_request_content_type, :body => stub_request_body) }
|
|
8
8
|
|
|
9
|
-
before(:each) { HttpStub::Configurer::Request::Stub.stub
|
|
9
|
+
before(:each) { HttpStub::Configurer::Request::Stub.stub(:new).and_return(stub_request) }
|
|
10
10
|
|
|
11
11
|
describe "when provided an activation uri, stub uri and stub options" do
|
|
12
12
|
|
|
@@ -26,7 +26,7 @@ describe HttpStub::Configurer::Request::Stub do
|
|
|
26
26
|
let(:request) { HttpStub::Configurer::Request::Stub.new(uri, stub_options) }
|
|
27
27
|
let(:request_body) { JSON.parse(request.body) }
|
|
28
28
|
|
|
29
|
-
before(:each) { HttpStub::Configurer::Request::Regexpable.stub
|
|
29
|
+
before(:each) { HttpStub::Configurer::Request::Regexpable.stub(:format) }
|
|
30
30
|
|
|
31
31
|
it "should create a HTTP POST request" do
|
|
32
32
|
request.method.should eql("POST")
|
|
@@ -377,7 +377,7 @@ describe HttpStub::Configurer, "when the server is running" do
|
|
|
377
377
|
describe "and an attempt is made to register a stub" do
|
|
378
378
|
|
|
379
379
|
before(:each) do
|
|
380
|
-
configurer.stub_response!("/some_stub_path", method: :get, response: { body: "Some stub body"
|
|
380
|
+
configurer.stub_response!("/some_stub_path", method: :get, response: { body: "Some stub body"})
|
|
381
381
|
end
|
|
382
382
|
|
|
383
383
|
it "should register the stub" do
|
|
@@ -389,6 +389,25 @@ describe HttpStub::Configurer, "when the server is running" do
|
|
|
389
389
|
|
|
390
390
|
end
|
|
391
391
|
|
|
392
|
+
describe "and an attempt is made to register a stub with a timeout" do
|
|
393
|
+
|
|
394
|
+
before(:each) do
|
|
395
|
+
configurer.stub_response!("/some_stub_path", method: :get, response: {:delay_in_seconds => 2})
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
it "should delegate to request pipeline" do
|
|
399
|
+
before = Time.new
|
|
400
|
+
|
|
401
|
+
response = Net::HTTP.get_response("localhost", "/some_stub_path", 8001)
|
|
402
|
+
response.code.should eql("200")
|
|
403
|
+
|
|
404
|
+
after = Time.now
|
|
405
|
+
|
|
406
|
+
(after - before).round().should be >= 2
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
end
|
|
410
|
+
|
|
392
411
|
end
|
|
393
412
|
|
|
394
413
|
describe "and the configurer has not been informed that the server has started" do
|
|
@@ -9,12 +9,12 @@ describe HttpStub::Controllers::StubActivatorController do
|
|
|
9
9
|
let(:stub_registry) { double("HttpStub::Models::StubRegistry").as_null_object }
|
|
10
10
|
let(:controller) { HttpStub::Controllers::StubActivatorController.new(stub_activator_registry, stub_registry) }
|
|
11
11
|
|
|
12
|
-
before(:each) { JSON.stub
|
|
12
|
+
before(:each) { JSON.stub(:parse).and_return(stub_activator_options) }
|
|
13
13
|
|
|
14
14
|
describe "#register" do
|
|
15
15
|
|
|
16
16
|
before(:each) do
|
|
17
|
-
HttpStub::Models::StubActivator.stub
|
|
17
|
+
HttpStub::Models::StubActivator.stub(:new).and_return(stub_activator)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it "should parse an options hash from the JSON request body" do
|
|
@@ -46,7 +46,7 @@ describe HttpStub::Controllers::StubActivatorController do
|
|
|
46
46
|
describe "when a stub activator has been registered that is activated by the request" do
|
|
47
47
|
|
|
48
48
|
before(:each) do
|
|
49
|
-
stub_activator_registry.stub
|
|
49
|
+
stub_activator_registry.stub(:find_for).with(request).and_return(stub_activator)
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
it "should add the activators stub to the stub registry" do
|
|
@@ -64,7 +64,7 @@ describe HttpStub::Controllers::StubActivatorController do
|
|
|
64
64
|
describe "when no stub activator is activated by the request" do
|
|
65
65
|
|
|
66
66
|
before(:each) do
|
|
67
|
-
stub_activator_registry.stub
|
|
67
|
+
stub_activator_registry.stub(:find_for).with(request).and_return(nil)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
it "should not add a stub to the registry" do
|
|
@@ -8,12 +8,12 @@ describe HttpStub::Controllers::StubController do
|
|
|
8
8
|
let(:registry) { double(HttpStub::Models::Registry).as_null_object }
|
|
9
9
|
let(:controller) { HttpStub::Controllers::StubController.new(registry) }
|
|
10
10
|
|
|
11
|
-
before(:each) { JSON.stub
|
|
11
|
+
before(:each) { JSON.stub(:parse).and_return(stub_options) }
|
|
12
12
|
|
|
13
13
|
describe "#register" do
|
|
14
14
|
|
|
15
15
|
before(:each) do
|
|
16
|
-
HttpStub::Models::Stub.stub
|
|
16
|
+
HttpStub::Models::Stub.stub(:new).and_return(the_stub)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "should parse an options hash from the JSON request body" do
|
|
@@ -45,7 +45,7 @@ describe HttpStub::Controllers::StubController do
|
|
|
45
45
|
describe "when a stub has been registered that should be replayed for the request" do
|
|
46
46
|
|
|
47
47
|
before(:each) do
|
|
48
|
-
registry.stub
|
|
48
|
+
registry.stub(:find_for).with(request).and_return(the_stub)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it "should return the stubs response" do
|
|
@@ -59,7 +59,7 @@ describe HttpStub::Controllers::StubController do
|
|
|
59
59
|
describe "when no stub should be replayed for the request" do
|
|
60
60
|
|
|
61
61
|
before(:each) do
|
|
62
|
-
registry.stub
|
|
62
|
+
registry.stub(:find_for).with(request).and_return(nil)
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
it "should return an empty response" do
|
|
@@ -14,7 +14,7 @@ describe HttpStub::Models::HashWithRegexpableValues do
|
|
|
14
14
|
let(:regexpable_hash) { HttpStub::Models::HashWithRegexpableValues.new(stubbed_hash) }
|
|
15
15
|
|
|
16
16
|
before(:each) do
|
|
17
|
-
regexpable_values.each { |value| HttpStub::Models::RegexpableValue.stub
|
|
17
|
+
regexpable_values.each { |value| HttpStub::Models::RegexpableValue.stub(:new).with(value.to_s).and_return(value) }
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it "should be hash" do
|
|
@@ -51,7 +51,7 @@ describe HttpStub::Models::HashWithRegexpableValues do
|
|
|
51
51
|
describe "and the values match" do
|
|
52
52
|
|
|
53
53
|
before(:each) do
|
|
54
|
-
regexpable_values.each { |value| value.stub
|
|
54
|
+
regexpable_values.each { |value| value.stub(:match?).with("another #{value}").and_return(true) }
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it "should return true" do
|
|
@@ -63,10 +63,10 @@ describe HttpStub::Models::HashWithRegexpableValues do
|
|
|
63
63
|
describe "and a value does not match" do
|
|
64
64
|
|
|
65
65
|
before(:each) do
|
|
66
|
-
regexpable_values.each { |value| value.stub
|
|
66
|
+
regexpable_values.each { |value| value.stub(:match?).with("another #{value}").and_return(true) }
|
|
67
67
|
|
|
68
68
|
non_matching_value = regexpable_values[1]
|
|
69
|
-
non_matching_value.stub
|
|
69
|
+
non_matching_value.stub(:match?).with("another #{non_matching_value}").and_return(false)
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
it "should return false" do
|
|
@@ -82,7 +82,7 @@ describe HttpStub::Models::HashWithRegexpableValues do
|
|
|
82
82
|
let(:provided_hash) { { "key1" => "value1", "differentkey2" => "another value2", "key3" => "value3" } }
|
|
83
83
|
|
|
84
84
|
before(:each) do
|
|
85
|
-
regexpable_values.each { |value| value.stub
|
|
85
|
+
regexpable_values.each { |value| value.stub(:match?).with(value.to_s).and_return(true) }
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
it "should return false" do
|
|
@@ -105,7 +105,7 @@ describe HttpStub::Models::HashWithRegexpableValues do
|
|
|
105
105
|
describe "and it has matching keys and values" do
|
|
106
106
|
|
|
107
107
|
before(:each) do
|
|
108
|
-
regexpable_values.each { |value| value.stub
|
|
108
|
+
regexpable_values.each { |value| value.stub(:match?).with("another #{value}").and_return(true) }
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
it "should return true" do
|
|
@@ -32,7 +32,7 @@ describe HttpStub::Models::Registry do
|
|
|
32
32
|
|
|
33
33
|
let(:matching_model) { models[1] }
|
|
34
34
|
|
|
35
|
-
before(:each) { matching_model.stub
|
|
35
|
+
before(:each) { matching_model.stub(:satisfies?).and_return(true) }
|
|
36
36
|
|
|
37
37
|
it "should return the model" do
|
|
38
38
|
registry.find_for(request).should eql(matching_model)
|
|
@@ -53,7 +53,7 @@ describe HttpStub::Models::Registry do
|
|
|
53
53
|
describe "and multiple registered models satisfy the request" do
|
|
54
54
|
|
|
55
55
|
before(:each) do
|
|
56
|
-
[0, 2].each { |i| models[i].stub
|
|
56
|
+
[0, 2].each { |i| models[i].stub(:satisfies?).and_return(true) }
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
it "should support model overrides by returning the last model registered" do
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
describe HttpStub::Models::RequestPipeline do
|
|
2
|
+
|
|
3
|
+
describe '.before_halt' do
|
|
4
|
+
|
|
5
|
+
let(:response) { double(HttpStub::Models::Response) }
|
|
6
|
+
let(:request_pipeline) { HttpStub::Models::RequestPipeline }
|
|
7
|
+
|
|
8
|
+
before(:each) do
|
|
9
|
+
request_pipeline.stub(:sleep)
|
|
10
|
+
response.stub(:delay_in_seconds).and_return(5)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'should sleep for specified duration' do
|
|
14
|
+
request_pipeline.should_receive(:sleep).with(5)
|
|
15
|
+
request_pipeline.before_halt(response)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'should skip sleep if not specified' do
|
|
19
|
+
request_pipeline.should_not_receive(:sleep)
|
|
20
|
+
response.stub(:delay_in_seconds).and_return(nil)
|
|
21
|
+
request_pipeline.before_halt(response)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -6,7 +6,7 @@ describe HttpStub::Models::StubActivator do
|
|
|
6
6
|
end
|
|
7
7
|
let(:stub_activator) { HttpStub::Models::StubActivator.new(options) }
|
|
8
8
|
|
|
9
|
-
before(:each) { HttpStub::Models::Stub.stub
|
|
9
|
+
before(:each) { HttpStub::Models::Stub.stub(:new).and_return(double(HttpStub::Models::Stub)) }
|
|
10
10
|
|
|
11
11
|
describe "#satisfies?" do
|
|
12
12
|
|
|
@@ -35,8 +35,8 @@ describe HttpStub::Models::StubHeaders do
|
|
|
35
35
|
let(:regexpable_stubbed_headers) { double(HttpStub::Models::HashWithRegexpableValues).as_null_object }
|
|
36
36
|
|
|
37
37
|
before(:each) do
|
|
38
|
-
HttpStub::Models::HashWithRegexpableValues.stub
|
|
39
|
-
HttpStub::Models::RequestHeaderParser.stub
|
|
38
|
+
HttpStub::Models::HashWithRegexpableValues.stub(:new).and_return(regexpable_stubbed_headers)
|
|
39
|
+
HttpStub::Models::RequestHeaderParser.stub(:parse).with(request).and_return(request_headers)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it "should parse the requests headers into a hash" do
|
|
@@ -53,7 +53,7 @@ describe HttpStub::Models::StubHeaders do
|
|
|
53
53
|
|
|
54
54
|
it "should delegate to the regexpable representation of the stubbed headers to determine a match" do
|
|
55
55
|
downcased_and_underscored_hash = { "another_request_key" => "value" }
|
|
56
|
-
request_headers.stub
|
|
56
|
+
request_headers.stub(:downcase_and_underscore_keys).and_return(downcased_and_underscored_hash)
|
|
57
57
|
regexpable_stubbed_headers.should_receive(:match?).with(downcased_and_underscored_hash).and_return(true)
|
|
58
58
|
|
|
59
59
|
stub_headers.match?(request).should be_true
|
|
@@ -33,7 +33,7 @@ describe HttpStub::Models::StubParameters do
|
|
|
33
33
|
describe "#match?" do
|
|
34
34
|
|
|
35
35
|
it "should delegate to the regexpable representation of the stubbed parameters to determine a match" do
|
|
36
|
-
HttpStub::Models::HashWithRegexpableValues.stub
|
|
36
|
+
HttpStub::Models::HashWithRegexpableValues.stub(:new).and_return(regexpable_stubbed_paremeters)
|
|
37
37
|
regexpable_stubbed_paremeters.should_receive(:match?).with(request_parameters).and_return(true)
|
|
38
38
|
|
|
39
39
|
stub_parameters.match?(request).should be(true)
|
|
@@ -34,9 +34,9 @@ describe HttpStub::Models::Stub do
|
|
|
34
34
|
let(:the_stub) { HttpStub::Models::Stub.new(stub_options) }
|
|
35
35
|
|
|
36
36
|
before(:each) do
|
|
37
|
-
HttpStub::Models::StubUri.stub
|
|
38
|
-
HttpStub::Models::StubParameters.stub
|
|
39
|
-
HttpStub::Models::StubHeaders.stub
|
|
37
|
+
HttpStub::Models::StubUri.stub(:new).and_return(stub_uri)
|
|
38
|
+
HttpStub::Models::StubParameters.stub(:new).and_return(stub_parameters)
|
|
39
|
+
HttpStub::Models::StubHeaders.stub(:new).and_return(stub_headers)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
describe "#satisfies?" do
|
|
@@ -47,7 +47,7 @@ describe HttpStub::Models::Stub do
|
|
|
47
47
|
|
|
48
48
|
describe "when the request uri matches" do
|
|
49
49
|
|
|
50
|
-
before(:each) { stub_uri.stub
|
|
50
|
+
before(:each) { stub_uri.stub(:match?).with(request).and_return(true) }
|
|
51
51
|
|
|
52
52
|
describe "and the request method matches" do
|
|
53
53
|
|
|
@@ -55,13 +55,13 @@ describe HttpStub::Models::Stub do
|
|
|
55
55
|
|
|
56
56
|
describe "that matches" do
|
|
57
57
|
|
|
58
|
-
before(:each) { stub_headers.stub
|
|
58
|
+
before(:each) { stub_headers.stub(:match?).with(request).and_return(true) }
|
|
59
59
|
|
|
60
60
|
describe "and a parameter match is configured" do
|
|
61
61
|
|
|
62
62
|
describe "that matches" do
|
|
63
63
|
|
|
64
|
-
before(:each) { stub_parameters.stub
|
|
64
|
+
before(:each) { stub_parameters.stub(:match?).with(request).and_return(true) }
|
|
65
65
|
|
|
66
66
|
it "should return true" do
|
|
67
67
|
the_stub.satisfies?(request).should be_true
|
|
@@ -81,7 +81,7 @@ describe HttpStub::Models::Stub do
|
|
|
81
81
|
|
|
82
82
|
describe "when the request uri does not match" do
|
|
83
83
|
|
|
84
|
-
before(:each) { stub_uri.stub
|
|
84
|
+
before(:each) { stub_uri.stub(:match?).with(request).and_return(false) }
|
|
85
85
|
|
|
86
86
|
it "should return false" do
|
|
87
87
|
the_stub.satisfies?(request).should be_false
|
|
@@ -101,7 +101,7 @@ describe HttpStub::Models::Stub do
|
|
|
101
101
|
|
|
102
102
|
describe "when the headers do not match" do
|
|
103
103
|
|
|
104
|
-
before(:each) { stub_headers.stub
|
|
104
|
+
before(:each) { stub_headers.stub(:match?).with(request).and_return(false) }
|
|
105
105
|
|
|
106
106
|
it "should return false" do
|
|
107
107
|
the_stub.satisfies?(request).should be_false
|
|
@@ -111,7 +111,7 @@ describe HttpStub::Models::Stub do
|
|
|
111
111
|
|
|
112
112
|
describe "when the parameters do not match" do
|
|
113
113
|
|
|
114
|
-
before(:each) { stub_parameters.stub
|
|
114
|
+
before(:each) { stub_parameters.stub(:match?).with(request).and_return(false) }
|
|
115
115
|
|
|
116
116
|
it "should return false" do
|
|
117
117
|
the_stub.satisfies?(request).should be_false
|
|
@@ -5,7 +5,7 @@ describe HttpStub::Models::StubUri do
|
|
|
5
5
|
let(:regexpable_value) { double(HttpStub::Models::RegexpableValue).as_null_object }
|
|
6
6
|
let(:stub_uri) { HttpStub::Models::StubUri.new(stubbed_uri) }
|
|
7
7
|
|
|
8
|
-
before(:each) { HttpStub::Models::RegexpableValue.stub
|
|
8
|
+
before(:each) { HttpStub::Models::RegexpableValue.stub(:new).and_return(regexpable_value) }
|
|
9
9
|
|
|
10
10
|
describe "constructor" do
|
|
11
11
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
describe HttpStub::Rake::ServerTasks do
|
|
2
|
+
include_context "server integration"
|
|
3
|
+
|
|
4
|
+
describe "the start task" do
|
|
5
|
+
|
|
6
|
+
context "when invoked" do
|
|
7
|
+
|
|
8
|
+
it "should start a stub server that responds to stub requests" do
|
|
9
|
+
request = Net::HTTP::Post.new("/stubs")
|
|
10
|
+
request.body = { "response" => { "status" => 302, "body" => "Some Body" } }.to_json
|
|
11
|
+
|
|
12
|
+
response = Net::HTTP.new("localhost", 8001).start { |http| http.request(request) }
|
|
13
|
+
|
|
14
|
+
response.code.should eql("200")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
describe HttpStub::Rake::ServerTasks do
|
|
2
|
+
|
|
3
|
+
describe "the configure task" do
|
|
4
|
+
|
|
5
|
+
context "when a configurer is provided" do
|
|
6
|
+
|
|
7
|
+
let(:configurer) { double(HttpStub::Configurer) }
|
|
8
|
+
|
|
9
|
+
before(:each) do
|
|
10
|
+
HttpStub::Rake::ServerTasks.new(name: :tasks_configurer_provided_test, port: 8001, configurer: configurer)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
context "and the task is executed" do
|
|
14
|
+
|
|
15
|
+
it "should initialize the provided configurer" do
|
|
16
|
+
configurer.should_receive(:initialize!)
|
|
17
|
+
|
|
18
|
+
Rake::Task[:configure_tasks_configurer_provided_test].execute
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context "when a configurer is not provided" do
|
|
26
|
+
|
|
27
|
+
before(:each) { HttpStub::Rake::ServerTasks.new(name: :tasks_configurer_not_provided_test, port: 8001) }
|
|
28
|
+
|
|
29
|
+
it "should not generate a task" do
|
|
30
|
+
lambda { Rake::Task[:configure_tasks_configurer_not_provided_test] }.should
|
|
31
|
+
raise_error(/Don't know how to build task/)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
@@ -6,7 +6,7 @@ describe HttpStub::Server, "when the server is running" do
|
|
|
6
6
|
|
|
7
7
|
describe "and a configurer with multiple stub activators is initialized" do
|
|
8
8
|
|
|
9
|
-
before(:all) {
|
|
9
|
+
before(:all) { HttpStub::Examples::ConfigurerWithManyActivators.initialize! }
|
|
10
10
|
|
|
11
11
|
describe "GET #stubs/activators" do
|
|
12
12
|
|
|
@@ -10,16 +10,16 @@ describe HttpStub::Server do
|
|
|
10
10
|
let(:stub_controller) { double(HttpStub::Controllers::StubController).as_null_object }
|
|
11
11
|
let(:stub_activator_controller) { double(HttpStub::Controllers::StubActivatorController).as_null_object }
|
|
12
12
|
|
|
13
|
-
let(:app) { HttpStub::Server.new }
|
|
13
|
+
let(:app) { HttpStub::Server.new! }
|
|
14
14
|
|
|
15
15
|
before(:each) do
|
|
16
|
-
HttpStub::Models::Registry.stub
|
|
17
|
-
HttpStub::Models::Registry.stub
|
|
18
|
-
HttpStub::Controllers::StubController.stub
|
|
19
|
-
HttpStub::Controllers::StubActivatorController.stub
|
|
16
|
+
HttpStub::Models::Registry.stub(:new).with("stub").and_return(stub_registry)
|
|
17
|
+
HttpStub::Models::Registry.stub(:new).with("stub_activator").and_return(stub_activator_registry)
|
|
18
|
+
HttpStub::Controllers::StubController.stub(:new).and_return(stub_controller)
|
|
19
|
+
HttpStub::Controllers::StubActivatorController.stub(:new).and_return(stub_activator_controller)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
context "when a stub insertion is received" do
|
|
23
23
|
|
|
24
24
|
it "should register the insertion via the stub controller" do
|
|
25
25
|
stub_controller.should_receive(:register).and_return(HttpStub::Models::Response::SUCCESS)
|
|
@@ -28,7 +28,7 @@ describe HttpStub::Server do
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "should respond with the response provided by the controller" do
|
|
31
|
-
stub_controller.stub
|
|
31
|
+
stub_controller.stub(:register).and_return(HttpStub::Models::Response.new("status" => 202, "body" => ""))
|
|
32
32
|
|
|
33
33
|
issue_stub_request
|
|
34
34
|
|
|
@@ -48,7 +48,7 @@ describe HttpStub::Server do
|
|
|
48
48
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
context "when a stub activator insertion request is received" do
|
|
52
52
|
|
|
53
53
|
it "should register the insertion via the stub activator controller" do
|
|
54
54
|
stub_activator_controller.should_receive(:register).and_return(HttpStub::Models::Response::SUCCESS)
|
|
@@ -57,7 +57,7 @@ describe HttpStub::Server do
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
it "should respond with the response provided by the controller" do
|
|
60
|
-
stub_activator_controller.stub
|
|
60
|
+
stub_activator_controller.stub(:register).and_return(HttpStub::Models::Response.new("status" => 302, "body" => ""))
|
|
61
61
|
|
|
62
62
|
issue_stub_activator_request
|
|
63
63
|
|
|
@@ -78,7 +78,7 @@ describe HttpStub::Server do
|
|
|
78
78
|
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
context "when a request to clear the stubs has been received" do
|
|
82
82
|
|
|
83
83
|
it "should delegate clearing to the stub controller" do
|
|
84
84
|
stub_controller.should_receive(:clear)
|
|
@@ -94,7 +94,7 @@ describe HttpStub::Server do
|
|
|
94
94
|
|
|
95
95
|
end
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
context "when a request to clear the stub activators has been received" do
|
|
98
98
|
|
|
99
99
|
it "should delegate clearing to the stub activator controller" do
|
|
100
100
|
stub_activator_controller.should_receive(:clear)
|
|
@@ -110,12 +110,12 @@ describe HttpStub::Server do
|
|
|
110
110
|
|
|
111
111
|
end
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
context "when another type of request is received" do
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
context "and the stub controller replays a response" do
|
|
116
116
|
|
|
117
117
|
before(:each) do
|
|
118
|
-
stub_controller.stub
|
|
118
|
+
stub_controller.stub(:replay).and_return(HttpStub::Models::Response.new("status" => 222, "body" => "Some body"))
|
|
119
119
|
end
|
|
120
120
|
|
|
121
121
|
it "should respond with the replay status code" do
|
|
@@ -132,16 +132,16 @@ describe HttpStub::Server do
|
|
|
132
132
|
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
context "and the stub controller does not replay a response" do
|
|
136
136
|
|
|
137
137
|
before(:each) do
|
|
138
|
-
stub_controller.stub
|
|
138
|
+
stub_controller.stub(:replay).and_return(HttpStub::Models::Response::EMPTY)
|
|
139
139
|
end
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
context "but the stub activator controller activates a stub" do
|
|
142
142
|
|
|
143
143
|
before(:each) do
|
|
144
|
-
stub_activator_controller.stub
|
|
144
|
+
stub_activator_controller.stub(:activate).and_return(HttpStub::Models::Response.new("status" => 300, "body" => "A body"))
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
it "should respond with the activation response status code" do
|
|
@@ -158,10 +158,10 @@ describe HttpStub::Server do
|
|
|
158
158
|
|
|
159
159
|
end
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
context "and the stub activator controller does not activate a stub" do
|
|
162
162
|
|
|
163
163
|
before(:each) do
|
|
164
|
-
stub_activator_controller.stub
|
|
164
|
+
stub_activator_controller.stub(:activate).and_return(HttpStub::Models::Response::EMPTY)
|
|
165
165
|
end
|
|
166
166
|
|
|
167
167
|
it "should respond with a 404 status code" do
|
|
@@ -176,4 +176,14 @@ describe HttpStub::Server do
|
|
|
176
176
|
|
|
177
177
|
end
|
|
178
178
|
|
|
179
|
+
context "when a request to replay a stub is received" do
|
|
180
|
+
|
|
181
|
+
it "should handle processing of the response via the request pipeline" do
|
|
182
|
+
HttpStub::Models::RequestPipeline.should_receive(:before_halt).with(duck_type(:status, :body))
|
|
183
|
+
|
|
184
|
+
get "/some/stubbed/uri"
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
end
|
|
188
|
+
|
|
179
189
|
end
|
data/spec/spec_helper.rb
CHANGED
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.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2013-
|
|
13
|
+
date: 2013-09-16 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: sinatra
|
|
@@ -19,7 +19,7 @@ dependencies:
|
|
|
19
19
|
requirements:
|
|
20
20
|
- - ~>
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: 1.
|
|
22
|
+
version: '1.4'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -27,7 +27,7 @@ dependencies:
|
|
|
27
27
|
requirements:
|
|
28
28
|
- - ~>
|
|
29
29
|
- !ruby/object:Gem::Version
|
|
30
|
-
version: 1.
|
|
30
|
+
version: '1.4'
|
|
31
31
|
- !ruby/object:Gem::Dependency
|
|
32
32
|
name: sinatra-partial
|
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -35,7 +35,7 @@ dependencies:
|
|
|
35
35
|
requirements:
|
|
36
36
|
- - ~>
|
|
37
37
|
- !ruby/object:Gem::Version
|
|
38
|
-
version: 0.4
|
|
38
|
+
version: '0.4'
|
|
39
39
|
type: :runtime
|
|
40
40
|
prerelease: false
|
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -43,7 +43,7 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - ~>
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 0.4
|
|
46
|
+
version: '0.4'
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: haml
|
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -51,7 +51,7 @@ dependencies:
|
|
|
51
51
|
requirements:
|
|
52
52
|
- - ~>
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 4.0
|
|
54
|
+
version: '4.0'
|
|
55
55
|
type: :runtime
|
|
56
56
|
prerelease: false
|
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -59,7 +59,7 @@ dependencies:
|
|
|
59
59
|
requirements:
|
|
60
60
|
- - ~>
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: 4.0
|
|
62
|
+
version: '4.0'
|
|
63
63
|
- !ruby/object:Gem::Dependency
|
|
64
64
|
name: sass
|
|
65
65
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -67,7 +67,7 @@ dependencies:
|
|
|
67
67
|
requirements:
|
|
68
68
|
- - ~>
|
|
69
69
|
- !ruby/object:Gem::Version
|
|
70
|
-
version: 3.2
|
|
70
|
+
version: '3.2'
|
|
71
71
|
type: :runtime
|
|
72
72
|
prerelease: false
|
|
73
73
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -75,7 +75,7 @@ dependencies:
|
|
|
75
75
|
requirements:
|
|
76
76
|
- - ~>
|
|
77
77
|
- !ruby/object:Gem::Version
|
|
78
|
-
version: 3.2
|
|
78
|
+
version: '3.2'
|
|
79
79
|
- !ruby/object:Gem::Dependency
|
|
80
80
|
name: rspec
|
|
81
81
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -83,7 +83,7 @@ dependencies:
|
|
|
83
83
|
requirements:
|
|
84
84
|
- - ~>
|
|
85
85
|
- !ruby/object:Gem::Version
|
|
86
|
-
version: '2.
|
|
86
|
+
version: '2.14'
|
|
87
87
|
type: :development
|
|
88
88
|
prerelease: false
|
|
89
89
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -91,7 +91,7 @@ dependencies:
|
|
|
91
91
|
requirements:
|
|
92
92
|
- - ~>
|
|
93
93
|
- !ruby/object:Gem::Version
|
|
94
|
-
version: '2.
|
|
94
|
+
version: '2.14'
|
|
95
95
|
- !ruby/object:Gem::Dependency
|
|
96
96
|
name: simplecov
|
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -99,7 +99,7 @@ dependencies:
|
|
|
99
99
|
requirements:
|
|
100
100
|
- - ~>
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: 0.7
|
|
102
|
+
version: '0.7'
|
|
103
103
|
type: :development
|
|
104
104
|
prerelease: false
|
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -107,7 +107,7 @@ dependencies:
|
|
|
107
107
|
requirements:
|
|
108
108
|
- - ~>
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: 0.7
|
|
110
|
+
version: '0.7'
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
112
|
name: flog
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -115,7 +115,7 @@ dependencies:
|
|
|
115
115
|
requirements:
|
|
116
116
|
- - ~>
|
|
117
117
|
- !ruby/object:Gem::Version
|
|
118
|
-
version:
|
|
118
|
+
version: '4.1'
|
|
119
119
|
type: :development
|
|
120
120
|
prerelease: false
|
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -123,7 +123,7 @@ dependencies:
|
|
|
123
123
|
requirements:
|
|
124
124
|
- - ~>
|
|
125
125
|
- !ruby/object:Gem::Version
|
|
126
|
-
version:
|
|
126
|
+
version: '4.1'
|
|
127
127
|
- !ruby/object:Gem::Dependency
|
|
128
128
|
name: travis-lint
|
|
129
129
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -131,7 +131,7 @@ dependencies:
|
|
|
131
131
|
requirements:
|
|
132
132
|
- - ~>
|
|
133
133
|
- !ruby/object:Gem::Version
|
|
134
|
-
version: 1.
|
|
134
|
+
version: '1.7'
|
|
135
135
|
type: :development
|
|
136
136
|
prerelease: false
|
|
137
137
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -139,7 +139,7 @@ dependencies:
|
|
|
139
139
|
requirements:
|
|
140
140
|
- - ~>
|
|
141
141
|
- !ruby/object:Gem::Version
|
|
142
|
-
version: 1.
|
|
142
|
+
version: '1.7'
|
|
143
143
|
- !ruby/object:Gem::Dependency
|
|
144
144
|
name: rake
|
|
145
145
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -147,7 +147,7 @@ dependencies:
|
|
|
147
147
|
requirements:
|
|
148
148
|
- - ~>
|
|
149
149
|
- !ruby/object:Gem::Version
|
|
150
|
-
version: 10.
|
|
150
|
+
version: '10.1'
|
|
151
151
|
type: :development
|
|
152
152
|
prerelease: false
|
|
153
153
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -155,7 +155,7 @@ dependencies:
|
|
|
155
155
|
requirements:
|
|
156
156
|
- - ~>
|
|
157
157
|
- !ruby/object:Gem::Version
|
|
158
|
-
version: 10.
|
|
158
|
+
version: '10.1'
|
|
159
159
|
- !ruby/object:Gem::Dependency
|
|
160
160
|
name: rack-test
|
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -163,7 +163,7 @@ dependencies:
|
|
|
163
163
|
requirements:
|
|
164
164
|
- - ~>
|
|
165
165
|
- !ruby/object:Gem::Version
|
|
166
|
-
version: 0.6
|
|
166
|
+
version: '0.6'
|
|
167
167
|
type: :development
|
|
168
168
|
prerelease: false
|
|
169
169
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -171,7 +171,7 @@ dependencies:
|
|
|
171
171
|
requirements:
|
|
172
172
|
- - ~>
|
|
173
173
|
- !ruby/object:Gem::Version
|
|
174
|
-
version: 0.6
|
|
174
|
+
version: '0.6'
|
|
175
175
|
- !ruby/object:Gem::Dependency
|
|
176
176
|
name: nokogiri
|
|
177
177
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -179,7 +179,7 @@ dependencies:
|
|
|
179
179
|
requirements:
|
|
180
180
|
- - ~>
|
|
181
181
|
- !ruby/object:Gem::Version
|
|
182
|
-
version: 1.
|
|
182
|
+
version: '1.6'
|
|
183
183
|
type: :development
|
|
184
184
|
prerelease: false
|
|
185
185
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -187,7 +187,23 @@ dependencies:
|
|
|
187
187
|
requirements:
|
|
188
188
|
- - ~>
|
|
189
189
|
- !ruby/object:Gem::Version
|
|
190
|
-
version: 1.
|
|
190
|
+
version: '1.6'
|
|
191
|
+
- !ruby/object:Gem::Dependency
|
|
192
|
+
name: httparty
|
|
193
|
+
requirement: !ruby/object:Gem::Requirement
|
|
194
|
+
none: false
|
|
195
|
+
requirements:
|
|
196
|
+
- - ~>
|
|
197
|
+
- !ruby/object:Gem::Version
|
|
198
|
+
version: '0.11'
|
|
199
|
+
type: :development
|
|
200
|
+
prerelease: false
|
|
201
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
202
|
+
none: false
|
|
203
|
+
requirements:
|
|
204
|
+
- - ~>
|
|
205
|
+
- !ruby/object:Gem::Version
|
|
206
|
+
version: '0.11'
|
|
191
207
|
- !ruby/object:Gem::Dependency
|
|
192
208
|
name: wait_until
|
|
193
209
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -211,7 +227,7 @@ dependencies:
|
|
|
211
227
|
requirements:
|
|
212
228
|
- - ~>
|
|
213
229
|
- !ruby/object:Gem::Version
|
|
214
|
-
version: 1.8
|
|
230
|
+
version: '1.8'
|
|
215
231
|
type: :development
|
|
216
232
|
prerelease: false
|
|
217
233
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -219,7 +235,7 @@ dependencies:
|
|
|
219
235
|
requirements:
|
|
220
236
|
- - ~>
|
|
221
237
|
- !ruby/object:Gem::Version
|
|
222
|
-
version: 1.8
|
|
238
|
+
version: '1.8'
|
|
223
239
|
description: fakeweb for a HTTP server, informing it to stub / fake responses.
|
|
224
240
|
email: matthew.ueckerman@myob.com
|
|
225
241
|
executables: []
|
|
@@ -240,13 +256,14 @@ files:
|
|
|
240
256
|
- ./lib/http_stub/models/regexpable_value.rb
|
|
241
257
|
- ./lib/http_stub/models/registry.rb
|
|
242
258
|
- ./lib/http_stub/models/request_header_parser.rb
|
|
259
|
+
- ./lib/http_stub/models/request_pipeline.rb
|
|
243
260
|
- ./lib/http_stub/models/response.rb
|
|
244
261
|
- ./lib/http_stub/models/stub.rb
|
|
245
262
|
- ./lib/http_stub/models/stub_activator.rb
|
|
246
263
|
- ./lib/http_stub/models/stub_headers.rb
|
|
247
264
|
- ./lib/http_stub/models/stub_parameters.rb
|
|
248
265
|
- ./lib/http_stub/models/stub_uri.rb
|
|
249
|
-
- ./lib/http_stub/rake/
|
|
266
|
+
- ./lib/http_stub/rake/server_tasks.rb
|
|
250
267
|
- ./lib/http_stub/rake/task_generators.rb
|
|
251
268
|
- ./lib/http_stub/server.rb
|
|
252
269
|
- ./lib/http_stub/version.rb
|
|
@@ -272,13 +289,15 @@ files:
|
|
|
272
289
|
- ./spec/lib/http_stub/models/regexpable_value_spec.rb
|
|
273
290
|
- ./spec/lib/http_stub/models/registry_spec.rb
|
|
274
291
|
- ./spec/lib/http_stub/models/request_header_parser_spec.rb
|
|
292
|
+
- ./spec/lib/http_stub/models/request_pipeline_spec.rb
|
|
275
293
|
- ./spec/lib/http_stub/models/response_spec.rb
|
|
276
294
|
- ./spec/lib/http_stub/models/stub_activator_spec.rb
|
|
277
295
|
- ./spec/lib/http_stub/models/stub_headers_spec.rb
|
|
278
296
|
- ./spec/lib/http_stub/models/stub_parameters_spec.rb
|
|
279
297
|
- ./spec/lib/http_stub/models/stub_spec.rb
|
|
280
298
|
- ./spec/lib/http_stub/models/stub_uri_spec.rb
|
|
281
|
-
- ./spec/lib/http_stub/rake/
|
|
299
|
+
- ./spec/lib/http_stub/rake/server_tasks_integration_spec.rb
|
|
300
|
+
- ./spec/lib/http_stub/rake/server_tasks_spec.rb
|
|
282
301
|
- ./spec/lib/http_stub/server_integration_spec.rb
|
|
283
302
|
- ./spec/lib/http_stub/server_spec.rb
|
|
284
303
|
- ./spec/spec_helper.rb
|
|
@@ -304,10 +323,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
304
323
|
version: '0'
|
|
305
324
|
segments:
|
|
306
325
|
- 0
|
|
307
|
-
hash: -
|
|
326
|
+
hash: -2870927875364426759
|
|
308
327
|
requirements: []
|
|
309
328
|
rubyforge_project: http_stub
|
|
310
|
-
rubygems_version: 1.8.
|
|
329
|
+
rubygems_version: 1.8.25
|
|
311
330
|
signing_key:
|
|
312
331
|
specification_version: 3
|
|
313
332
|
summary: A HTTP Server replaying configured stub responses.
|
|
@@ -328,13 +347,15 @@ test_files:
|
|
|
328
347
|
- ./spec/lib/http_stub/models/regexpable_value_spec.rb
|
|
329
348
|
- ./spec/lib/http_stub/models/registry_spec.rb
|
|
330
349
|
- ./spec/lib/http_stub/models/request_header_parser_spec.rb
|
|
350
|
+
- ./spec/lib/http_stub/models/request_pipeline_spec.rb
|
|
331
351
|
- ./spec/lib/http_stub/models/response_spec.rb
|
|
332
352
|
- ./spec/lib/http_stub/models/stub_activator_spec.rb
|
|
333
353
|
- ./spec/lib/http_stub/models/stub_headers_spec.rb
|
|
334
354
|
- ./spec/lib/http_stub/models/stub_parameters_spec.rb
|
|
335
355
|
- ./spec/lib/http_stub/models/stub_spec.rb
|
|
336
356
|
- ./spec/lib/http_stub/models/stub_uri_spec.rb
|
|
337
|
-
- ./spec/lib/http_stub/rake/
|
|
357
|
+
- ./spec/lib/http_stub/rake/server_tasks_integration_spec.rb
|
|
358
|
+
- ./spec/lib/http_stub/rake/server_tasks_spec.rb
|
|
338
359
|
- ./spec/lib/http_stub/server_integration_spec.rb
|
|
339
360
|
- ./spec/lib/http_stub/server_spec.rb
|
|
340
361
|
- ./spec/spec_helper.rb
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module HttpStub
|
|
2
|
-
|
|
3
|
-
module Rake
|
|
4
|
-
|
|
5
|
-
class StartServerTask < ::Rake::TaskLib
|
|
6
|
-
|
|
7
|
-
def initialize(options)
|
|
8
|
-
desc "Starts stub #{options[:name]}"
|
|
9
|
-
task "start_#{options[:name]}" do
|
|
10
|
-
HttpStub::Server.instance_eval do
|
|
11
|
-
set :port, options[:port]
|
|
12
|
-
run!
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
describe HttpStub::Rake::StartServerTask do
|
|
2
|
-
include_context "server integration"
|
|
3
|
-
|
|
4
|
-
describe("when the generated task is invoked") do
|
|
5
|
-
|
|
6
|
-
it "should start a stub server that responds to stub requests" do
|
|
7
|
-
request = Net::HTTP::Post.new("/stubs")
|
|
8
|
-
request.body = { "response" => { "status" => 302, "body" => "Some Body" } }.to_json
|
|
9
|
-
|
|
10
|
-
response = Net::HTTP.new("localhost", 8001).start { |http| http.request(request) }
|
|
11
|
-
|
|
12
|
-
response.code.should eql("200")
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|