http_stub 0.9.6 → 0.9.7

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.
Files changed (34) hide show
  1. data/lib/http_stub/configurer/request/controllable_value.rb +21 -0
  2. data/lib/http_stub/configurer/request/omittable.rb +18 -0
  3. data/lib/http_stub/configurer/request/regexpable.rb +2 -7
  4. data/lib/http_stub/configurer/request/stub.rb +3 -3
  5. data/lib/http_stub/models/exact_value_matcher.rb +13 -0
  6. data/lib/http_stub/models/hash_with_value_matchers.rb +20 -0
  7. data/lib/http_stub/models/omitted_value_matcher.rb +19 -0
  8. data/lib/http_stub/models/regexp_value_matcher.rb +14 -0
  9. data/lib/http_stub/models/stub_headers.rb +1 -1
  10. data/lib/http_stub/models/stub_parameters.rb +1 -1
  11. data/lib/http_stub/models/stub_uri.rb +1 -1
  12. data/lib/http_stub/models/value_matcher.rb +29 -0
  13. data/lib/http_stub/version.rb +1 -1
  14. data/lib/http_stub.rb +7 -2
  15. data/spec/lib/http_stub/configurer/request/controllable_value_spec.rb +34 -0
  16. data/spec/lib/http_stub/configurer/request/omittable_spec.rb +70 -0
  17. data/spec/lib/http_stub/configurer/request/stub_spec.rb +11 -11
  18. data/spec/lib/http_stub/configurer_integration_spec.rb +51 -9
  19. data/spec/lib/http_stub/models/exact_value_matcher_spec.rb +33 -0
  20. data/spec/lib/http_stub/models/hash_with_value_matchers_spec.rb +156 -0
  21. data/spec/lib/http_stub/models/omitted_value_matcher_spec.rb +58 -0
  22. data/spec/lib/http_stub/models/regexp_value_matcher_spec.rb +48 -0
  23. data/spec/lib/http_stub/models/stub_headers_spec.rb +4 -4
  24. data/spec/lib/http_stub/models/stub_parameters_spec.rb +4 -4
  25. data/spec/lib/http_stub/models/stub_uri_spec.rb +9 -9
  26. data/spec/lib/http_stub/models/value_matcher_spec.rb +81 -0
  27. data/spec/lib/http_stub/server_integration_spec.rb +33 -7
  28. data/spec/lib/http_stub/server_spec.rb +13 -16
  29. data/spec/spec_helper.rb +1 -1
  30. metadata +36 -21
  31. data/lib/http_stub/models/hash_with_regexpable_values.rb +0 -20
  32. data/lib/http_stub/models/regexpable_value.rb +0 -22
  33. data/spec/lib/http_stub/models/hash_with_regexpable_values_spec.rb +0 -149
  34. data/spec/lib/http_stub/models/regexpable_value_spec.rb +0 -69
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.9.6
4
+ version: 0.9.7
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-10-28 00:00:00.000000000 Z
13
+ date: 2013-11-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sinatra
@@ -93,13 +93,13 @@ dependencies:
93
93
  - !ruby/object:Gem::Version
94
94
  version: '10.1'
95
95
  - !ruby/object:Gem::Dependency
96
- name: metric_fu
96
+ name: travis-lint
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  none: false
99
99
  requirements:
100
100
  - - ~>
101
101
  - !ruby/object:Gem::Version
102
- version: '4.4'
102
+ version: '1.7'
103
103
  type: :development
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
@@ -107,15 +107,15 @@ dependencies:
107
107
  requirements:
108
108
  - - ~>
109
109
  - !ruby/object:Gem::Version
110
- version: '4.4'
110
+ version: '1.7'
111
111
  - !ruby/object:Gem::Dependency
112
- name: rspec
112
+ name: metric_fu
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  none: false
115
115
  requirements:
116
116
  - - ~>
117
117
  - !ruby/object:Gem::Version
118
- version: '2.14'
118
+ version: '4.4'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
@@ -123,15 +123,15 @@ dependencies:
123
123
  requirements:
124
124
  - - ~>
125
125
  - !ruby/object:Gem::Version
126
- version: '2.14'
126
+ version: '4.4'
127
127
  - !ruby/object:Gem::Dependency
128
- name: simplecov
128
+ name: rspec
129
129
  requirement: !ruby/object:Gem::Requirement
130
130
  none: false
131
131
  requirements:
132
132
  - - ~>
133
133
  - !ruby/object:Gem::Version
134
- version: '0.7'
134
+ version: '2.14'
135
135
  type: :development
136
136
  prerelease: false
137
137
  version_requirements: !ruby/object:Gem::Requirement
@@ -139,15 +139,15 @@ dependencies:
139
139
  requirements:
140
140
  - - ~>
141
141
  - !ruby/object:Gem::Version
142
- version: '0.7'
142
+ version: '2.14'
143
143
  - !ruby/object:Gem::Dependency
144
- name: travis-lint
144
+ name: simplecov
145
145
  requirement: !ruby/object:Gem::Requirement
146
146
  none: false
147
147
  requirements:
148
148
  - - ~>
149
149
  - !ruby/object:Gem::Version
150
- version: '1.7'
150
+ version: '0.7'
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: '1.7'
158
+ version: '0.7'
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: rake
161
161
  requirement: !ruby/object:Gem::Requirement
@@ -262,6 +262,8 @@ files:
262
262
  - ./lib/http_stub/configurer/command_processor.rb
263
263
  - ./lib/http_stub/configurer/impatient_command_chain.rb
264
264
  - ./lib/http_stub/configurer/patient_command_chain.rb
265
+ - ./lib/http_stub/configurer/request/controllable_value.rb
266
+ - ./lib/http_stub/configurer/request/omittable.rb
265
267
  - ./lib/http_stub/configurer/request/regexpable.rb
266
268
  - ./lib/http_stub/configurer/request/stub.rb
267
269
  - ./lib/http_stub/configurer/request/stub_activator.rb
@@ -269,8 +271,10 @@ files:
269
271
  - ./lib/http_stub/controllers/stub_activator_controller.rb
270
272
  - ./lib/http_stub/controllers/stub_controller.rb
271
273
  - ./lib/http_stub/hash_extensions.rb
272
- - ./lib/http_stub/models/hash_with_regexpable_values.rb
273
- - ./lib/http_stub/models/regexpable_value.rb
274
+ - ./lib/http_stub/models/exact_value_matcher.rb
275
+ - ./lib/http_stub/models/hash_with_value_matchers.rb
276
+ - ./lib/http_stub/models/omitted_value_matcher.rb
277
+ - ./lib/http_stub/models/regexp_value_matcher.rb
274
278
  - ./lib/http_stub/models/registry.rb
275
279
  - ./lib/http_stub/models/request_header_parser.rb
276
280
  - ./lib/http_stub/models/request_pipeline.rb
@@ -280,6 +284,7 @@ files:
280
284
  - ./lib/http_stub/models/stub_headers.rb
281
285
  - ./lib/http_stub/models/stub_parameters.rb
282
286
  - ./lib/http_stub/models/stub_uri.rb
287
+ - ./lib/http_stub/models/value_matcher.rb
283
288
  - ./lib/http_stub/rake/server_tasks.rb
284
289
  - ./lib/http_stub/rake/task_generators.rb
285
290
  - ./lib/http_stub/server.rb
@@ -295,6 +300,8 @@ files:
295
300
  - ./spec/lib/http_stub/configurer/command_spec.rb
296
301
  - ./spec/lib/http_stub/configurer/impatient_command_chain_spec.rb
297
302
  - ./spec/lib/http_stub/configurer/patient_command_chain_spec.rb
303
+ - ./spec/lib/http_stub/configurer/request/controllable_value_spec.rb
304
+ - ./spec/lib/http_stub/configurer/request/omittable_spec.rb
298
305
  - ./spec/lib/http_stub/configurer/request/regexpable_spec.rb
299
306
  - ./spec/lib/http_stub/configurer/request/stub_activator_spec.rb
300
307
  - ./spec/lib/http_stub/configurer/request/stub_spec.rb
@@ -303,8 +310,10 @@ files:
303
310
  - ./spec/lib/http_stub/controllers/stub_activator_controller_spec.rb
304
311
  - ./spec/lib/http_stub/controllers/stub_controller_spec.rb
305
312
  - ./spec/lib/http_stub/hash_extensions_spec.rb
306
- - ./spec/lib/http_stub/models/hash_with_regexpable_values_spec.rb
307
- - ./spec/lib/http_stub/models/regexpable_value_spec.rb
313
+ - ./spec/lib/http_stub/models/exact_value_matcher_spec.rb
314
+ - ./spec/lib/http_stub/models/hash_with_value_matchers_spec.rb
315
+ - ./spec/lib/http_stub/models/omitted_value_matcher_spec.rb
316
+ - ./spec/lib/http_stub/models/regexp_value_matcher_spec.rb
308
317
  - ./spec/lib/http_stub/models/registry_spec.rb
309
318
  - ./spec/lib/http_stub/models/request_header_parser_spec.rb
310
319
  - ./spec/lib/http_stub/models/request_pipeline_spec.rb
@@ -314,6 +323,7 @@ files:
314
323
  - ./spec/lib/http_stub/models/stub_parameters_spec.rb
315
324
  - ./spec/lib/http_stub/models/stub_spec.rb
316
325
  - ./spec/lib/http_stub/models/stub_uri_spec.rb
326
+ - ./spec/lib/http_stub/models/value_matcher_spec.rb
317
327
  - ./spec/lib/http_stub/rake/server_tasks_integration_spec.rb
318
328
  - ./spec/lib/http_stub/rake/server_tasks_spec.rb
319
329
  - ./spec/lib/http_stub/server_integration_spec.rb
@@ -341,7 +351,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
341
351
  version: '0'
342
352
  segments:
343
353
  - 0
344
- hash: -2832130990887344791
354
+ hash: -1462084841205828236
345
355
  requirements: []
346
356
  rubyforge_project: http_stub
347
357
  rubygems_version: 1.8.25
@@ -354,6 +364,8 @@ test_files:
354
364
  - ./spec/lib/http_stub/configurer/command_spec.rb
355
365
  - ./spec/lib/http_stub/configurer/impatient_command_chain_spec.rb
356
366
  - ./spec/lib/http_stub/configurer/patient_command_chain_spec.rb
367
+ - ./spec/lib/http_stub/configurer/request/controllable_value_spec.rb
368
+ - ./spec/lib/http_stub/configurer/request/omittable_spec.rb
357
369
  - ./spec/lib/http_stub/configurer/request/regexpable_spec.rb
358
370
  - ./spec/lib/http_stub/configurer/request/stub_activator_spec.rb
359
371
  - ./spec/lib/http_stub/configurer/request/stub_spec.rb
@@ -362,8 +374,10 @@ test_files:
362
374
  - ./spec/lib/http_stub/controllers/stub_activator_controller_spec.rb
363
375
  - ./spec/lib/http_stub/controllers/stub_controller_spec.rb
364
376
  - ./spec/lib/http_stub/hash_extensions_spec.rb
365
- - ./spec/lib/http_stub/models/hash_with_regexpable_values_spec.rb
366
- - ./spec/lib/http_stub/models/regexpable_value_spec.rb
377
+ - ./spec/lib/http_stub/models/exact_value_matcher_spec.rb
378
+ - ./spec/lib/http_stub/models/hash_with_value_matchers_spec.rb
379
+ - ./spec/lib/http_stub/models/omitted_value_matcher_spec.rb
380
+ - ./spec/lib/http_stub/models/regexp_value_matcher_spec.rb
367
381
  - ./spec/lib/http_stub/models/registry_spec.rb
368
382
  - ./spec/lib/http_stub/models/request_header_parser_spec.rb
369
383
  - ./spec/lib/http_stub/models/request_pipeline_spec.rb
@@ -373,6 +387,7 @@ test_files:
373
387
  - ./spec/lib/http_stub/models/stub_parameters_spec.rb
374
388
  - ./spec/lib/http_stub/models/stub_spec.rb
375
389
  - ./spec/lib/http_stub/models/stub_uri_spec.rb
390
+ - ./spec/lib/http_stub/models/value_matcher_spec.rb
376
391
  - ./spec/lib/http_stub/rake/server_tasks_integration_spec.rb
377
392
  - ./spec/lib/http_stub/rake/server_tasks_spec.rb
378
393
  - ./spec/lib/http_stub/server_integration_spec.rb
@@ -1,20 +0,0 @@
1
- module HttpStub
2
- module Models
3
-
4
- class HashWithRegexpableValues < Hash
5
-
6
- def initialize(hash)
7
- hash.each_pair { |key, value| self[key] = HttpStub::Models::RegexpableValue.new(value) }
8
- end
9
-
10
- def match?(other_hash)
11
- !(self.find do |key_and_regexpable_value|
12
- other_value = other_hash[key_and_regexpable_value[0]]
13
- !(other_value && key_and_regexpable_value[1].match?(other_value))
14
- end)
15
- end
16
-
17
- end
18
-
19
- end
20
- end
@@ -1,22 +0,0 @@
1
- module HttpStub
2
- module Models
3
-
4
- class RegexpableValue
5
-
6
- def initialize(value)
7
- @value = value
8
- end
9
-
10
- def match?(other_value)
11
- match_data = @value.match(/^regexp:(.*)/)
12
- match_data ? !!Regexp.new(match_data[1]).match(other_value) : other_value == @value
13
- end
14
-
15
- def to_s
16
- @value
17
- end
18
-
19
- end
20
-
21
- end
22
- end
@@ -1,149 +0,0 @@
1
- describe HttpStub::Models::HashWithRegexpableValues do
2
-
3
- let(:stubbed_hash) do
4
- (1..3).reduce({}) do |result, i|
5
- result["key#{i}"] = "value#{i}"
6
- result
7
- end
8
- end
9
-
10
- let(:regexpable_values) do
11
- stubbed_hash.values.map { |value| double(HttpStub::Models::RegexpableValue, to_s: value).as_null_object }
12
- end
13
-
14
- let(:regexpable_hash) { HttpStub::Models::HashWithRegexpableValues.new(stubbed_hash) }
15
-
16
- before(:each) do
17
- regexpable_values.each { |value| HttpStub::Models::RegexpableValue.stub(:new).with(value.to_s).and_return(value) }
18
- end
19
-
20
- it "should be hash" do
21
- regexpable_hash.should be_a(Hash)
22
- end
23
-
24
- describe "constructor" do
25
-
26
- it "should create a regexpable representation of each value in the hash" do
27
- regexpable_values.each do |value|
28
- HttpStub::Models::RegexpableValue.should_receive(:new).with(value.to_s).and_return(value)
29
- end
30
-
31
- regexpable_hash.values.should eql(regexpable_values)
32
- end
33
-
34
- end
35
-
36
- describe "#match?" do
37
-
38
- describe "when the stubbed hash contains multiple entries" do
39
-
40
- describe "and the provided hash has the same number of entries" do
41
-
42
- describe "and the keys match" do
43
-
44
- let(:provided_hash) do
45
- stubbed_hash.reduce({}) do |result, entry|
46
- result[entry[0]] = "another #{entry[1]}"
47
- result
48
- end
49
- end
50
-
51
- describe "and the values match" do
52
-
53
- before(:each) do
54
- regexpable_values.each { |value| value.stub(:match?).with("another #{value}").and_return(true) }
55
- end
56
-
57
- it "should return true" do
58
- regexpable_hash.match?(provided_hash).should be_true
59
- end
60
-
61
- end
62
-
63
- describe "and a value does not match" do
64
-
65
- before(:each) do
66
- regexpable_values.each { |value| value.stub(:match?).with("another #{value}").and_return(true) }
67
-
68
- non_matching_value = regexpable_values[1]
69
- non_matching_value.stub(:match?).with("another #{non_matching_value}").and_return(false)
70
- end
71
-
72
- it "should return false" do
73
- regexpable_hash.match?(provided_hash).should be_false
74
- end
75
-
76
- end
77
-
78
- end
79
-
80
- describe "and a key does not match" do
81
-
82
- let(:provided_hash) { { "key1" => "value1", "differentkey2" => "another value2", "key3" => "value3" } }
83
-
84
- before(:each) do
85
- regexpable_values.each { |value| value.stub(:match?).with(value.to_s).and_return(true) }
86
- end
87
-
88
- it "should return false" do
89
- regexpable_hash.match?(provided_hash).should be_false
90
- end
91
-
92
- end
93
-
94
- end
95
-
96
- describe "and the provided hash contains more entries" do
97
-
98
- let(:provided_hash) do
99
- (1..5).reduce({}) do |result, i|
100
- result["key#{i}"] = "another value#{i}"
101
- result
102
- end
103
- end
104
-
105
- describe "and it has matching keys and values" do
106
-
107
- before(:each) do
108
- regexpable_values.each { |value| value.stub(:match?).with("another #{value}").and_return(true) }
109
- end
110
-
111
- it "should return true" do
112
- regexpable_hash.match?(provided_hash).should be_true
113
- end
114
-
115
- end
116
-
117
- end
118
-
119
- end
120
-
121
- describe "when the stubbed hash is empty" do
122
-
123
- let(:stubbed_hash) { {} }
124
-
125
- describe "and the provided hash is not empty" do
126
-
127
- let(:provided_hash) { { "key" => "value" } }
128
-
129
- it "should return true" do
130
- regexpable_hash.match?(provided_hash).should be_true
131
- end
132
-
133
- end
134
-
135
- describe "and the provided hash is empty" do
136
-
137
- let(:provided_hash) { {} }
138
-
139
- it "should return true" do
140
- regexpable_hash.match?(provided_hash).should be_true
141
- end
142
-
143
- end
144
-
145
- end
146
-
147
- end
148
-
149
- end
@@ -1,69 +0,0 @@
1
- describe HttpStub::Models::RegexpableValue do
2
-
3
- let(:value) { "a simple string" }
4
-
5
- let(:regexpable_value) { HttpStub::Models::RegexpableValue.new(value) }
6
-
7
- describe "#match?" do
8
-
9
- describe "when the value is a string prefixed with 'regexp:'" do
10
-
11
- let(:value) { "regexp:^a[0-9]*\\$z$" }
12
-
13
- describe "and the provided value matches the regular expression" do
14
-
15
- let(:other_value) { "a789$z" }
16
-
17
- it "should return true" do
18
- regexpable_value.match?(other_value).should be_true
19
- end
20
-
21
- end
22
-
23
- describe "and the provided value does not match the regular expression" do
24
-
25
- let(:other_value) { "a789" }
26
-
27
- it "should return false" do
28
- regexpable_value.match?(other_value).should be_false
29
- end
30
-
31
- end
32
-
33
- end
34
-
35
- describe "when the value is a simple string" do
36
-
37
- describe "and the provided value is equal to the string" do
38
-
39
- let(:other_value) { value }
40
-
41
- it "should return true" do
42
- regexpable_value.match?(other_value).should be_true
43
- end
44
-
45
- end
46
-
47
- describe "and the provided value is not equal to the string" do
48
-
49
- let(:other_value) { "a not equal string" }
50
-
51
- it "should return false" do
52
- regexpable_value.match?(other_value).should be_false
53
- end
54
-
55
- end
56
-
57
- end
58
-
59
- end
60
-
61
- describe "#to_s" do
62
-
63
- it "should return the value provided" do
64
- regexpable_value.to_s.should eql(value)
65
- end
66
-
67
- end
68
-
69
- end