Skip to content

test: enforce 95% coverage with SimpleCov and close all spec gaps - #55

Merged
nejdetkadir merged 2 commits into
mainfrom
test/add-simplecov-and-full-coverage
Aug 25, 2026
Merged

nejdetkadir merged 2 commits into
mainfrom
test/add-simplecov-and-full-coverage

Conversation

@nejdetkadir

Copy link
Copy Markdown
Owner

Summary

  • Adds SimpleCov with an enforced 95% line-coverage minimum on full-suite runs (bundle exec rake) and CI; the suite now sits at 100% line and 100% branch coverage (282 examples).
  • Closes every documented test gap: real monad-contract service specs (KI-12), install generator specs (KI-13), non-default configuration specs (KI-14), plus token model and controller-helpers specs.
  • Removes the dead TokensService::Create#authenticate_service method (KI-5) in a separate commit.

Changes

  • Coverage tooling: simplecov ~> 0.22 in the Gemfile (compatible with the Ruby 2.7 CI floor); SimpleCov.start at the top of spec/spec_helper.rb before the gem loads; minimum enforced only when CI or ENFORCE_COVERAGE is set — a new enforce_coverage Rakefile prerequisite sets it for rake, so single-file rspec runs stay unaffected. version.rb is filtered (loaded by the gemspec before coverage can start).
  • Service specs (spec/services/**): replaced the six inheritance-only placeholders with Success/Failure contract specs, including branches unreachable via HTTP (:invalid_resource_owner, :devise_api_token_create_error, :devise_api_token_revoke_error, sign-up transaction rollback).
  • New specs: install_generator_spec.rb (migration template, locale copy, migration numbering), token_spec.rb (active?/inactive?, expires_in_infinite, generator collision retry, conditional validations), helpers_spec.rb (invalid-location ArgumentError, header-extraction rescue, unmemoized refresh-token lookup), configuration_overrides_spec.rb (disabled sign_up/refresh, extra_fields, revoke failure, :header/:params-only locations, with around/ensure config restore), admin_user_tokens_spec.rb, customized_path_names_routes_spec.rb.
  • Dummy app: new bare AdminUser model (database_authenticatable, registerable, validatable, :api only) with table, migration, factory and devise_for :admin_users routes, so every "optional Devise module not enabled" branch is exercised end-to-end; users.name column added for extra_fields coverage.
  • Response/config spec extensions: locked/unconfirmed/bare-model ErrorResponse variants (incl. unlock_at), TokenResponse refresh-disabled/extra-fields/non-confirmable bodies, Configuration overrides on fresh instances.
  • Source: dead method removed from TokensService::Create; one pre-existing over-length line in token_response.rb reformatted for RuboCop (no behavior change).
  • Docs (contractual): testing.md coverage section + fully-green coverage map, known-issues.md (KI-5/12/13 resolved, KI-14 mostly resolved), development.md, services.md.

Architecture Impact

  • No production behavior changes. New dummy-app migrations (admin_users table, users.name) affect the test schema only — the gem's generator template is untouched.
  • Gemfile.lock: simplecov + deps, arm64-darwin-25 platform entry, and recording the gem's own 0.1.3 → 0.2.0 drift.

Test Plan

  • bundle exec rake green (282 examples, 0 failures; RuboCop 0 offenses)
  • Line coverage 100% (441/441), branch coverage 100% (112/112)
  • Enforcement verified: partial run under CI=true fails with the below-minimum error
  • Suite run twice with --order random — no config leakage between examples

Related

  • Resolves KI-5, KI-12, KI-13 and most of KI-14 from docs/analysis/known-issues.md

🤖 Generated with Claude Code

nejdetkadir and others added 2 commits August 25, 2026 18:49
Create#authenticate_service was never called and referenced params /
resource_class, which don't exist on this service (KI-5).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds SimpleCov (95% line minimum on full-suite and CI runs; suite now at
100% line/branch), real monad-contract service specs (KI-12), generator
specs (KI-13), token model and helpers specs, config-override request
specs (KI-14), and a bare AdminUser dummy model so the optional-module
false branches are exercised end-to-end. Docs updated to match.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@nejdetkadir nejdetkadir self-assigned this Aug 25, 2026
@nejdetkadir
nejdetkadir merged commit 0564133 into main Aug 25, 2026
8 checks passed
@nejdetkadir
nejdetkadir deleted the test/add-simplecov-and-full-coverage branch August 25, 2026 15:52
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.

1 participant