http_stub 0.17.0.pre1 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTlmNDUyNWZjZjhjODYwMjcyNDViZWE1MDY4NzljZTc3MDJhYmYxMA==
4
+ MjE5ZmY4YmJhNjA3OGI2NWU1MWMxNmIzODk3OTQwMDI3NWZjOTY4Ng==
5
5
  data.tar.gz: !binary |-
6
- ZTdhZmExMjY3NTBkNzZmZGMwYTdjMTJhZWM1ODAzMzcyZWZhZThmOQ==
6
+ NTA4YjMxNzYyNGI4YTM3MzI1M2Y4YTRjYTUzOTIzZjgwMTBkODAxYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWI2MDc1ZThkNjQ4OWE2YWQ4YWM3MjM1YThlYzc5ZTg4OWE1MzFmM2EyZGUx
10
- N2ZiM2Q5Y2ZhN2I3MGQ2ZGUzNTdmM2ViM2M0MGQwNDI5ODZhMTdjODM5MjBl
11
- ZjMyNmMwMTJkMWNmNjk4MTk3NDg5ZGIxNTRlYmFiNDk1MzJjYWI=
9
+ Mjk1NGI5YjE3Y2EwNjIxZmQwYzIyOGM5ZDU0ZDRhNzUzODAwNmMwYTA5NmY5
10
+ YWI3YmQ1YTkxZDA0ODE1MDgzYmM1OGEyYWY5OTIyMDI4MmNmMjQ2MmI3MmQ4
11
+ NGVkNjljOThkMTkyMTYzNjRkOWNiZTljNTQ0ZDIyZGJkZGUwYjM=
12
12
  data.tar.gz: !binary |-
13
- OWI1OGY4MzNiOGU3MjdkNGFmZDgxNjRhMjlkNmIxZjA5N2FmYjc0NDE3MmM5
14
- NThiZDAyNzQzNTRjMTBjODFlMTA3MDJhZGEwMjUwZmUxMTBjOTcxNWMwZDhm
15
- NWVlYzgxMzIwNWYxZmJhZTk5NWUxOWUzZTYzMTQzOTdhNjJiZTQ=
13
+ OGZkOTY0YWRlZDAwZjYwZGE0ODA0ZmE3YTEyNDA0ZWRmYmQzZTIwYzQwNjcw
14
+ OTE0NmNhZmUwNWYxMjliZDBiZTdiYWRkNjc5YjExMDc0YjJmOThjNzQyMGRj
15
+ YzAwZjU2N2NmMzk2ZGZjYThlNjZlOGU1YWQ2ZGYyMDE1NGI3OGQ=
@@ -1,3 +1,3 @@
1
1
  module HttpStub
2
- VERSION = "0.17.0.pre1".freeze
2
+ VERSION = "0.17.0".freeze
3
3
  end
@@ -0,0 +1,161 @@
1
+ describe "Scenario acceptance" do
2
+ include_context "configurer integration"
3
+
4
+ context "when a configurer that contains a stub matching a request body" do
5
+
6
+ let(:configurer) { HttpStub::Examples::ConfigurerWithStubRequestBody.new }
7
+
8
+ before(:example) { configurer.class.initialize! }
9
+
10
+ context "against an exact match" do
11
+
12
+ before(:example) { stub_server.activate!("match_body_exactly_scenario") }
13
+
14
+ context "and a request is made with a request body" do
15
+
16
+ context "that exactly matches" do
17
+
18
+ let(:response) { issue_request(body: "Exactly matches") }
19
+
20
+ it "responds with the configured response" do
21
+ expect(response.code).to eql(204)
22
+ end
23
+
24
+ end
25
+
26
+ context "that does not match" do
27
+
28
+ let(:response) { issue_request(body: "Does not match") }
29
+
30
+ it "responds with a 404 status code" do
31
+ expect(response.code).to eql(404)
32
+ end
33
+
34
+ end
35
+
36
+ context "that is empty" do
37
+
38
+ let(:response) { issue_request(body: {}) }
39
+
40
+ it "responds with a 404 status code" do
41
+ expect(response.code).to eql(404)
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+
48
+ def issue_request(args)
49
+ HTTParty.post("#{server_uri}/match_body_exactly", args)
50
+ end
51
+
52
+ end
53
+
54
+ context "against a regular expression" do
55
+
56
+ before(:example) { stub_server.activate!("match_body_regex_scenario") }
57
+
58
+ context "and a request is made with a request body" do
59
+
60
+ context "that matches the regular expression" do
61
+
62
+ let(:response) { issue_request(body: "matches with additional content") }
63
+
64
+ it "responds with the configured response" do
65
+ expect(response.code).to eql(204)
66
+ end
67
+
68
+ end
69
+
70
+ context "that does not match the regular expression" do
71
+
72
+ let(:response) { issue_request(body: "Does not match") }
73
+
74
+ it "responds with a 404 status code" do
75
+ expect(response.code).to eql(404)
76
+ end
77
+
78
+ end
79
+
80
+ context "that is empty" do
81
+
82
+ let(:response) { issue_request(body: {}) }
83
+
84
+ it "responds with a 404 status code" do
85
+ expect(response.code).to eql(404)
86
+ end
87
+
88
+ end
89
+
90
+ end
91
+
92
+ def issue_request(args)
93
+ HTTParty.post("#{server_uri}/match_body_regex", args)
94
+ end
95
+
96
+ end
97
+
98
+ context "against a JSON schema" do
99
+
100
+ before(:example) { stub_server.activate!("match_body_json_schema_scenario") }
101
+
102
+ context "and a request is made with a request body" do
103
+
104
+ context "that completely matches" do
105
+
106
+ let(:response) do
107
+ issue_request(body: { string_property: "some string",
108
+ integer_property: 88,
109
+ float_property: 77.7 }.to_json)
110
+ end
111
+
112
+ it "responds with the configured response" do
113
+ expect(response.code).to eql(204)
114
+ end
115
+
116
+ end
117
+
118
+ context "that partially matches" do
119
+
120
+ let(:response) do
121
+ issue_request(body: { string_property: "some string",
122
+ integer_property: 88 }.to_json)
123
+ end
124
+
125
+ it "responds with a 404 status code" do
126
+ expect(response.code).to eql(404)
127
+ end
128
+
129
+ end
130
+
131
+ context "that is completely different" do
132
+
133
+ let(:response) { issue_request(body: { some_other_key: "some string" }.to_json) }
134
+
135
+ it "responds with a 404 status code" do
136
+ expect(response.code).to eql(404)
137
+ end
138
+
139
+ end
140
+
141
+ context "that is empty" do
142
+
143
+ let(:response) { issue_request(body: {}) }
144
+
145
+ it "responds with a 404 status code" do
146
+ expect(response.code).to eql(404)
147
+ end
148
+
149
+ end
150
+
151
+ end
152
+
153
+ def issue_request(args)
154
+ HTTParty.post("#{server_uri}/match_body_json_schema", args)
155
+ end
156
+
157
+ end
158
+
159
+ end
160
+
161
+ end
data/spec/spec_helper.rb CHANGED
@@ -7,7 +7,7 @@ SimpleCov.start do
7
7
  add_filter "/spec/"
8
8
  add_filter "/vendor/"
9
9
 
10
- minimum_coverage 99.64
10
+ minimum_coverage 99.65
11
11
  refuse_coverage_drop
12
12
  end if ENV["coverage"]
13
13
 
@@ -24,7 +24,8 @@ require_relative '../examples/configurer_with_complex_initializer'
24
24
  require_relative '../examples/configurer_with_response_defaults'
25
25
  require_relative '../examples/configurer_with_stub_triggers'
26
26
  require_relative '../examples/configurer_with_file_responses'
27
- require_relative '../examples/configurer_with_schema_validating_stub'
27
+ require_relative '../examples/configurer_with_stub_request_body'
28
+ require_relative '../examples/configurer_with_regex_request_body'
28
29
 
29
30
  HttpStub::Server::Daemon.log_dir = ::File.expand_path('../../tmp/log', __FILE__)
30
31
  HttpStub::Server::Daemon.pid_dir = ::File.expand_path('../../tmp/pids', __FILE__)
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.17.0.pre1
4
+ version: 0.17.0
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-06-17 00:00:00.000000000 Z
12
+ date: 2015-06-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -347,7 +347,7 @@ files:
347
347
  - ./spec/acceptance/activator_spec.rb
348
348
  - ./spec/acceptance/configurer_initialization_spec.rb
349
349
  - ./spec/acceptance/scenario_spec.rb
350
- - ./spec/acceptance/stub_body_schema_validation_spec.rb
350
+ - ./spec/acceptance/stub_body_request_matching_spec.rb
351
351
  - ./spec/acceptance/stub_control_values_spec.rb
352
352
  - ./spec/acceptance/stub_spec.rb
353
353
  - ./spec/acceptance/stub_trigger_spec.rb
@@ -440,9 +440,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
440
440
  version: 1.9.3
441
441
  required_rubygems_version: !ruby/object:Gem::Requirement
442
442
  requirements:
443
- - - ! '>'
443
+ - - ! '>='
444
444
  - !ruby/object:Gem::Version
445
- version: 1.3.1
445
+ version: '0'
446
446
  requirements: []
447
447
  rubyforge_project: http_stub
448
448
  rubygems_version: 2.4.8
@@ -453,7 +453,7 @@ test_files:
453
453
  - ./spec/acceptance/activator_spec.rb
454
454
  - ./spec/acceptance/configurer_initialization_spec.rb
455
455
  - ./spec/acceptance/scenario_spec.rb
456
- - ./spec/acceptance/stub_body_schema_validation_spec.rb
456
+ - ./spec/acceptance/stub_body_request_matching_spec.rb
457
457
  - ./spec/acceptance/stub_control_values_spec.rb
458
458
  - ./spec/acceptance/stub_spec.rb
459
459
  - ./spec/acceptance/stub_trigger_spec.rb
@@ -1,67 +0,0 @@
1
- describe "Scenario acceptance" do
2
- include_context "configurer integration"
3
-
4
- context "when a configurer that contains a stub matching a request body schema" do
5
-
6
- let(:configurer) { HttpStub::Examples::ConfigurerWithSchemaValidatingStub.new }
7
-
8
- before(:example) { configurer.class.initialize! }
9
-
10
- context "and a request is made with a request body" do
11
-
12
- context "that completely matches" do
13
-
14
- let(:response) do
15
- issue_request(body: { string_property: "some string",
16
- integer_property: 88,
17
- float_property: 77.7 }.to_json)
18
- end
19
-
20
- it "responds with the configured response" do
21
- expect(response.code).to eql(204)
22
- end
23
-
24
- end
25
-
26
- context "that partially matches" do
27
-
28
- let(:response) do
29
- issue_request(body: { string_property: "some string",
30
- integer_property: 88 }.to_json)
31
- end
32
-
33
- it "responds with a 404 status code" do
34
- expect(response.code).to eql(404)
35
- end
36
-
37
- end
38
-
39
- context "that is completely different" do
40
-
41
- let(:response) { issue_request(body: { some_other_key: "some string" }.to_json) }
42
-
43
- it "responds with a 404 status code" do
44
- expect(response.code).to eql(404)
45
- end
46
-
47
- end
48
-
49
- context "that is empty" do
50
-
51
- let(:response) { issue_request(body: {}) }
52
-
53
- it "responds with a 404 status code" do
54
- expect(response.code).to eql(404)
55
- end
56
-
57
- end
58
-
59
- end
60
-
61
- def issue_request(args)
62
- HTTParty.post("#{server_uri}/matches_on_body_schema", args)
63
- end
64
-
65
- end
66
-
67
- end