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/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/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/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] 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"] 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 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