From ee5bd7c9056685cb4a73fd631499049e81fbc92d Mon Sep 17 00:00:00 2001 From: MarioRuiz Date: Tue, 24 Mar 2026 12:32:34 +0000 Subject: [PATCH 1/4] Migrate coverage reporting to SimpleCov with GitHub Actions Coveralls upload. Replace Travis/Coveralls gem integration with GitHub CI matrix and Coveralls parallel uploads so coverage is reported correctly from Actions runs. Made-with: Cursor --- .github/workflows/ci.yml | 45 ++++++++++++++++++++++++++++++++++++++++ Gemfile | 2 +- README.md | 2 +- spec/spec_helper.rb | 6 +++--- 4 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..950ca25 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: CI + +on: + push: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby-version: ["3.0", "3.1", "3.2", "3.3", "3.4"] + + steps: + - 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 rspec + + - name: Upload coverage to Coveralls + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + file: coverage/.resultset.json + format: simplecov + flag-name: ruby-${{ matrix.ruby-version }} + parallel: true + + coveralls-finish: + needs: test + if: always() + runs-on: ubuntu-latest + steps: + - name: Mark Coveralls parallel build as finished + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel-finished: true diff --git a/Gemfile b/Gemfile index 3db65df..dad9c45 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ group :test do gem "rspec" gem "sinatra", "~> 3.0" gem "webrick" - gem "coveralls_reborn", "~> 0.27.0", require: false + gem "simplecov", "~> 0.22.0", require: false end # Specify your gem's dependencies in mygem.gemspec diff --git a/README.md b/README.md index 24e4c8b..f7fd074 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # NiceHttp [![Gem Version](https://badge.fury.io/rb/nice_http.svg)](https://rubygems.org/gems/nice_http) -[![Build Status](https://travis-ci.com/MarioRuiz/nice_http.svg?branch=master)](https://github.com/MarioRuiz/nice_http) +[![CI](https://github.com/MarioRuiz/nice_http/actions/workflows/ci.yml/badge.svg)](https://github.com/MarioRuiz/nice_http/actions/workflows/ci.yml) [![Coverage Status](https://coveralls.io/repos/github/MarioRuiz/nice_http/badge.svg?branch=master)](https://coveralls.io/github/MarioRuiz/nice_http?branch=master) ![Gem](https://img.shields.io/gem/dt/nice_http) ![GitHub commit activity](https://img.shields.io/github/commit-activity/y/MarioRuiz/nice_http) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 09ba82a..1e0791c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,12 +1,12 @@ +require "simplecov" +SimpleCov.start + # Start local fake API server(s) in-process and set HOST_EXAMPLE_SINATRA / TEST_SERVER_URL (set USE_FAKE_API=false to use external hosts) require_relative "support/server" if File.exist?(File.join(__dir__, "support", "server.rb")) ENV["HOST_EXAMPLE_SINATRA"] ||= "http://localhost:4567" TEST_SERVER_URL = ENV["TEST_SERVER_URL"] || "http://localhost:4567" unless defined?(TEST_SERVER_URL) TEST_SERVER_URL_2 = ENV["TEST_SERVER_URL_2"] || "http://localhost:4568" unless defined?(TEST_SERVER_URL_2) -require "coveralls" -Coveralls.wear! - # This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause From a9a9aaa031104995b9cc8b4a7e5121ecbfae2e2a Mon Sep 17 00:00:00 2001 From: MarioRuiz Date: Tue, 24 Mar 2026 12:38:53 +0000 Subject: [PATCH 2/4] Fix validate_response spec to avoid ActiveSupport matcher dependency. Replace be_present with plain RSpec assertions so the test passes consistently in CI and local runs. Made-with: Cursor --- spec/nice_http/validate_response_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/nice_http/validate_response_spec.rb b/spec/nice_http/validate_response_spec.rb index f803eb7..7e2f18c 100644 --- a/spec/nice_http/validate_response_spec.rb +++ b/spec/nice_http/validate_response_spec.rb @@ -48,7 +48,8 @@ expected = {} result = described_class.validate_response(resp, expected) expect(result[:ok]).to be false - expect(result[:error]).to be_present + expect(result[:error]).to be_a(String) + expect(result[:error]).not_to be_empty end it "accepts nested expected structure" do From 9e888a143a49b782f45d9d54ffaa9af97d3ea367 Mon Sep 17 00:00:00 2001 From: MarioRuiz Date: Tue, 24 Mar 2026 12:44:36 +0000 Subject: [PATCH 3/4] Fix HTTP method detection for request logging and stats on Ruby 3.4. Use caller_locations with a fallback instead of parsing caller strings so capture and stats consistently record GET/POST method names across Ruby versions. Made-with: Cursor --- lib/nice_http/manage/request.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/nice_http/manage/request.rb b/lib/nice_http/manage/request.rb index b37c44f..31d9c81 100644 --- a/lib/nice_http/manage/request.rb +++ b/lib/nice_http/manage/request.rb @@ -83,7 +83,16 @@ def manage_request(*arguments_param) } headers_t["Cookie"] = cookies_to_set_str - method_s = caller[0].to_s().scan(/:in `(.*)'/).join + method_s = caller_locations(1, 10).map(&:base_label).find do |label| + %w[get post put patch delete head send_request].include?(label) + end + if method_s == "send_request" && arguments.size == 1 && arguments[0].kind_of?(Hash) && arguments[0].key?(:method) + method_s = arguments[0][:method].to_s + end + if method_s.to_s == "" + method_s = caller[0].to_s().scan(/:in `(.*)'/).join + end + method_s = "request" if method_s.to_s == "" @request[:method] = method_s.upcase self.class.request[:method] = @request[:method] From b8445e360c1d0fb8f56ac40ebcd30fa6312cca7c Mon Sep 17 00:00:00 2001 From: MarioRuiz Date: Tue, 24 Mar 2026 12:48:14 +0000 Subject: [PATCH 4/4] Release version 1.10.1. Bump gem version and document the Ruby 3.4 method detection fix for request capture and stats in the changelog. Made-with: Cursor --- CHANGELOG.md | 6 ++++++ nice_http.gemspec | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eae0a85..51e02fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +## [1.10.1] - 2026-03-24 + +### Fixed + +- Robust HTTP method detection in request management using `caller_locations` with fallback logic, fixing Ruby 3.4 compatibility for capture/stats method keys (`GET`, `POST`, etc.). + ## [1.10.0] - 2026-02-13 ### Added diff --git a/nice_http.gemspec b/nice_http.gemspec index 5075155..5852cec 100644 --- a/nice_http.gemspec +++ b/nice_http.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "nice_http" - s.version = "1.10.0" + s.version = "1.10.1" s.summary = "NiceHttp -- simplest library for accessing and testing HTTP and REST resources. Get http logs and statistics automatically. Use hashes on your requests. Access JSON even easier." s.description = "NiceHttp -- simplest library for accessing and testing HTTP and REST resources. Get http logs and statistics automatically. Use hashes on your requests. Access JSON even easier." s.authors = ["Mario Ruiz"]