New Features
- New stubbing helper (#65)
stub_api_client_all(
ExampleApiClient,
get_user: { response: { id: 1 } }, # Returns an arbitrary response.
post_users: { id: 1 }, # You can ommit `response` keyword.
patch_user: ->(params) { { id: params[:id] } }, # Returns calculated result as response.
delete_user: { raise: MyApiClient::ClientError } # Raises an arbitrary error.
)
response = ExampleApiClient.new.get_user(id: 123)
response.id # => 1
api_client = stub_api_client(
ExampleApiClient,
get_user: { response: { id: 1 } }, # Returns an arbitrary response.
post_users: { id: 1 }, # You can ommit `response` keyword.
patch_user: ->(params) { { id: params[:id] } }, # Returns calculated result as response.
delete_user: { raise: MyApiClient::ClientError } # Raises an arbitrary error.
)
response = api_client.get_user(id: 123)
response.id # => 1