From 6ca2e0294cadfc2f0e6d048fe3fee57429400b88 Mon Sep 17 00:00:00 2001 From: Copilot Date: Thu, 6 Aug 2026 10:50:27 +0000 Subject: [PATCH] Add minitest test suite and CI workflow - Add test/test_helper.rb with simplecov + minitest/test-unit setup - Add test/faker/test_version.rb covering Faker::VERSION - Add Rakefile with a test task (rake test) as the default task - Add .github/workflows/ci.yml to run tests on push/PR across Ruby 3.2-3.4 - Add .gitignore to exclude coverage/ and bundler artifacts Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 27 +++++++++++++++++++++++++++ .gitignore | 5 +++++ Rakefile | 13 +++++++++++++ test/faker/test_version.rb | 23 +++++++++++++++++++++++ test/test_helper.rb | 13 +++++++++++++ 5 files changed, 81 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 Rakefile create mode 100644 test/faker/test_version.rb create mode 100644 test/test_helper.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..85ce3f42da --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby: ['3.2', '3.3', '3.4'] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + + - name: Run tests + run: bundle exec rake test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..dabd54fbe0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/coverage/ +/.bundle/ +/vendor/bundle/ +*.gem +.rspec_status diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000000..e2c743564c --- /dev/null +++ b/Rakefile @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'bundler/gem_tasks' +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'test' + t.libs << 'lib' + t.test_files = FileList['test/**/test_*.rb'].exclude('test/test_helper.rb') + t.verbose = true +end + +task default: :test diff --git a/test/faker/test_version.rb b/test/faker/test_version.rb new file mode 100644 index 0000000000..7b4ce1d6d7 --- /dev/null +++ b/test/faker/test_version.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require_relative '../test_helper' + +class TestFakerVersion < Test::Unit::TestCase + def test_version_is_defined + assert defined?(Faker::VERSION) + end + + def test_version_is_a_string + assert_instance_of String, Faker::VERSION + end + + def test_version_matches_semver_format + assert_match(/\A\d+\.\d+\.\d+\z/, Faker::VERSION) + end + + def test_version_matches_gemspec + gemspec_path = File.expand_path('../../faker.gemspec', __dir__) + spec = Gem::Specification.load(gemspec_path) + assert_equal spec.version.to_s, Faker::VERSION + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000000..55f6e3023d --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'simplecov' + +SimpleCov.start do + add_filter ['.bundle', 'lib/extensions', 'test'] +end + +require 'minitest/autorun' +require 'test/unit' +require 'rubygems' + +require File.expand_path("#{File.dirname(__FILE__)}/../lib/faker/version")