From 5f87a5bf70efdc0f20c69cbd703b6c1fc410339a Mon Sep 17 00:00:00 2001 From: Bogdan Pozderca Date: Tue, 19 Nov 2024 15:22:32 -0600 Subject: [PATCH] Bump gems and support rails < 8 --- .github/workflows/ruby.yml | 6 +++--- .ruby-version | 1 + jsonapi-matchers.gemspec | 10 +++++----- lib/jsonapi/matchers/version.rb | 2 +- spec/jsonapi/attributes_included_spec.rb | 18 +++++++++--------- spec/jsonapi/record_included_spec.rb | 5 +---- 6 files changed, 20 insertions(+), 22 deletions(-) create mode 100644 .ruby-version diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 6d718b6..6343ba7 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -19,11 +19,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Ruby - uses: ruby/setup-ruby@v1.152.0 + uses: ruby/setup-ruby@v1.202.0 with: - ruby-version: 3.1.4 + ruby-version: 3.3.6 bundler-cache: true - name: Install dependencies run: bundle install diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..97ceee1 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.1.5 \ No newline at end of file diff --git a/jsonapi-matchers.gemspec b/jsonapi-matchers.gemspec index 3d3c2c6..055ea60 100644 --- a/jsonapi-matchers.gemspec +++ b/jsonapi-matchers.gemspec @@ -18,14 +18,14 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.required_ruby_version = ">= 2.7.7" + spec.required_ruby_version = ">= 3.1.5" - spec.add_dependency "activesupport", ">= 4.0", "< 7.1" + spec.add_dependency "activesupport", ">= 7.0", "< 8" spec.add_dependency "awesome_print" - spec.add_development_dependency "bump", "~> 0.9.0" + spec.add_development_dependency "bump", "~> 0.10.0" spec.add_development_dependency "bundler" - spec.add_development_dependency "rake", "~> 13.0" - spec.add_development_dependency "rspec", "~> 3.0" + spec.add_development_dependency "rake", "~> 13.2" + spec.add_development_dependency "rspec", "~> 3.13" spec.add_development_dependency "pry" end diff --git a/lib/jsonapi/matchers/version.rb b/lib/jsonapi/matchers/version.rb index 6560c18..b5abead 100644 --- a/lib/jsonapi/matchers/version.rb +++ b/lib/jsonapi/matchers/version.rb @@ -1,5 +1,5 @@ module Jsonapi module Matchers - VERSION = "1.1.0" + VERSION = "1.2.0" end end diff --git a/spec/jsonapi/attributes_included_spec.rb b/spec/jsonapi/attributes_included_spec.rb index 76db731..c9ebdba 100644 --- a/spec/jsonapi/attributes_included_spec.rb +++ b/spec/jsonapi/attributes_included_spec.rb @@ -265,14 +265,14 @@ describe 'with_record' do context 'record exists' do - let(:record) { OpenStruct.new(id: 'some-car-id') } + let(:record) { Struct.new(:id).new('some-car-id') } it 'matches' do expect(have_relationship(:car).with_record(record).matches?(target)).to be_truthy end context 'the record id is not a string' do - let(:record) { OpenStruct.new(id: 3) } + let(:record) { Struct.new(:id).new(3) } it 'matches' do expect(have_relationship(:bike).with_record(record).matches?(target)).to be_truthy @@ -281,7 +281,7 @@ end context 'record id does not match' do - let(:record) { OpenStruct.new(id: 'not-the-right-car-id') } + let(:record) { Struct.new(:id).new('not-the-right-car-id') } subject { have_relationship(:car).with_record(record) } @@ -296,14 +296,14 @@ end context 'relationship is array and it matches' do - let(:record) { OpenStruct.new(id: 'some-chair-id-1') } + let(:record) { Struct.new(:id).new('some-chair-id-1') } it 'matches' do expect(have_relationship(:chairs).with_record(record).matches?(target)).to be_truthy end context 'the record id is not a string' do - let(:record) { OpenStruct.new(id: 4) } + let(:record) { Struct.new(:id).new(4) } it 'matches' do expect(have_relationship(:telephones).with_record(record).matches?(target)).to be_truthy @@ -312,7 +312,7 @@ end context 'relationship is array and it does not match' do - let(:record) { OpenStruct.new(id: 'some-chair-id-3') } + let(:record) { Struct.new(:id).new('some-chair-id-3') } subject { have_relationship(:chairs).with_record(record) } @@ -327,7 +327,7 @@ end context 'relationship does not have an id attribute' do - let(:record) { OpenStruct.new(id: 'some-chair-id-1') } + let(:record) { Struct.new(:id).new('some-chair-id-1') } subject { have_relationship(:house).with_record(record) } @@ -342,7 +342,7 @@ end context 'relationship is nil' do - let(:record) { OpenStruct.new(id: 'some-chair-id-1') } + let(:record) { Struct.new(:id).new('some-chair-id-1') } subject { have_relationship(:plane).with_record(record) } @@ -357,7 +357,7 @@ end context 'relationship does not exist' do - let(:record) { OpenStruct.new(id: 'some-chair-id-1') } + let(:record) { Struct.new(:id).new('some-chair-id-1') } subject { have_relationship(:does_not_exist).with_record(record) } diff --git a/spec/jsonapi/record_included_spec.rb b/spec/jsonapi/record_included_spec.rb index e9ca6bd..d8784ea 100644 --- a/spec/jsonapi/record_included_spec.rb +++ b/spec/jsonapi/record_included_spec.rb @@ -27,16 +27,13 @@ let(:subject) { have_record(record) } let(:response) { ActionDispatch::TestResponse.new(response_data) } let(:response_data) { '{' } - let(:architecture) { `uname -m`.strip } - let(:arm_expectation) { /Expected response to be json string but was \"{\". JSON::ParserError - unexpected token at '{'/ } - let(:linux_expectation) { /Expected response to be json string but was \"{\". JSON::ParserError - \d\d\d: unexpected token at '{'/ } + let(:expectation) { /Expected response to be json string but was \"{\". JSON::ParserError - unexpected token at '{'/ } before do subject.matches?(response) end it 'tells you that the response body is not json' do - expectation = architecture == 'arm64' ? arm_expectation : linux_expectation expect(subject.failure_message).to match(expectation) end end