From 4dbf1bb38ecfe67534a48388c44997ffa4410421 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 20 Sep 2024 17:21:22 +0700 Subject: [PATCH] Create api_helper_spec.rb --- .../business/spec/helpers/api_helper_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 global_business/business/spec/helpers/api_helper_spec.rb diff --git a/global_business/business/spec/helpers/api_helper_spec.rb b/global_business/business/spec/helpers/api_helper_spec.rb new file mode 100644 index 000000000..458525eba --- /dev/null +++ b/global_business/business/spec/helpers/api_helper_spec.rb @@ -0,0 +1,17 @@ +require 'rails_helper' + +RSpec.describe ApiHelper do + describe '#json_response' do + it 'renders a JSON response with the given object' do + object = { foo: 'bar' } + expect(json_response(object)).to eq(object.to_json) + end + end + + describe '#error_response' do + it 'renders an error response with the given errors' do + errors = ['error1', 'error2'] + expect(error_response(errors)).to eq({ errors: errors }.to_json) + end + end +end