summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Doherty <cdoherty@chef.io>2015-11-04 13:27:04 -0800
committerChris Doherty <cdoherty@chef.io>2015-11-04 13:27:04 -0800
commit444af61f22e0c3bcf21e5237b9fa071b08000729 (patch)
tree43bb50f3c55f9926925ab6abf47226ae0c8ca60f
parentc147b7ff762824c6f00965927af95fc258753fba (diff)
downloadchef-zero-444af61f22e0c3bcf21e5237b9fa071b08000729.tar.gz
Enable RestBast#error to produce non-pretty JSON, as required by some pedant specs.
-rw-r--r--lib/chef_zero/rest_base.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/chef_zero/rest_base.rb b/lib/chef_zero/rest_base.rb
index bab71e4..a503df6 100644
--- a/lib/chef_zero/rest_base.rb
+++ b/lib/chef_zero/rest_base.rb
@@ -195,12 +195,13 @@ module ChefZero
data_store.exists_dir?(rest_path)
end
- def error(response_code, error)
- json_response(response_code, {"error" => [error]})
+ def error(response_code, error, opts={})
+ json_response(response_code, {"error" => [error]}, 0, 0, opts)
end
- def json_response(response_code, json, request_version=0, response_version=0)
- already_json_response(response_code, FFI_Yajl::Encoder.encode(json, :pretty => true), request_version, response_version)
+ def json_response(response_code, json, request_version=0, response_version=0, opts={pretty: true})
+ do_pretty_json = opts[:pretty] && true
+ already_json_response(response_code, FFI_Yajl::Encoder.encode(json, :pretty => do_pretty_json), request_version, response_version)
end
def text_response(response_code, text)