Skip to content

Commit

Permalink
Create api_helper_spec.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Sep 20, 2024
1 parent 54bad14 commit 4dbf1bb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions global_business/business/spec/helpers/api_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4dbf1bb

Please sign in to comment.