graphiti_spec_helpers 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a00691315a444a8df06833ae41d8c7429b3bb259e18f1913cdc160733a08123
4
- data.tar.gz: 6ed313ef3a0578d01b1714c663b269a5a3c3bac0d1ae8f7a95a0f42dc4ffcbae
3
+ metadata.gz: 43dd11cb4400aec41c9a7013c755d24396866d1d62817b127dae4d36475e9606
4
+ data.tar.gz: 2303af152ed9d8fbbf065fa3b4b60fb8d48c69505507649d52c5a090e21a1cf1
5
5
  SHA512:
6
- metadata.gz: c74d21897b216b6a39f54fd29da8e85664f43e931499fa32c08af145fba2863f31f07ea16de8bf63c4b36093e0568e8434b4531e793517a56942a3f009ebbc4e
7
- data.tar.gz: ebeef28459f67952117255eac8c9871b6ee77ffd64da610fbf32408fee3ce5c1da6610f143270e608daef8e9421212ca207053a1ce84d5f9aff9ba7ac92ff86c
6
+ metadata.gz: 469b7d05f8aca9bbb20d4ead66ecc387c983fbbb6e5a877afd3fbe7e3dd44594e5135283ba1968add3ac91f9d8d623206a62280e72b18cea0422d920e07fd6a4
7
+ data.tar.gz: 48ceb92f4b45580be992d41f09e0f173b5bc96524892131a5ba250da3bd9214c9f7c9f9c6b0eaf0a6664c2eb5f96d6b30e6da4c8b3bcd1aff6bb83cd14bf6020
@@ -0,0 +1,39 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request: {}
7
+ workflow_dispatch: {}
8
+
9
+ concurrency:
10
+ group: ci-${{ github.head_ref || github.ref }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ ruby: [ 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, head ]
21
+
22
+ steps:
23
+ - uses: actions/checkout@v3
24
+ - uses: ruby/setup-ruby@v1
25
+ with:
26
+ bundler-cache: true
27
+ ruby-version: ${{ matrix.ruby }}
28
+ - run: bundle exec rake
29
+ publish:
30
+ name: Release
31
+ runs-on: ubuntu-latest
32
+ if: github.ref == 'refs/heads/main'
33
+ needs: [test]
34
+ steps:
35
+ - name: Dispatch Release
36
+ uses: benc-uk/workflow-dispatch@v1
37
+ with:
38
+ workflow: Generate New Release
39
+ token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: Generate New Release
3
+
4
+ on:
5
+ workflow_dispatch:
6
+
7
+ concurrency:
8
+ group: ci-${{ github.head_ref || github.ref }}
9
+ cancel-in-progress: true
10
+
11
+ jobs:
12
+ release:
13
+ name: Release
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Checkout
17
+ uses: actions/checkout@v3
18
+ with:
19
+ submodules: true
20
+ persist-credentials: false
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: "3.1"
25
+ - name: Build
26
+ run: |
27
+ gem install bundler
28
+ git submodule update --init --recursive
29
+ bundle install --jobs 4 --retry 3
30
+ - name: Setup Node.js
31
+ uses: actions/setup-node@v2
32
+ with:
33
+ node-version: 14
34
+ - name: Install Dependencies
35
+ run: yarn install --frozen-lockfile
36
+ - name: Release
37
+ env:
38
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39
+ GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
40
+ run: node_modules/.bin/semantic-release
41
+
data/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ graphiti changelog
2
+
3
+ ## [1.2.1](https://github.com/graphiti-api/graphiti_spec_helpers/compare/v1.2.0...v1.2.1) (2026-08-07)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * cap the graphiti dependency below 2.0 ([99db596](https://github.com/graphiti-api/graphiti_spec_helpers/commit/99db5964c1eb6fef583922c03df5ab951a7c1eb4))
9
+
10
+ # [1.2.0](https://github.com/graphiti-api/graphiti_spec_helpers/compare/v1.1.0...v1.2.0) (2025-03-18)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * allow current_user and params to remain lazy in rspec contexts ([#25](https://github.com/graphiti-api/graphiti_spec_helpers/issues/25)) ([6ce1e07](https://github.com/graphiti-api/graphiti_spec_helpers/commit/6ce1e07bbbcfd8d692d496f2acc6a740ebf9812c))
16
+ * jsonapi_included helper may accept symbol keys ([#20](https://github.com/graphiti-api/graphiti_spec_helpers/issues/20)) ([cc3cb2d](https://github.com/graphiti-api/graphiti_spec_helpers/commit/cc3cb2d2dfacad323ae7107b0392c03ebf12e2eb))
17
+ * require rspec-core as a dependency of the matchers ([0ea2a92](https://github.com/graphiti-api/graphiti_spec_helpers/commit/0ea2a92d9c8f035c45558f79caaf96737959bfef))
18
+
19
+
20
+ ### Features
21
+
22
+ * alias Node#key? to Node#has_key? ([#24](https://github.com/graphiti-api/graphiti_spec_helpers/issues/24)) ([202aecb](https://github.com/graphiti-api/graphiti_spec_helpers/commit/202aecb6f4637d6f7e3d370e0b5d28a275b7ec1a))
23
+ * Allow passing AR records to jsonapi_* http operations ([#22](https://github.com/graphiti-api/graphiti_spec_helpers/issues/22)) ([c5e4b23](https://github.com/graphiti-api/graphiti_spec_helpers/commit/c5e4b235e79a663014e11720c764992d25caceff))
24
+ * Support matching against RSpec's`include` builtin ([#23](https://github.com/graphiti-api/graphiti_spec_helpers/issues/23)) ([1ed6fd0](https://github.com/graphiti-api/graphiti_spec_helpers/commit/1ed6fd0a561a43af604821821c569d819e6dff5f))
data/Gemfile CHANGED
@@ -1,4 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem "mutex_m" # Ruby 3.4 no longer includes this
4
+ gem "base64"
5
+ gem "ostruct" # Ruby 3.5 no longer includes this
6
+
3
7
  # Specify your gem's dependencies in graphiti_spec_helpers.gemspec
4
- gemspec
8
+ gemspec
data/README.md CHANGED
@@ -1,6 +1,39 @@
1
1
  # GraphitiSpecHelpers
2
2
 
3
3
  ![Build Status](https://travis-ci.org/graphiti-api/graphiti_spec_helpers.svg?branch=master)
4
+ [![Gem Version](https://badge.fury.io/rb/graphiti_spec_helpers.svg)](https://badge.fury.io/rb/graphiti_spec_helpers)
4
5
 
5
6
  Spec helpers for [Graphiti](https://github.com/graphiti-api/graphiti)
6
7
  APIs.
8
+
9
+ # Installation
10
+ Note: this assumes you have [rspec-rails](https://github.com/rspec/rspec-rails) installed & configured already.
11
+
12
+ `Gemfile`
13
+ ```ruby
14
+ group :development, :test do
15
+ # ...
16
+ gem 'graphiti_spec_helpers', '~> 1.1'
17
+ # ...
18
+ end
19
+ ```
20
+
21
+ `spec/rails_helper.rb`
22
+ ```ruby
23
+ # ...
24
+ # Add additional requires below this line. Rails is not loaded until this point!
25
+ require 'graphiti_spec_helpers/rspec'
26
+ # ...
27
+
28
+ RSpec.configure do |config|
29
+ # ...
30
+ config.include GraphitiSpecHelpers::RSpec
31
+ config.include GraphitiSpecHelpers::Sugar
32
+ config.include Graphiti::Rails::TestHelpers
33
+ # ...
34
+ ```
35
+
36
+ Then in your project directory
37
+ ```sh
38
+ $ bundle install
39
+ ```
@@ -13,17 +13,24 @@ Gem::Specification.new do |spec|
13
13
  spec.description = %q{Easily test JSONAPIs and Graphiti Resources}
14
14
  spec.license = "MIT"
15
15
 
16
+ spec.post_install_message = <<~MESSAGE
17
+ graphiti_spec_helpers is part of graphiti as of 2.0 and is no longer released separately.
18
+
19
+ Remove it from your Gemfile. The "graphiti_spec_helpers/rspec" require and the GraphitiSpecHelpers namespace are unchanged.
20
+
21
+ https://graphiti.dev/upgrading
22
+ MESSAGE
23
+
16
24
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
25
  spec.bindir = "exe"
18
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
27
  spec.require_paths = ["lib"]
20
28
 
21
- spec.add_dependency "graphiti", '>= 1.0.alpha.1'
29
+ spec.add_dependency "graphiti", '>= 1.0.alpha.1', '< 2'
30
+ spec.add_dependency "rspec", "~> 3.0"
22
31
 
23
32
  spec.add_development_dependency "pry"
24
33
  spec.add_development_dependency "pry-byebug"
25
34
  spec.add_development_dependency "actionpack", "~> 5.0"
26
- spec.add_development_dependency "bundler", "~> 1.11"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_dependency "rspec", "~> 3.0"
35
+ spec.add_development_dependency "rake", "~> 13"
29
36
  end
@@ -27,7 +27,7 @@ module GraphitiSpecHelpers
27
27
 
28
28
  nodes = _jsonapi_included.map { |i| node(from: i) }
29
29
  if type
30
- nodes.select! { |n| n.jsonapi_type == type }
30
+ nodes.select! { |n| n.jsonapi_type == type.to_s }
31
31
  end
32
32
  instance_variable_set(variable, nodes)
33
33
  nodes
@@ -50,23 +50,23 @@ module GraphitiSpecHelpers
50
50
  end
51
51
 
52
52
  def jsonapi_get(url, params: {}, headers: {})
53
- get url, params: params, headers: jsonapi_headers.merge(headers)
53
+ get url_for(url), params: params, headers: jsonapi_headers.merge(headers)
54
54
  end
55
55
 
56
56
  def jsonapi_post(url, payload, headers: {})
57
- post url, params: payload.to_json, headers: jsonapi_headers.merge(headers)
57
+ post url_for(url), params: payload.to_json, headers: jsonapi_headers.merge(headers)
58
58
  end
59
59
 
60
60
  def jsonapi_put(url, payload, headers: {})
61
- put url, params: payload.to_json, headers: jsonapi_headers.merge(headers)
61
+ put url_for(url), params: payload.to_json, headers: jsonapi_headers.merge(headers)
62
62
  end
63
63
 
64
64
  def jsonapi_patch(url, payload, headers: {})
65
- patch url, params: payload.to_json, headers: jsonapi_headers.merge(headers)
65
+ patch url_for(url), params: payload.to_json, headers: jsonapi_headers.merge(headers)
66
66
  end
67
67
 
68
68
  def jsonapi_delete(url, headers: {})
69
- delete url, headers: jsonapi_headers.merge(headers)
69
+ delete url_for(url), headers: jsonapi_headers.merge(headers)
70
70
  end
71
71
 
72
72
  def json_datetime(value)
@@ -27,6 +27,7 @@ module GraphitiSpecHelpers
27
27
  def has_key?(key)
28
28
  @attributes.has_key?(key)
29
29
  end
30
+ alias :key? :has_key?
30
31
 
31
32
  def [](key)
32
33
  @attributes[key] || @attributes[key.to_s]
@@ -39,6 +40,7 @@ module GraphitiSpecHelpers
39
40
  def attributes
40
41
  @attributes
41
42
  end
43
+ alias :to_hash :attributes
42
44
 
43
45
  def method_missing(id, *args, &blk)
44
46
  if @attributes.has_key?(id)
@@ -1,8 +1,35 @@
1
+ require 'rspec/core'
1
2
  require 'graphiti_spec_helpers'
2
3
 
3
- ::RSpec.shared_context 'resource testing', type: :resource do |parameter|
4
- let(:resource) { described_class }
5
- let(:params) { {} }
4
+ class GraphitiContextProxy < OpenStruct
5
+ def initialize(proxied, *args)
6
+ @__proxied = proxied
7
+ super(*args)
8
+ end
9
+
10
+ # variables defined in the rspec context should remain lazy
11
+ def current_user
12
+ super || __proxied_current_user
13
+ end
14
+
15
+ def params
16
+ super || __proxied_params
17
+ end
18
+
19
+ private
20
+
21
+ def __proxied_current_user
22
+ @__proxied.current_user if @__proxied.respond_to?(:current_user)
23
+ end
24
+
25
+ def __proxied_params
26
+ @__proxied.params if @__proxied.respond_to?(:params)
27
+ end
28
+ end
29
+
30
+ ::RSpec.shared_context "resource testing", type: :resource do |parameter|
31
+ let(:resource) { described_class }
32
+ let(:params) { {} }
6
33
 
7
34
  around do |e|
8
35
  begin
@@ -18,12 +45,7 @@ require 'graphiti_spec_helpers'
18
45
  end
19
46
 
20
47
  def graphiti_context
21
- @graphiti_context ||= begin
22
- ctx = OpenStruct.new
23
- ctx.current_user = current_user if respond_to?(:current_user)
24
- ctx.params = params
25
- ctx
26
- end
48
+ @graphiti_context ||= GraphitiContextProxy.new(self)
27
49
  end
28
50
 
29
51
  # If you need to set context:
@@ -54,7 +76,7 @@ require 'graphiti_spec_helpers'
54
76
  end
55
77
  end
56
78
 
57
- RSpec.shared_context 'remote api' do
79
+ ::RSpec.shared_context 'remote api' do
58
80
  # Fake request headers
59
81
  around do |e|
60
82
  ctx = OpenStruct.new \
@@ -1,3 +1,3 @@
1
1
  module GraphitiSpecHelpers
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.1"
3
3
  end
data/package.json ADDED
@@ -0,0 +1,111 @@
1
+ {
2
+ "name": "graphiti_spec_helpers",
3
+ "version": "1.1.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/graphiti-api/graphiti_spec_helpers.git"
7
+ },
8
+ "license": "MIT",
9
+ "bugs": {
10
+ "url": "https://github.com/graphiti-api/graphiti_spec_helpers/issues"
11
+ },
12
+ "homepage": "https://github.com/graphiti-api/graphiti_spec_helpers",
13
+ "scripts": {
14
+ "semantic-release": "semantic-release"
15
+ },
16
+ "devDependencies": {
17
+ "semantic-release-rubygem": "^1.2.0",
18
+ "semantic-release": "^19.0.3",
19
+ "@semantic-release/changelog": "^6.0.1",
20
+ "@semantic-release/git": "^10.0.1"
21
+ },
22
+ "release": {
23
+ "branches": [
24
+ "main",
25
+ {
26
+ "name": "beta",
27
+ "prerelease": true
28
+ },
29
+ {
30
+ "name": "alpha",
31
+ "prerelease": true
32
+ }
33
+ ],
34
+ "plugins": [
35
+ [
36
+ "@semantic-release/commit-analyzer",
37
+ {
38
+ "releaseRules": [
39
+ {
40
+ "type": "*!",
41
+ "release": "major"
42
+ },
43
+ {
44
+ "type": "feat",
45
+ "release": "minor"
46
+ },
47
+ {
48
+ "type": "build",
49
+ "release": "patch"
50
+ },
51
+ {
52
+ "type": "ci",
53
+ "release": "patch"
54
+ },
55
+ {
56
+ "type": "chore",
57
+ "release": "patch"
58
+ },
59
+ {
60
+ "type": "docs",
61
+ "release": "patch"
62
+ },
63
+ {
64
+ "type": "refactor",
65
+ "release": "patch"
66
+ },
67
+ {
68
+ "type": "style",
69
+ "release": "patch"
70
+ },
71
+ {
72
+ "type": "test",
73
+ "release": "patch"
74
+ }
75
+ ],
76
+ "parserOpts": {
77
+ "noteKeywords": [
78
+ "BREAKING CHANGE",
79
+ "BREAKING CHANGES",
80
+ "BREAKING",
81
+ "BREAKING CHANGE!",
82
+ "BREAKING CHANGES!",
83
+ "BREAKING!"
84
+ ]
85
+ }
86
+ }
87
+ ],
88
+ "@semantic-release/release-notes-generator",
89
+ [
90
+ "@semantic-release/changelog",
91
+ {
92
+ "changelogTitle": "graphiti changelog",
93
+ "changelogFile": "CHANGELOG.md"
94
+ }
95
+ ],
96
+ "semantic-release-rubygem",
97
+ "@semantic-release/github",
98
+ [
99
+ "@semantic-release/git",
100
+ {
101
+ "assets": [
102
+ "CHANGELOG.md"
103
+ ],
104
+ "message": "${nextRelease.version} CHANGELOG [skip ci]\n\n${nextRelease.notes}"
105
+ }
106
+ ]
107
+ ],
108
+ "debug": true,
109
+ "dryRun": false
110
+ }
111
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti_spec_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-28 00:00:00.000000000 Z
11
+ date: 2026-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphiti
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.0.alpha.1
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,23 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 1.0.alpha.1
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.0'
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: pry
29
49
  requirement: !ruby/object:Gem::Requirement
@@ -66,48 +86,20 @@ dependencies:
66
86
  - - "~>"
67
87
  - !ruby/object:Gem::Version
68
88
  version: '5.0'
69
- - !ruby/object:Gem::Dependency
70
- name: bundler
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.11'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.11'
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: rake
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
93
  - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: '10.0'
95
+ version: '13'
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
100
  - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: '10.0'
97
- - !ruby/object:Gem::Dependency
98
- name: rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '3.0'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '3.0'
102
+ version: '13'
111
103
  description: Easily test JSONAPIs and Graphiti Resources
112
104
  email:
113
105
  - lrichmond1@bloomberg.net
@@ -115,9 +107,11 @@ executables: []
115
107
  extensions: []
116
108
  extra_rdoc_files: []
117
109
  files:
110
+ - ".github/workflows/ci.yml"
111
+ - ".github/workflows/release.yml"
118
112
  - ".gitignore"
119
113
  - ".rspec"
120
- - ".travis.yml"
114
+ - CHANGELOG.md
121
115
  - Gemfile
122
116
  - LICENSE.txt
123
117
  - README.md
@@ -133,11 +127,17 @@ files:
133
127
  - lib/graphiti_spec_helpers/node.rb
134
128
  - lib/graphiti_spec_helpers/rspec.rb
135
129
  - lib/graphiti_spec_helpers/version.rb
130
+ - package.json
136
131
  homepage:
137
132
  licenses:
138
133
  - MIT
139
134
  metadata: {}
140
- post_install_message:
135
+ post_install_message: |
136
+ graphiti_spec_helpers is part of graphiti as of 2.0 and is no longer released separately.
137
+
138
+ Remove it from your Gemfile. The "graphiti_spec_helpers/rspec" require and the GraphitiSpecHelpers namespace are unchanged.
139
+
140
+ https://graphiti.dev/upgrading
141
141
  rdoc_options: []
142
142
  require_paths:
143
143
  - lib
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  requirements: []
155
- rubygems_version: 3.2.22
155
+ rubygems_version: 3.3.27
156
156
  signing_key:
157
157
  specification_version: 4
158
158
  summary: Spec helpers for Graphiti and JSONAPI
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.6.3
4
- before_install: gem install bundler -v 1.11.2