diff --git a/.ruby-version b/.ruby-version index a4dd9db..0aec50e 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.4 +3.1.4 diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..306ab33 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +ruby 3.1.4 diff --git a/Appraisals b/Appraisals index 32e1e98..3d589ab 100644 --- a/Appraisals +++ b/Appraisals @@ -1,7 +1,3 @@ -appraise "rails-6" do - gem "rails", "6.0.3.7" -end - appraise "rails-6-1" do gem "rails", "6.1.4" end diff --git a/CHANGELOG.md b/CHANGELOG.md index 65dfebb..dc1c4da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ _none_ +## 3.0.1 (2024-01-30) + +* Add `include_graphql_error` RSpec matcher + +## 3.0.0 (2024-01-30) + +**Changes** +* **(Breaking)** Drop support for Rails 6.0 +* **(Breaking)** Drop support for Ruby 2.7 + ## 2.2.0 (2024-01-15) **Changes** diff --git a/README.md b/README.md index 222ecec..c8a5346 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Help Nulogy applications be compliant with the [Standard on Error-handling in Gr Add this line to your application's Gemfile: ```ruby -gem "nulogy_graphql_api", "2.1.0" +gem "nulogy_graphql_api", "3.0.1" ``` And then execute: @@ -253,9 +253,7 @@ end #### Custom matchers -These are the custom matchers available: - -`have_graphql_data` for checking the response `data` +Use `have_graphql_data` for checking the response `data`. ```ruby expect(response).to have_graphql_data( @@ -265,12 +263,20 @@ expect(response).to have_graphql_data( ) ``` -`have_graphql_error` for checking the response `errors` +Use `have_graphql_error` for matching exactly on the response `errors`.
+The match succeeds when the `errors` array contains a single entry with the specified message. ```ruby expect(response).to have_graphql_error("Error message") ``` +Use `include_graphql_error` for matching inclusively on the response `errors`.
+The match succeeds when the `errors` array includes an entry with the specified message. + +```ruby +expect(response).to include_graphql_error("Error message") +``` + ## Development After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment. diff --git a/gemfiles/rails_6.gemfile b/gemfiles/rails_6.gemfile deleted file mode 100644 index ab7af82..0000000 --- a/gemfiles/rails_6.gemfile +++ /dev/null @@ -1,7 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rails", "6.0.3.7" - -gemspec path: "../" diff --git a/lib/nulogy_graphql_api/rspec/graphql_matchers.rb b/lib/nulogy_graphql_api/rspec/graphql_matchers.rb index 184b688..dc6c030 100644 --- a/lib/nulogy_graphql_api/rspec/graphql_matchers.rb +++ b/lib/nulogy_graphql_api/rspec/graphql_matchers.rb @@ -34,5 +34,13 @@ module GraphqlMatchers }) end end + + RSpec::Matchers.define :include_graphql_error do |message| + match do |actual_response| + expect(actual_response.fetch(:errors, nil)).to include(a_hash_including( + message: include(message) + )) + end + end end end diff --git a/lib/nulogy_graphql_api/version.rb b/lib/nulogy_graphql_api/version.rb index dbcbe6d..4e75de5 100644 --- a/lib/nulogy_graphql_api/version.rb +++ b/lib/nulogy_graphql_api/version.rb @@ -1,3 +1,3 @@ module NulogyGraphqlApi - VERSION = "2.2.0" + VERSION = "3.0.1" end diff --git a/nulogy_graphql_api.gemspec b/nulogy_graphql_api.gemspec index 952c93a..1c7df0e 100644 --- a/nulogy_graphql_api.gemspec +++ b/nulogy_graphql_api.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| "rubygems_mfa_required" => "true" } - spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0") + spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0") # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. @@ -31,7 +31,7 @@ Gem::Specification.new do |spec| spec.add_dependency "graphql", "~> 2" spec.add_dependency "graphql-schema_comparator", "~> 1.2" - spec.add_dependency "rails", ">= 6.0", "< 8.0" + spec.add_dependency "rails", ">= 6.1", "< 8.0" spec.add_dependency "rainbow", "~> 3.0" spec.add_development_dependency "appraisal", "~> 2.5"