diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ae48ec1..eececa9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest ] - ruby-version: ['3.0', '3.1', '3.2'] + ruby-version: ['3.0', '3.1', '3.2', '3.3', '3.4'] runs-on: ${{ matrix.os }} diff --git a/test/safe/explain_test.rb b/test/safe/explain_test.rb index 907683c..b2b5f38 100644 --- a/test/safe/explain_test.rb +++ b/test/safe/explain_test.rb @@ -1,10 +1,12 @@ # typed: strict require "test_helper" +require "support/version_helper" class ExplainTest < Minitest::Test include Mocktail::DSL extend T::Sig + include VersionHelper class Thing extend T::Sig @@ -41,7 +43,7 @@ def test_explain_stub_returned_nil The call site: - #{__FILE__}:25:in `test_explain_stub_returned_nil' + #{__FILE__}:27:in #{at_least_ruby_3_4? ? "'ExplainTest#" : "`"}test_explain_stub_returned_nil' No stubbings were configured on this method. @@ -75,7 +77,7 @@ def test_explain_stub_returned_nil_with_stubbings The call site: - #{__FILE__}:56:in `test_explain_stub_returned_nil_with_stubbings' + #{__FILE__}:58:in #{at_least_ruby_3_4? ? "'ExplainTest#" : "`"}test_explain_stub_returned_nil_with_stubbings' Stubbings configured prior to this call but not satisfied by it: diff --git a/test/support/version_helper.rb b/test/support/version_helper.rb new file mode 100644 index 0000000..770b28d --- /dev/null +++ b/test/support/version_helper.rb @@ -0,0 +1,11 @@ +# typed: false + +module VersionHelper + def ruby_version + Gem::Version.new(RUBY_VERSION) + end + + def at_least_ruby_3_4? + ruby_version >= "3.4" + end +end diff --git a/test/unit/verifies_call/raises_verification_error/stringifies_call_test.rb b/test/unit/verifies_call/raises_verification_error/stringifies_call_test.rb index e66e374..e6aa4db 100644 --- a/test/unit/verifies_call/raises_verification_error/stringifies_call_test.rb +++ b/test/unit/verifies_call/raises_verification_error/stringifies_call_test.rb @@ -1,10 +1,12 @@ # typed: strict require "test_helper" +require "support/version_helper" module Mocktail class StringifiesCallTest < Minitest::Test extend T::Sig + include VersionHelper sig { params(name: String).void } def initialize(name) @@ -33,21 +35,32 @@ def test_some_calls assert_equal "hi([], [1], [[2]], [[3, 4], [5, 6]])", invoke(args: [ [], [1], [[2]], [[3, 4], [5, 6]] ]) - assert_equal "hi({}, {:a=>1}, {:b=>2, :c=>3}, {:d=>[4, {:e=>5}]})", invoke(args: [ - {}, {a: 1}, {b: 2, c: 3}, {d: [4, {e: 5}]} - ]) + + if at_least_ruby_3_4? + assert_equal "hi({}, {a: 1}, {b: 2, c: 3}, {d: [4, {e: 5}]})", invoke(args: [ + {}, {a: 1}, {b: 2, c: 3}, {d: [4, {e: 5}]} + ]) + else + assert_equal "hi({}, {:a=>1}, {:b=>2, :c=>3}, {:d=>[4, {:e=>5}]})", invoke(args: [ + {}, {a: 1}, {b: 2, c: 3}, {d: [4, {e: 5}]} + ]) + end # Kwargs assert_equal "hi(a: 1)", invoke(kwargs: {a: 1}) assert_equal "hi(c: 2, b: 3)", invoke(kwargs: {c: 2, b: 3}) - assert_equal "hi(d: {:e=>4}, f: [:g, {:h=>5}])", invoke(kwargs: {d: {e: 4}, f: [:g, {h: 5}]}) + if at_least_ruby_3_4? + assert_equal "hi(d: {e: 4}, f: [:g, {h: 5}])", invoke(kwargs: {d: {e: 4}, f: [:g, {h: 5}]}) + else + assert_equal "hi(d: {:e=>4}, f: [:g, {:h=>5}])", invoke(kwargs: {d: {e: 4}, f: [:g, {h: 5}]}) + end # Blocks & Procs - assert_equal "hi { Proc at test/unit/verifies_call/raises_verification_error/stringifies_call_test.rb:46 }", invoke {} - assert_equal "hi(&lambda[test/unit/verifies_call/raises_verification_error/stringifies_call_test.rb:47])", invoke(&lambda {}) + assert_equal "hi { Proc at test/unit/verifies_call/raises_verification_error/stringifies_call_test.rb:59 }", invoke {} + assert_equal "hi(&lambda[test/unit/verifies_call/raises_verification_error/stringifies_call_test.rb:60])", invoke(&lambda {}) # Mix & Match - assert_equal "hi(:a, 1, b: 2) { Proc at test/unit/verifies_call/raises_verification_error/stringifies_call_test.rb:50 }", invoke(args: [:a, 1], kwargs: {b: 2}) { |c| 3 } + assert_equal "hi(:a, 1, b: 2) { Proc at test/unit/verifies_call/raises_verification_error/stringifies_call_test.rb:63 }", invoke(args: [:a, 1], kwargs: {b: 2}) { |c| 3 } end private