Skip to content

Commit 6d84af6

Browse files
authored
Merge pull request #4 from rameerez/cursor/ensure-gem-is-thoroughly-tested-and-bug-free-d486
Add complete `minitest` test suite
2 parents 81974cb + befc82d commit 6d84af6

28 files changed

+4622
-205
lines changed

.github/workflows/test.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- "*.md"
7+
- "LICENSE.txt"
8+
push:
9+
branches:
10+
- main
11+
paths-ignore:
12+
- "*.md"
13+
- "LICENSE.txt"
14+
15+
jobs:
16+
# Main test suite - tests Ruby versions and Rails compatibility
17+
test:
18+
runs-on: ubuntu-latest
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
ruby_version: ["3.3", "3.4", "4.0"]
24+
gemfile:
25+
- Gemfile
26+
- gemfiles/rails_7.2.gemfile
27+
- gemfiles/rails_8.0.gemfile
28+
- gemfiles/rails_8.1.gemfile
29+
30+
env:
31+
RAILS_ENV: test
32+
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
33+
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v4
37+
38+
- name: Set up Ruby ${{ matrix.ruby_version }}
39+
uses: ruby/setup-ruby@v1
40+
with:
41+
ruby-version: ${{ matrix.ruby_version }}
42+
bundler-cache: true
43+
44+
- name: Run tests
45+
run: bundle exec rake test
46+
47+
- name: Upload test results
48+
if: failure()
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: test-results-sqlite-ruby-${{ matrix.ruby_version }}-${{ matrix.gemfile }}
52+
path: test/reports/
53+
retention-days: 7

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,37 @@
66
/pkg/
77
/spec/reports/
88
/tmp/
9+
10+
test/dummy/db/*.sqlite3*
11+
test/dummy/log/*.log
12+
test/dummy/tmp/
13+
test/dummy/public/packs/
14+
test/dummy/public/packs-test/
15+
test/dummy/node_modules/
16+
test/dummy/Gemfile.lock
17+
test/dummy/config/master.key
18+
test/dummy/storage/*.sqlite3*
19+
test/dummy/log/*
20+
test/coverage/*
21+
**/.kamal/
22+
deploy.yml
23+
.DS_Store
24+
25+
/Gemfile.lock
26+
/gemfiles/*.gemfile.lock
27+
928
/dist/
1029
*.gem
1130

31+
# Ignore bundler and vendor-installed gems
32+
/vendor/
33+
/vendor/**
34+
/vendor/bundle/
35+
/vendor/cache/
36+
/vendor/ruby/
37+
38+
.cursor/
39+
.claude/
40+
.aux/
41+
1242
TODO

.simplecov

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# frozen_string_literal: true
2+
3+
# SimpleCov configuration file (auto-loaded before test suite)
4+
# This keeps test_helper.rb clean and follows best practices
5+
6+
SimpleCov.start do
7+
# Use SimpleFormatter for terminal-only output (no HTML generation)
8+
formatter SimpleCov::Formatter::SimpleFormatter
9+
10+
# Track coverage for the lib directory (gem source code)
11+
add_filter "/test/"
12+
13+
# Track the lib and app directories
14+
track_files "{lib,app}/**/*.rb"
15+
16+
# Enable branch coverage for more detailed metrics
17+
enable_coverage :branch
18+
19+
# Set minimum coverage threshold to prevent coverage regression
20+
minimum_coverage line: 80, branch: 75
21+
22+
# Disambiguate parallel test runs
23+
command_name "Job #{ENV['TEST_ENV_NUMBER']}" if ENV['TEST_ENV_NUMBER']
24+
end
25+
26+
# Print coverage summary to terminal after tests complete
27+
SimpleCov.at_exit do
28+
SimpleCov.result.format!
29+
puts "\n" + "=" * 60
30+
puts "COVERAGE SUMMARY"
31+
puts "=" * 60
32+
puts "Line Coverage: #{SimpleCov.result.covered_percent.round(2)}%"
33+
puts "Branch Coverage: #{SimpleCov.result.coverage_statistics[:branch]&.percent&.round(2) || 'N/A'}%"
34+
puts "=" * 60
35+
end

AGENTS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# AGENTS.md
2+
3+
This file provides guidance to AI Agents (like OpenAI's Codex, Cursor Agent, Claude Code, etc) when working with code in this repository.
4+
5+
Please go ahead and read the full context for this project at `.cursor/rules/0-overview.mdc` and `.cursor/rules/1-quality.mdc` now. Also read the README for a good overview of the project.

Appraisals

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# frozen_string_literal: true
2+
3+
# Note: Rails < 7.2 is not compatible with Ruby 3.4
4+
# (Logger became a bundled gem in Ruby 3.4, and only Rails 7.2+ handles this)
5+
# See: https://stdgems.org/logger/
6+
7+
# Test against Rails 7.2 (minimum version compatible with Ruby 3.4)
8+
appraise "rails-7.2" do
9+
gem "rails", "~> 7.2.0"
10+
end
11+
12+
# Test against Rails 8.0
13+
appraise "rails-8.0" do
14+
gem "rails", "~> 8.0.0"
15+
end
16+
17+
# Test against Rails 8.1 (latest)
18+
appraise "rails-8.1" do
19+
gem "rails", "~> 8.1.0"
20+
end

CLAUDE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
Please go ahead and read the full context for this project at `.cursor/rules/0-overview.mdc` and `.cursor/rules/1-quality.mdc` now. Also read the README for a good overview of the project.

Gemfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,11 @@ source "https://rubygems.org"
66
gemspec
77

88
gem "rake", "~> 13.0"
9+
10+
group :development, :test do
11+
gem "appraisal"
12+
gem "minitest", "~> 6.0"
13+
gem "minitest-mock"
14+
gem "rack-test"
15+
gem "simplecov", require: false
16+
end

Gemfile.lock

Lines changed: 0 additions & 202 deletions
This file was deleted.

Rakefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# frozen_string_literal: true
22

33
require "bundler/gem_tasks"
4-
task default: %i[]
4+
require "rake/testtask"
5+
6+
Rake::TestTask.new do |t|
7+
t.libs << "test"
8+
t.pattern = "test/**/*_test.rb"
9+
t.warning = false
10+
end
11+
12+
task default: %i[test]

0 commit comments

Comments
 (0)