test: SimpleCov 100% coverage gate + fix Android device_screen_size bug#32
test: SimpleCov 100% coverage gate + fix Android device_screen_size bug#32AkashBrowserStack wants to merge 4 commits into
Conversation
…size bug
The SDK had minitest specs but no coverage instrumentation. This wires
SimpleCov with a 100% line gate and raises coverage to 100%.
Coverage tooling (the suite runs one spec per process):
- Add simplecov to the Gemfile.
- specs/support/spec_helper.rb starts SimpleCov per process with a unique
command_name so results merge into coverage/.resultset.json.
- specs/support/run_spec.rb loads the helper then the target spec (a CLI
`-r` flag can't load simplecov before bundler sets up the path).
- specs/support/coverage_check.rb collates the merged results and enforces
minimum_coverage line: 100.
- CI runs each spec via run_spec.rb, then coverage_check.rb as the gate.
Source bug fixed (surfaced by the new coverage runs):
- Percy::AndroidMetadata#device_screen_size returned symbol-keyed hashes
({width:, height:}) while every caller — GenericProvider#get_tag,
#get_tiles, #get_regions_by_location, and AndroidMetadata itself — reads
string keys ('width'/'height'), as does IosMetadata#device_screen_size.
On Android this silently produced 1x1 tiles (the `|| 1` fallback) and
crashed get_regions_by_location (Integer >= nil). Return string keys to
match iOS and all callers; updated the one spec asserting symbol keys.
Tests added across cli_wrapper, percy_automate (new spec), app_automate,
generic_provider, app_percy, driver_metadata, ios_metadata, metadata,
common, and the top-level percy_screenshot error paths — covering all 52
previously-uncovered lines (error/branch/rescue paths). Also restored
monkey-patched metadata methods in generic_providers teardown to remove
pre-existing run-order flakiness.
Result: 100% line coverage (704/704), all specs green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
stub(:m, 'k' => 'v') passes the string-keyed hash as keywords on Ruby 3.0 (kwarg separation), so Minitest's stub(name, val_or_callable) received too few args (ArgumentError: given 1, expected 2+) — a pre-existing failure on the repo's Ruby 3.0 CI matrix. Wrap the hash in explicit braces so it is a positional value on 2.6/2.7/3.0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Ruby 3.0 has pre-existing, coverage-unrelated failures (appium_lib API/version drift); fail-fast was cancelling the green 2.6/2.7 jobs. Run each version independently so the working versions (and the new coverage gate) report green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude Code PR ReviewPR: #32 • Head: 5d891a3 • Reviewers: stack:code-reviewer (acting per SummaryAdds a SimpleCov 100%-line-coverage gate (per-process Review Table
Findings
Verdict: PASS |
Add a pull_request trigger so the SimpleCov 100% coverage gate runs as a PR check. Pin appium_lib ~> 12.0 (and appium_console ~> 3.0, which requires appium_lib = 12.0.0) so all Ruby legs resolve appium_lib_core ~> 5.0, which still exposes Appium::Core::Base::SearchContext. Unpinned, Ruby 3.0 pulled appium_lib 15 / appium_lib_core 9.x, which removed that constant and made the 3.0 leg red. fail-fast stays false. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude Code PR ReviewPR: #32 • Head: c818768 • Reviewers: stack:code-reviewer (.claude/agents) + 18-row checklist SummaryAdds a SimpleCov 100% line-coverage gate (per-process Review Table
FindingsNo Fail rows. Two non-blocking Low observations (not gating):
These are stylistic and do not affect correctness. The production bug fix is correct and well-targeted, the Ruby-3.0 pin is justified and documented, and the coverage tooling is sound. Verdict: PASS |
What & why
The SDK had minitest specs but no coverage instrumentation or gate. This adds SimpleCov with a 100% line gate and raises coverage to 100% (704/704), verified on Ruby 2.6.
Coverage tooling
The suite runs one spec per process (
for file in specs/*.rb; ruby $file), so:simplecovadded to the Gemfile.specs/support/spec_helper.rbstarts SimpleCov per process (uniquecommand_name→ results merge).specs/support/run_spec.rbloads the helper then the spec (a-rflag can't load simplecov before bundler sets up the path).specs/support/coverage_check.rbcollates the merged results and enforcesminimum_coverage line: 100.run_spec.rb, thencoverage_check.rbas the gate.Source bug fixed (found by the new coverage runs)
Percy::AndroidMetadata#device_screen_sizereturned symbol-keyed hashes while every caller (andIosMetadata) reads string keys — on Android this silently produced 1×1 tiles (|| 1fallback) and crashedget_regions_by_location(Integer >= nil). Fixed to return string keys; updated the one spec asserting symbol keys.Tests
Added tests covering all 52 previously-uncovered lines across
cli_wrapper,percy_automate(new spec),app_automate,generic_provider,app_percy,driver_metadata,ios_metadata,metadata,common, and the top-levelpercy_screenshoterror paths. Restored monkey-patched metadata methods ingeneric_providersteardown to remove pre-existing run-order flakiness. Also made the existingexecute_percy_screenshot_endstub Ruby-3.0-kwarg-safe.Verification
This repo's Test workflow has been red on
mainfor months on the Ruby 3.0 matrix entry, from pre-existing issues unrelated to coverage — e.g.appium_libAPI/version drift (uninitialized constant Appium::Core::Base::SearchContexton the 3.0-resolved gem set) and Ruby 3.0 keyword-argument separation. This PR fixes the one 3.0 kwarg issue it touched, but fully greening the 3.0 matrix is a separate dependency-modernization effort (and isn't reproducible without a Ruby 3.0 toolchain). The coverage gate and 100% are delivered for the working Ruby versions; the 3.0 jobs remain pre-existingly red.🤖 Generated with Claude Code