diff options
author | Chris Doherty <cdoherty@chef.io> | 2015-11-04 13:27:04 -0800 |
---|---|---|
committer | Chris Doherty <cdoherty@chef.io> | 2015-11-04 13:27:04 -0800 |
commit | 444af61f22e0c3bcf21e5237b9fa071b08000729 (patch) | |
tree | 43bb50f3c55f9926925ab6abf47226ae0c8ca60f | |
parent | c147b7ff762824c6f00965927af95fc258753fba (diff) | |
download | chef-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.rb | 9 |
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) |