Skip to content

Add spec coverage for Client::Helper, query_string scheme, and Errors classes - #398

Merged
pboling merged 1 commit into
ruby-oauth:mainfrom
iamibi:test/client-helper-and-errors-coverage
Sep 18, 2026
Merged

pboling merged 1 commit into
ruby-oauth:mainfrom
iamibi:test/client-helper-and-errors-coverage

Conversation

@iamibi

@iamibi iamibi commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #397

Line coverage dropped from 88.32% to 69.47% between v1.1.7 and v1.1.8. lib/oauth/client/ is the weakest real directory (~66%), and these had no dedicated spec file:

  • OAuth::Client::Helper (lib/oauth/client/helper.rb) — used by every HTTP adapter
  • The query_string OAuth signing scheme in lib/oauth/client/net_http.rb
  • OAuth::Error / OAuth::Unauthorized / OAuth::Problem (lib/oauth/errors/)

This PR adds specs only — no behavior changes.

What changed

  • spec/oauth/client/helper_spec.rb (new) — covers #nonce, #timestamp, #oauth_parameters (incl. allow_empty_params variants), #token_request?, #hash_body, #amend_user_agent_header, #header, #parameters, #parameters_with_oauth
  • spec/net/http_spec.rb — added coverage for the query_string scheme (fresh query and appending to an existing one) and the URI-derivation branches in #signature_base_string (https fallback, :request_endpoint + :site)
  • spec/oauth/error_spec.rb, spec/oauth/unauthorized_spec.rb, spec/oauth/problem_spec.rb (new) — cover OAuth::Error, OAuth::Unauthorized#to_s/#request, OAuth::Problem#to_s/#problem/#params
    • Note: these live at spec/oauth/*_spec.rb rather than mirroring lib/oauth/errors/, since RSpec/SpecFilePathFormat derives the expected path from the OAuth:: constant name, not the lib/ directory
  • CHANGELOG.md — [Unreleased] entry

Test plan

  • bundle exec kettle-test — 189 examples, 0 failures, 5 pending (unchanged, pre-existing pending specs for optional gems not installed)
  • bundle exec rake rubocop_gradual:check — clean, only the pre-existing tracked Lint/EmptyWhen violation remains
  • bin/rake reek — no new smells introduced by the new/changed spec files
  • Confirmed via direct (non-parallel) coverage runs that the previously-uncovered lines in helper.rb, net_http.rb, and errors/*.rb are now exercised

… classes

Coverage dropped from 88.32% to 69.47% line coverage between v1.1.7 and
v1.1.8. lib/oauth/client/ was the weakest real directory, with
OAuth::Client::Helper, the query_string OAuth scheme, and the OAuth
error classes having no dedicated spec files.
@iamibi

iamibi commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Looked into the failing checks — none of them are caused by the 5 files changed in this PR:

  • All per-Ruby-version Specs jobs are green (2.4–3.4, current, dep-heads, JRuby, TruffleRuby).
  • Code Coverage / Default rake task (locked & unlocked deps) fail because line coverage is still under the 80% hard gate. This job has been failing on main since at least 2026-07-27, so it's a pre-existing gap, not a regression from this PR — this PR actually nudges coverage up slightly (68.88% → 70.72%).
  • Specs *-head@head jobs are explicitly continue-on-error: true in heads.yml for bleeding-edge interpreter builds, by design.
  • run (Auto Assign) needs repo-write permissions forks don't get — expected on external PRs.
  • Style shows violations across ~45 unrelated files (Gemfile, README, oauth.gemspec, consumer.rb, etc.). style.yml runs against Appraisal.root.gemfile, whose lock file isn't committed to the repo, so it resolves rubocop-lts fresh on every run — a newer release there looks like the cause, and it would likely show up on a fresh push to main too.

Happy to help address any of these separately if useful, but wanted to flag that they're unrelated to the spec changes here.

@iamibi

iamibi commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Correction to my comment above — one more job is unrelated to this PR too: Specs - Ruby ruby current under the Windows workflow fails with Exec format error trying to run kettle-test.sh (Ruby 4.0.6 on Windows). Same root cause as Style: gemfiles/current.gemfile.lock isn't committed either, so that job resolves kettle-test fresh on every run — it pulled kettle-test 2.0.22, which looks like it has a Windows-specific packaging issue unrelated to the spec changes here. Windows passed on main's last run (2026-09-07) for the same reason — a newer, unpinned dependency release is the likely trigger, not this PR.

@pboling

pboling commented Sep 18, 2026

Copy link
Copy Markdown
Member

This looks great. I'll fix those CI issues in separate PRs.

@pboling
pboling merged commit e69492b into ruby-oauth:main Sep 18, 2026
30 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test coverage regression: lib/oauth/client/ dropped to ~69% between v1.1.7 and v1.1.8

2 participants