Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.7"
".": "0.1.0-alpha.8"
}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.1.0-alpha.8 (2025-04-08)

Full Changelog: [v0.1.0-alpha.7...v0.1.0-alpha.8](https://github.com/Finch-API/finch-api-ruby/compare/v0.1.0-alpha.7...v0.1.0-alpha.8)

### Chores

* **internal:** version bump ([2107a86](https://github.com/Finch-API/finch-api-ruby/commit/2107a86c968117d7fd7516d95f2951014e7f627c))
* make client tests look prettier ([#129](https://github.com/Finch-API/finch-api-ruby/issues/129)) ([8e81a13](https://github.com/Finch-API/finch-api-ruby/commit/8e81a13b7cb5bc7ecc384a9f9fcebd70f393dc2e))

## 0.1.0-alpha.7 (2025-04-08)

Full Changelog: [v0.1.0-alpha.6...v0.1.0-alpha.7](https://github.com/Finch-API/finch-api-ruby/compare/v0.1.0-alpha.6...v0.1.0-alpha.7)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: .
specs:
finch-api (0.1.0.pre.alpha.6)
finch-api (0.1.0.pre.alpha.7)
connection_pool

GEM
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
<!-- x-release-please-start-version -->

```ruby
gem "finch-api", "~> 0.1.0.pre.alpha.6"
gem "finch-api", "~> 0.1.0.pre.alpha.7"
```

<!-- x-release-please-end -->
Expand Down
2 changes: 1 addition & 1 deletion lib/finch_api/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module FinchAPI
VERSION = "0.1.0.pre.alpha.7"
VERSION = "0.1.0.pre.alpha.8"
end
45 changes: 27 additions & 18 deletions test/finch_api/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ def test_retry_count_header
finch.hris.directory.list
end

retry_count_headers = requester.attempts.map { _1[:headers]["x-stainless-retry-count"] }
retry_count_headers = requester.attempts.map do
_1.fetch(:headers).fetch("x-stainless-retry-count")
end

assert_equal(%w[0 1 2], retry_count_headers)
end

Expand All @@ -159,7 +162,10 @@ def test_omit_retry_count_header
finch.hris.directory.list(request_options: {extra_headers: {"x-stainless-retry-count" => nil}})
end

retry_count_headers = requester.attempts.map { _1[:headers]["x-stainless-retry-count"] }
retry_count_headers = requester.attempts.map do
_1.fetch(:headers).fetch("x-stainless-retry-count", nil)
end

assert_equal([nil, nil, nil], retry_count_headers)
end

Expand All @@ -172,7 +178,10 @@ def test_overwrite_retry_count_header
finch.hris.directory.list(request_options: {extra_headers: {"x-stainless-retry-count" => "42"}})
end

retry_count_headers = requester.attempts.map { _1[:headers]["x-stainless-retry-count"] }
retry_count_headers = requester.attempts.map do
_1.fetch(:headers).fetch("x-stainless-retry-count")
end

assert_equal(%w[42 42 42], retry_count_headers)
end

Expand All @@ -185,12 +194,12 @@ def test_client_redirect_307
finch.hris.directory.list(request_options: {extra_headers: {}})
end

assert_equal("/redirected", requester.attempts.last[:url].path)
assert_equal(requester.attempts.first[:method], requester.attempts.last[:method])
assert_equal(requester.attempts.first[:body], requester.attempts.last[:body])
assert_equal("/redirected", requester.attempts.last.fetch(:url).path)
assert_equal(requester.attempts.first.fetch(:method), requester.attempts.last.fetch(:method))
assert_equal(requester.attempts.first.fetch(:body), requester.attempts.last.fetch(:body))
assert_equal(
requester.attempts.first[:headers]["content-type"],
requester.attempts.last[:headers]["content-type"]
requester.attempts.first.fetch(:headers)["content-type"],
requester.attempts.last.fetch(:headers)["content-type"]
)
end

Expand All @@ -203,10 +212,10 @@ def test_client_redirect_303
finch.hris.directory.list(request_options: {extra_headers: {}})
end

assert_equal("/redirected", requester.attempts.last[:url].path)
assert_equal(:get, requester.attempts.last[:method])
assert_nil(requester.attempts.last[:body])
assert_nil(requester.attempts.last[:headers]["Content-Type"])
assert_equal("/redirected", requester.attempts.last.fetch(:url).path)
assert_equal(:get, requester.attempts.last.fetch(:method))
assert_nil(requester.attempts.last.fetch(:body))
assert_nil(requester.attempts.last.fetch(:headers)["content-type"])
end

def test_client_redirect_auth_keep_same_origin
Expand All @@ -215,12 +224,12 @@ def test_client_redirect_auth_keep_same_origin
finch.requester = requester

assert_raises(FinchAPI::Errors::APIConnectionError) do
finch.hris.directory.list(request_options: {extra_headers: {"Authorization" => "Bearer xyz"}})
finch.hris.directory.list(request_options: {extra_headers: {"authorization" => "Bearer xyz"}})
end

assert_equal(
requester.attempts.first[:headers]["authorization"],
requester.attempts.last[:headers]["authorization"]
requester.attempts.first.fetch(:headers)["authorization"],
requester.attempts.last.fetch(:headers)["authorization"]
)
end

Expand All @@ -230,18 +239,18 @@ def test_client_redirect_auth_strip_cross_origin
finch.requester = requester

assert_raises(FinchAPI::Errors::APIConnectionError) do
finch.hris.directory.list(request_options: {extra_headers: {"Authorization" => "Bearer xyz"}})
finch.hris.directory.list(request_options: {extra_headers: {"authorization" => "Bearer xyz"}})
end

assert_nil(requester.attempts.last[:headers]["Authorization"])
assert_nil(requester.attempts.last.fetch(:headers)["authorization"])
end

def test_default_headers
finch = FinchAPI::Client.new(base_url: "http://localhost:4010", access_token: "My Access Token")
requester = MockRequester.new(200, {}, {})
finch.requester = requester
finch.hris.directory.list
headers = requester.attempts.first[:headers]
headers = requester.attempts.first.fetch(:headers)

refute_empty(headers["accept"])
refute_empty(headers["content-type"])
Expand Down
Loading