Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Tests

on:
pull_request:
paths-ignore:
- "README.md"
- "CHANGELOG.md"
- "LICENSE.txt"
- "*.md"
push:
branches:
- main
paths-ignore:
- "README.md"
- "CHANGELOG.md"
- "LICENSE.txt"
- "*.md"

jobs:
test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
ruby_version: ["3.2", "3.3", "3.4"]
gemfile:
- Gemfile
- gemfiles/pay_7.3.gemfile
- gemfiles/pay_8.3.gemfile
- gemfiles/pay_9.0.gemfile
- gemfiles/pay_10.0.gemfile
- gemfiles/pay_11.0.gemfile

env:
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby ${{ matrix.ruby_version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: true

- name: Run tests
run: bundle exec rake test

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-results-ruby-${{ matrix.ruby_version }}-${{ matrix.gemfile }}
path: test/reports/
retention-days: 7
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@
/spec/reports/
/tmp/
/dist
*.gem
*.gem
Gemfile.lock
TODO
VERIFICATION.md

# Appraisal - exclude gemfile lockfiles but keep generated Gemfiles
/gemfiles/*.gemfile.lock
31 changes: 31 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

# Test against Pay 7.x (original minimum supported version)
appraise "pay-7.3" do
gem "pay", "~> 7.3.0"
gem "stripe", "~> 12.0"
end

# Test against Pay 8.x
appraise "pay-8.3" do
gem "pay", "~> 8.3.0"
gem "stripe", "~> 13.0"
end

# Test against Pay 9.x
appraise "pay-9.0" do
gem "pay", "~> 9.0.0"
gem "stripe", "~> 13.0"
end

# Test against Pay 10.x (newly supported version with object column)
appraise "pay-10.0" do
gem "pay", "~> 10.0.0"
gem "stripe", "~> 15.0"
end

# Test against Pay 11.x (latest version as of 2025)
appraise "pay-11.0" do
gem "pay", "~> 11.0"
gem "stripe", "~> 18.0"
end
13 changes: 13 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,16 @@ source "https://rubygems.org"
gemspec

gem "rake", "~> 13.0"

group :development do
gem "appraisal", "~> 2.5"
end

group :test do
gem "minitest", "~> 5.0"
gem "minitest-reporters", "~> 1.6"
gem "mocha", "~> 2.1"
gem "activerecord", ">= 7.0"
gem "actionview", ">= 7.0"
gem "sqlite3"
end
83 changes: 82 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,88 @@ Profitable.mrr # => 123456

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
### Setup

After checking out the repo, install dependencies:

```bash
bundle install
```

### Running Tests

The gem includes a comprehensive test suite with 211 tests covering all functionality:

```bash
# Run all tests
bundle exec rake test

# Run tests with verbose output
bundle exec rake test TESTOPTS="-v"
```

### Testing Against Multiple Pay Gem Versions

This gem uses [Appraisal](https://github.com/thoughtbot/appraisal) to test against multiple versions of the Pay gem, ensuring compatibility across Pay 7.x through 11.x.

**Supported Pay versions:**
- Pay 7.3.x (minimum supported version)
- Pay 8.3.x
- Pay 9.0.x
- Pay 10.x (with `object` column support)
- Pay 11.x (latest)

**Generate appraisal gemfiles:**

```bash
bundle exec appraisal install
```

**Run tests against a specific Pay version:**

```bash
# Test against Pay 10.x
bundle exec appraisal pay-10.0 rake test

# Test against Pay 11.x
bundle exec appraisal pay-11.0 rake test
```

**Run tests against all Pay versions:**

```bash
bundle exec appraisal rake test
```

### Continuous Integration

The gem uses GitHub Actions to automatically test against:
- Ruby versions: 3.2, 3.3, 3.4
- Pay gem versions: 7.3.x, 8.3.x, 9.0.x, 10.x, 11.x
- Total test matrix: 18 combinations (3 Ruby × 6 Pay versions)

See [`.github/workflows/test.yml`](.github/workflows/test.yml) for the full CI configuration.

### Database Compatibility

Tests run on SQLite by default, but the gem supports:
- PostgreSQL (9.3+)
- MySQL (5.7.9+)
- MariaDB (10.2.7+)
- SQLite (3.9.0+)

The gem automatically detects your database adapter and uses the appropriate JSON query syntax.

### Test Coverage

The test suite includes:
- **211 tests** with **250 assertions**
- **10 test files** totaling **6,151 lines** of test code
- **22 regression tests** preventing critical bugs
- Comprehensive processor tests (Stripe, Braintree, Paddle Billing, Paddle Classic)
- Pay v10+ compatibility tests (`object` vs `data` column)
- Database-agnostic JSON query tests
- All public API methods tested

To install this gem onto your local machine, run `bundle exec rake install`.

Expand Down
11 changes: 10 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
task default: %i[]
require "rake/testtask"

Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
t.warning = false
end

task default: :test
22 changes: 22 additions & 0 deletions gemfiles/pay_10.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rake", "~> 13.0"
gem "pay", "~> 10.0.0"
gem "stripe", "~> 15.0"

group :development do
gem "appraisal", "~> 2.5"
end

group :test do
gem "minitest", "~> 5.0"
gem "minitest-reporters", "~> 1.6"
gem "mocha", "~> 2.1"
gem "activerecord", ">= 7.0"
gem "actionview", ">= 7.0"
gem "sqlite3"
end

gemspec path: "../"
22 changes: 22 additions & 0 deletions gemfiles/pay_11.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rake", "~> 13.0"
gem "pay", "~> 11.0"
gem "stripe", "~> 18.0"

group :development do
gem "appraisal", "~> 2.5"
end

group :test do
gem "minitest", "~> 5.0"
gem "minitest-reporters", "~> 1.6"
gem "mocha", "~> 2.1"
gem "activerecord", ">= 7.0"
gem "actionview", ">= 7.0"
gem "sqlite3"
end

gemspec path: "../"
22 changes: 22 additions & 0 deletions gemfiles/pay_7.3.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rake", "~> 13.0"
gem "pay", "~> 7.3.0"
gem "stripe", "~> 12.0"

group :development do
gem "appraisal", "~> 2.5"
end

group :test do
gem "minitest", "~> 5.0"
gem "minitest-reporters", "~> 1.6"
gem "mocha", "~> 2.1"
gem "activerecord", ">= 7.0"
gem "actionview", ">= 7.0"
gem "sqlite3"
end

gemspec path: "../"
22 changes: 22 additions & 0 deletions gemfiles/pay_8.3.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rake", "~> 13.0"
gem "pay", "~> 8.3.0"
gem "stripe", "~> 13.0"

group :development do
gem "appraisal", "~> 2.5"
end

group :test do
gem "minitest", "~> 5.0"
gem "minitest-reporters", "~> 1.6"
gem "mocha", "~> 2.1"
gem "activerecord", ">= 7.0"
gem "actionview", ">= 7.0"
gem "sqlite3"
end

gemspec path: "../"
22 changes: 22 additions & 0 deletions gemfiles/pay_9.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rake", "~> 13.0"
gem "pay", "~> 9.0.0"
gem "stripe", "~> 13.0"

group :development do
gem "appraisal", "~> 2.5"
end

group :test do
gem "minitest", "~> 5.0"
gem "minitest-reporters", "~> 1.6"
gem "mocha", "~> 2.1"
gem "activerecord", ">= 7.0"
gem "actionview", ">= 7.0"
gem "sqlite3"
end

gemspec path: "../"
Loading