diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7929a9840..5230ca2cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,12 +8,16 @@ jobs: runs-on: ubuntu-latest name: Ruby ${{ matrix.ruby }} tests strategy: + fail-fast: false matrix: - ruby: [2.3, 2.4, 2.5, 2.6, 2.7, jruby-9.3] + # '4' is a prefix match resolved against the version list baked into the + # setup-ruby commit pinned below, so it only tracks new 4.x releases as far + # as that pin. Bump the pin to pick up newer ones. + ruby: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0.5', '4', 'jruby-9.3'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@a37ce9120846195fa4ece8f58b268e6043cb2f26 # v3 - name: Setup ruby - uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0 with: ruby-version: ${{ matrix.ruby }} - run: ./scripts/build diff --git a/.github/workflows/pr-review.yml b/.github/workflows/pr-review.yml deleted file mode 100644 index 5239309ef..000000000 --- a/.github/workflows/pr-review.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: PR Review - -on: - pull_request: - types: - - opened - - repoened - - edited - - synchronize - - labeled - - unlabeled - -concurrency: - group: ${{ github.workflow }} - ${{ github.ref }} - cancel-in-progress: true - -jobs: - label-checker: - runs-on: ubuntu-latest - name: Label Checker - steps: - - name: Check Labels - uses: docker://agilepathway/pull-request-label-checker:latest - with: - one_of: V2 - repo_token: ${{ secrets.GITHUB_TOKEN }} - \ No newline at end of file diff --git a/lib/recurly_v2/xml/nokogiri.rb b/lib/recurly_v2/xml/nokogiri.rb index 8853b8994..04b55b47c 100644 --- a/lib/recurly_v2/xml/nokogiri.rb +++ b/lib/recurly_v2/xml/nokogiri.rb @@ -18,10 +18,10 @@ def each_element xpath = nil elements.each { |el| yield el } end - def each element = root + def each element = root, &block element.elements.each do |el| - yield el - each el, &Proc.new + block.call el + each el, &block end end diff --git a/lib/recurly_v2/xml/rexml.rb b/lib/recurly_v2/xml/rexml.rb index 7c25d5564..741f47812 100644 --- a/lib/recurly_v2/xml/rexml.rb +++ b/lib/recurly_v2/xml/rexml.rb @@ -19,10 +19,10 @@ def each_element xpath = nil root.each_element(xpath) { |el| yield el } end - def each element = root + def each element = root, &block element.each_element do |el| - yield el - each el, &Proc.new + block.call el + each el, &block end end diff --git a/recurly.gemspec b/recurly.gemspec index c3f89751e..8e0201b97 100644 --- a/recurly.gemspec +++ b/recurly.gemspec @@ -25,10 +25,24 @@ Gem::Specification.new do |s| s.add_development_dependency 'nokogiri', '~> 1.8', '>= 1.8.2' end - s.add_development_dependency 'rake', '~> 11.3' - s.add_development_dependency 'minitest', '~> 5.8', '>= 5.8.0' + # logger left the default gems in Ruby 4.0; spec_helper requires it. + s.add_development_dependency 'logger' + # rake 11 requires ostruct, gone from Ruby 4.0's default gems. + s.add_development_dependency 'rake', '>= 11.3' + # Held to the 5.x line: minitest 6 needs Ruby >= 3.2, dropped the global must_* + # expectations this suite is written in, and moved Minitest::Mock to a gem that + # itself needs Ruby >= 3.1 — none of which the old half of the matrix can meet. + s.add_development_dependency 'minitest', '~> 5.8' + # Restores must_* if a bundled minitest 6 wins activation over the pin above. + s.add_development_dependency 'minitest-global_expectations' + # On Ruby 4.0 the bundled minitest 6 does win, and it no longer ships + # Minitest::Mock. Earlier Rubies keep getting Mock from minitest 5 itself. + if RUBY_VERSION >= '4.0' + s.add_development_dependency 'minitest-mock' + end s.add_development_dependency 'addressable', '~> 2.4', '>= 2.4.0' - s.add_development_dependency 'webmock', '~> 2.3', '>= 2.3.2' + # webmock 2.x requires base64, gone from Ruby 3.4's default gems. + s.add_development_dependency 'webmock', '>= 2.3.2' s.add_development_dependency 'simplecov', '~> 0' if RUBY_PLATFORM != 'java' && !ENV['CI'] diff --git a/spec/environment.rb b/spec/environment.rb index 4d76a48eb..2d276afeb 100644 --- a/spec/environment.rb +++ b/spec/environment.rb @@ -3,8 +3,12 @@ require 'stringio' old_stderr, $stderr = $stderr, StringIO.new at_exit do - $stderr.rewind - $stderr.lines.each { |line| old_stderr.puts line if line.include? lib } + # Warnings from anywhere but lib are noise, but suppressing them unconditionally + # also swallows load errors and leaves a failing run with no output at all. + failing = !$!.nil? && !($!.is_a?(SystemExit) && $!.success?) + buffered, $stderr = $stderr, old_stderr + buffered.rewind + buffered.each_line { |line| old_stderr.puts line if failing || line.include?(lib) } end case ENV['XML'] diff --git a/spec/recurly_v2/adjustment_spec.rb b/spec/recurly_v2/adjustment_spec.rb index 0c1c531d6..9fe79b840 100644 --- a/spec/recurly_v2/adjustment_spec.rb +++ b/spec/recurly_v2/adjustment_spec.rb @@ -85,7 +85,7 @@ juris_detail.tax_in_cents[:USD].must_equal 115 juris_detail.rate.must_equal 0.056 juris_detail.description.must_equal 'Sales Tax' - juris_detail.jurisdiction_name.must_equal nil + juris_detail.jurisdiction_name.must_be_nil end it "must raise an exception when unavailable" do @@ -107,7 +107,7 @@ stub_api_request :get, 'adjustments/abcdef1234567890', 'adjustments/show-200-nosub' adjustment = Adjustment.find 'abcdef1234567890' - adjustment.subscription.must_equal nil + adjustment.subscription.must_be_nil end describe '#marshal_dump' do @@ -117,7 +117,7 @@ adjustment = Adjustment.find 'abcdef1234567890' adjustment_from_dump = Marshal.load(Marshal.dump(adjustment)) - adjustment.instance_variables.must_equal adjustment_from_dump.instance_variables + adjustment.instance_variables.sort.must_equal adjustment_from_dump.instance_variables.sort end it 'must return the same values' do diff --git a/spec/recurly_v2/api/errors_spec.rb b/spec/recurly_v2/api/errors_spec.rb index 97553fc46..6dc630aa7 100644 --- a/spec/recurly_v2/api/errors_spec.rb +++ b/spec/recurly_v2/api/errors_spec.rb @@ -8,12 +8,12 @@ let(:error) { RecurlyV2::API::ResponseError.new nil, nil } it "must return nil" do - error.send(:xml).must_equal nil + error.send(:xml).must_be_nil end end describe "when response assigned" do - let(:response) { MiniTest::Mock.new } + let(:response) { Minitest::Mock.new } let(:error) { RecurlyV2::API::ResponseError.new nil, response } describe "when xml already cached" do @@ -28,7 +28,7 @@ before { response.expect :body, nil } it "must return nil" do - error.send(:xml).must_equal nil + error.send(:xml).must_be_nil end end @@ -36,7 +36,7 @@ before { 2.times { response.expect :body, '' } } it "must return nil" do - error.send(:xml).must_equal nil + error.send(:xml).must_be_nil end end @@ -54,7 +54,7 @@ before { 3.times { response.expect :body, html } } it "must return nil" do - error.send(:xml).must_equal nil + error.send(:xml).must_be_nil end end end diff --git a/spec/recurly_v2/billing_info_spec.rb b/spec/recurly_v2/billing_info_spec.rb index 394cf986f..b43432dc0 100644 --- a/spec/recurly_v2/billing_info_spec.rb +++ b/spec/recurly_v2/billing_info_spec.rb @@ -129,7 +129,7 @@ it "is accessible as an attribute" do billing_info_without_cc_bin_country = BillingInfo.find 'without-cc-bin' - billing_info_without_cc_bin_country.cc_bin_country.must_equal nil + billing_info_without_cc_bin_country.cc_bin_country.must_be_nil billing_info_with_cc_bin_country = BillingInfo.find 'with-cc-bin' billing_info_with_cc_bin_country.cc_bin_country.must_equal 'US' @@ -229,7 +229,7 @@ billing_info = BillingInfo.find 'abcdef1234567890' billing_info_from_dump = Marshal.load(Marshal.dump(billing_info)) - billing_info.instance_variables.must_equal billing_info_from_dump.instance_variables + billing_info.instance_variables.sort.must_equal billing_info_from_dump.instance_variables.sort end it 'must return the same values' do diff --git a/spec/recurly_v2/credit_payment_spec.rb b/spec/recurly_v2/credit_payment_spec.rb index fb795cb64..613670219 100644 --- a/spec/recurly_v2/credit_payment_spec.rb +++ b/spec/recurly_v2/credit_payment_spec.rb @@ -34,7 +34,7 @@ credit_payment = CreditPayment.find('12345') credit_payment_from_dump = Marshal.load(Marshal.dump(credit_payment)) - credit_payment.instance_variables.must_equal credit_payment_from_dump.instance_variables + credit_payment.instance_variables.sort.must_equal credit_payment_from_dump.instance_variables.sort end it 'must return the same values' do diff --git a/spec/recurly_v2/gift_card_spec.rb b/spec/recurly_v2/gift_card_spec.rb index 169800f00..d60e3a8cc 100644 --- a/spec/recurly_v2/gift_card_spec.rb +++ b/spec/recurly_v2/gift_card_spec.rb @@ -36,8 +36,8 @@ gift_card.balance_in_cents.must_equal 1_000 gift_card.currency.must_equal "USD" gift_card.created_at.must_equal DateTime.parse("2016-07-28T00:01:48Z") - gift_card.canceled_at.must_equal nil - gift_card.delivered_at.must_equal nil + gift_card.canceled_at.must_be_nil + gift_card.delivered_at.must_be_nil gift_card.id.must_equal 2004005808969875135 gift_card.product_code.must_equal "gift_card" gift_card.redeemed_at.must_equal DateTime.parse("2016-07-28T00:01:46Z") @@ -54,7 +54,7 @@ delivery.must_be_instance_of RecurlyV2::Delivery delivery.method.must_equal "email" - delivery.deliver_at.must_equal nil + delivery.deliver_at.must_be_nil delivery.email_address.must_equal "john@example.com" delivery.first_name.must_equal "John" delivery.last_name.must_equal "Smith" @@ -64,7 +64,7 @@ address = delivery.address address.address1.must_equal "400 Alabama St" - address.address2.must_equal nil + address.address2.must_be_nil address.city.must_equal "San Francisco" address.state.must_equal "CA" address.zip.must_equal "94110" diff --git a/spec/recurly_v2/resource_spec.rb b/spec/recurly_v2/resource_spec.rb index 2102673c5..3fb8b060c 100644 --- a/spec/recurly_v2/resource_spec.rb +++ b/spec/recurly_v2/resource_spec.rb @@ -569,12 +569,12 @@ def record.to_param() 1 end it "must return nil if persisted with changes" do record.persist! record[:uuid] = 'changed' - record.valid?.must_equal nil + record.valid?.must_be_nil end it "must return nil if not persisted with changes and no errors" do record[:uuid] = 'changed' - record.valid?.must_equal nil + record.valid?.must_be_nil end it "must return false if it has errors" do diff --git a/spec/recurly_v2/subscription_spec.rb b/spec/recurly_v2/subscription_spec.rb index 7ec9cdede..06dc8dcca 100644 --- a/spec/recurly_v2/subscription_spec.rb +++ b/spec/recurly_v2/subscription_spec.rb @@ -347,7 +347,7 @@ stub_api_request :get, 'subscriptions/abcdef1234567890', 'subscriptions/show-200-noinvoice' subscription = Subscription.find 'abcdef1234567890' - subscription.invoice.must_equal nil + subscription.invoice.must_be_nil end end end @@ -405,12 +405,12 @@ it "should be able to pause and resume a subscription" do sub = RecurlyV2::Subscription.find('abcdef1234567890') - sub.paused_at.must_equal nil + sub.paused_at.must_be_nil sub.pause(1).must_equal true sub.paused_at.must_be_instance_of DateTime sub.remaining_pause_cycles.must_equal 1 sub.resume.must_equal true - sub.remaining_pause_cycles.must_equal nil + sub.remaining_pause_cycles.must_be_nil end end diff --git a/spec/recurly_v2/transaction_spec.rb b/spec/recurly_v2/transaction_spec.rb index dea2a1bf1..19264af1b 100644 --- a/spec/recurly_v2/transaction_spec.rb +++ b/spec/recurly_v2/transaction_spec.rb @@ -62,7 +62,7 @@ transaction = Transaction.find 'abcdef1234567890' transaction_from_dump = Marshal.load(Marshal.dump(transaction)) - transaction.instance_variables.must_equal transaction_from_dump.instance_variables + transaction.instance_variables.sort.must_equal transaction_from_dump.instance_variables.sort end it 'must return the same values' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f43ae66d2..59a7c01b4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,6 +6,8 @@ require 'cgi' require 'minitest/autorun' require 'minitest/spec' +require 'minitest/global_expectations' +require 'minitest/mock' require 'webmock' WebMock.enable!