committee 1.12.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa85c91924d305a304a54ad64c055d237fa1d497
4
- data.tar.gz: eeaf629c7d4a3ba4c4f5928722771c2d41bbf3c3
3
+ metadata.gz: 703008e03b49547332164301f81686c96c0f7252
4
+ data.tar.gz: f7a38ed4f362f015e0eebb08a49f5142cdf4db93
5
5
  SHA512:
6
- metadata.gz: 69cf9b11c8e820f30e7fbf6c17d409aee52650cda21e39237dea0d97e1efeaafbf82083f3bdc321e69edb9af307db509d33fb512d782ab028277fff4cae4515d
7
- data.tar.gz: 716618189cb9a7accbc45b485a63837600311c99c793ba435ef2bf0a720ec8f0abe5d5267173ee1d7e71c827206245636a97df205fdafa93cf348c2405d97998
6
+ metadata.gz: b59cbc674414a102d14e82fd7b4fe4f836eaeb2f9a3af74f6483632a2fd85bcb6365ead75705dd23b1adcbe2e0b30f2a4f1f020341eb834cc83e8bfc18fbfd2b
7
+ data.tar.gz: 4a289d9deb88483313f635bdc72bed536c2b04c9640123001ceee4bc51a649fb2e3bf830135362dd776fdb8e0bddfb5a3a69ed0ab4aa38a562b76e417016f32f
@@ -24,6 +24,10 @@ module Committee::Middleware
24
24
  # otherwise keep the headers and whatever data manipulations were
25
25
  # made, and stub normally
26
26
  headers.merge!(call_headers)
27
+
28
+ # allow allow the handler to change the data object (if unchanged, it
29
+ # will be the same one that we set above)
30
+ data = request.env["committee.response"]
27
31
  end
28
32
  status = link.rel == "create" ? 201 : 200
29
33
  [status, headers, [JSON.pretty_generate(data)]]
@@ -55,9 +55,18 @@ describe Committee::Middleware::Stub do
55
55
  assert_equal ValidApp.keys.sort, data.keys.sort
56
56
  end
57
57
 
58
+ it "allows the stub's response to be replaced" do
59
+ response = { replaced: true }
60
+ @app = new_rack_app(call: true, response: response)
61
+ get "/apps/heroku-api"
62
+ assert_equal 200, last_response.status
63
+ assert_equal response, JSON.parse(last_response.body, symbolize_names: true)
64
+ end
65
+
58
66
  private
59
67
 
60
68
  def new_rack_app(options = {})
69
+ response = options.delete(:response)
61
70
  suppress = options.delete(:suppress)
62
71
  options = {
63
72
  schema: JSON.parse(File.read("./test/data/schema.json"))
@@ -65,6 +74,7 @@ describe Committee::Middleware::Stub do
65
74
  Rack::Builder.new {
66
75
  use Committee::Middleware::Stub, options
67
76
  run lambda { |env|
77
+ env["committee.response"] = response if response
68
78
  headers = { "Committee-Response" => JSON.generate(env["committee.response"]) }
69
79
  env["committee.suppress"] = suppress
70
80
  [429, headers, []]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: committee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandur
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-30 00:00:00.000000000 Z
12
+ date: 2015-12-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json_schema
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  version: '0'
157
157
  requirements: []
158
158
  rubyforge_project:
159
- rubygems_version: 2.4.5.1
159
+ rubygems_version: 2.2.2
160
160
  signing_key:
161
161
  specification_version: 4
162
162
  summary: A collection of Rack middleware to support JSON Schema.