Skip to content

Commit 62076b9

Browse files
authored
Merge pull request #1 from rameerez/cursor/ensure-gem-is-fully-tested-and-robust-29e7
Add full Minitest 6 testing suite
2 parents 91339dc + bf873ca commit 62076b9

19 files changed

+2691
-16
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

.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: 90, branch: 90
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

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.2"
20+
end

Gemfile

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

88
gem "rake", "~> 13.0"
9+
10+
group :test do
11+
gem "appraisal"
12+
gem "minitest", "~> 6.0"
13+
gem "minitest-mock"
14+
gem "minitest-reporters", "~> 1.6"
15+
gem "webmock", "~> 3.19"
16+
gem "sqlite3", "~> 2.1"
17+
gem "simplecov", require: false
18+
end

Rakefile

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

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

gemfiles/rails_7.2.gemfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "rake", "~> 13.0"
6+
gem "rails", "~> 7.2.0"
7+
8+
group :test do
9+
gem "appraisal"
10+
gem "minitest", "~> 6.0"
11+
gem "minitest-mock"
12+
gem "minitest-reporters", "~> 1.6"
13+
gem "webmock", "~> 3.19"
14+
gem "sqlite3", "~> 2.1"
15+
gem "simplecov", require: false
16+
end
17+
18+
gemspec path: "../"

gemfiles/rails_8.0.gemfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "rake", "~> 13.0"
6+
gem "rails", "~> 8.0.0"
7+
8+
group :test do
9+
gem "appraisal"
10+
gem "minitest", "~> 6.0"
11+
gem "minitest-mock"
12+
gem "minitest-reporters", "~> 1.6"
13+
gem "webmock", "~> 3.19"
14+
gem "sqlite3", "~> 2.1"
15+
gem "simplecov", require: false
16+
end
17+
18+
gemspec path: "../"

gemfiles/rails_8.1.gemfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "rake", "~> 13.0"
6+
gem "rails", "~> 8.1.2"
7+
8+
group :test do
9+
gem "appraisal"
10+
gem "minitest", "~> 6.0"
11+
gem "minitest-mock"
12+
gem "minitest-reporters", "~> 1.6"
13+
gem "webmock", "~> 3.19"
14+
gem "sqlite3", "~> 2.1"
15+
gem "simplecov", require: false
16+
end
17+
18+
gemspec path: "../"

lib/nondisposable.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ def self.configure
1919

2020
def self.disposable?(email)
2121
return false if email.nil? || !email.include?('@')
22-
domain = email.to_s.split('@').last.downcase
23-
DisposableDomain.disposable?(domain)
22+
domain = email.to_s.split('@').last
23+
return false if domain.nil? || domain.empty?
24+
DisposableDomain.disposable?(domain.downcase)
2425
end
2526

2627
class Configuration

lib/nondisposable/engine.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ module Nondisposable
44
class Engine < ::Rails::Engine
55
isolate_namespace Nondisposable
66

7-
initializer "nondisposable.assets.precompile" do |app|
8-
app.config.assets.precompile += %w( nondisposable/application.css nondisposable/application.js )
9-
end
10-
117
config.generators do |g|
128
g.test_framework :rspec
139
g.fixture_replacement :factory_bot

0 commit comments

Comments
 (0)