artemis 0.8.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +21 -6
  3. data/Appraisals +21 -3
  4. data/CHANGELOG.md +35 -4
  5. data/artemis.gemspec +1 -1
  6. data/bin/console +3 -3
  7. data/gemfiles/graphql_2_0.gemfile +15 -0
  8. data/gemfiles/rails_60.gemfile +3 -3
  9. data/gemfiles/rails_71.gemfile +14 -0
  10. data/gemfiles/rails_edge.gemfile +1 -0
  11. data/lib/artemis/adapters/net_http_persistent_adapter.rb +6 -0
  12. data/lib/artemis/railtie.rb +1 -1
  13. data/lib/artemis/version.rb +1 -1
  14. data/spec/adapters_spec.rb +9 -2
  15. data/spec/autoloading_spec.rb +55 -49
  16. data/spec/callbacks_spec.rb +6 -6
  17. data/spec/client_spec.rb +84 -78
  18. data/spec/endpoint_spec.rb +11 -7
  19. data/spec/fixtures/github/_repository_fields.graphql +12 -0
  20. data/spec/fixtures/github/repository.graphql +6 -0
  21. data/spec/fixtures/github/schema.json +165225 -0
  22. data/spec/fixtures/github/user.graphql +6 -0
  23. data/spec/fixtures/github/user_repositories.graphql +13 -0
  24. data/spec/fixtures/github.rb +2 -0
  25. data/spec/fixtures/responses/github/repository.yml +17 -0
  26. data/spec/fixtures/responses/github/user.json +10 -0
  27. data/spec/spec_helper.rb +3 -3
  28. data/spec/test_helper_spec.rb +32 -32
  29. metadata +15 -13
  30. data/spec/fixtures/metaphysics/_artist_fields.graphql +0 -4
  31. data/spec/fixtures/metaphysics/artist.graphql +0 -7
  32. data/spec/fixtures/metaphysics/artists.graphql +0 -8
  33. data/spec/fixtures/metaphysics/artwork.graphql +0 -8
  34. data/spec/fixtures/metaphysics/schema.json +0 -49811
  35. data/spec/fixtures/metaphysics.rb +0 -2
  36. data/spec/fixtures/responses/metaphysics/artist.yml +0 -24
  37. data/spec/fixtures/responses/metaphysics/artwork.json +0 -12
@@ -0,0 +1,6 @@
1
+ query {
2
+ user(login: "yuki24") {
3
+ id
4
+ name
5
+ }
6
+ }
@@ -0,0 +1,13 @@
1
+ query($login: String!, $size: Int!) {
2
+ user(login: $login) {
3
+ id
4
+ name
5
+ repositories(first: $size) {
6
+ nodes {
7
+ name
8
+ description
9
+ ...Github::RepositoryFields
10
+ }
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,2 @@
1
+ class Github < Artemis::Client
2
+ end
@@ -0,0 +1,17 @@
1
+ yuki24_artemis:
2
+ data:
3
+ repository:
4
+ name: artemis
5
+ nameWithOwner: yuki24/artemis
6
+
7
+ yuki24_rambulance:
8
+ data:
9
+ repository:
10
+ name: rambulance
11
+ nameWithOwner: <%= "yuki24" %>/rambulance
12
+
13
+ yoshiki:
14
+ data:
15
+ repository:
16
+ name: did_you_mean
17
+ nameWithOwner: ruby/did_you_mean
@@ -0,0 +1,10 @@
1
+ {
2
+ "yuki24": {
3
+ "data": {
4
+ "user": {
5
+ "id": "foobar",
6
+ "name": "Yuki Nishijima"
7
+ }
8
+ }
9
+ }
10
+ }
data/spec/spec_helper.rb CHANGED
@@ -13,10 +13,10 @@ require 'pry-byebug' if RUBY_ENGINE == 'ruby'
13
13
  # tested, but we don't have any test setup for that yet.
14
14
  Artemis::Client.query_paths = [File.join(__dir__, 'fixtures')]
15
15
  Artemis::GraphQLEndpoint.suppress_warnings_on_schema_load = true
16
- Artemis::GraphQLEndpoint.register!(:metaphysics, adapter: :test, url: '', schema_path: 'spec/fixtures/metaphysics/schema.json')
17
- Artemis::GraphQLEndpoint.lookup(:metaphysics).load_schema!
16
+ Artemis::GraphQLEndpoint.register!(:github, adapter: :test, url: '', schema_path: 'spec/fixtures/github/schema.json')
17
+ Artemis::GraphQLEndpoint.lookup(:github).load_schema!
18
18
 
19
- require 'fixtures/metaphysics'
19
+ require 'fixtures/github'
20
20
 
21
21
  PROJECT_DIR = FileUtils.pwd
22
22
 
@@ -14,79 +14,79 @@ describe Artemis::TestHelper do
14
14
  end
15
15
 
16
16
  it "can mock a GraphQL request" do
17
- stub_graphql(Metaphysics, :artist).to_return(:yayoi_kusama)
17
+ stub_graphql(Github, :repository).to_return(:yuki24_artemis)
18
18
 
19
- response = Metaphysics.artist(id: "yayoi-kusama")
19
+ response = Github.repository(owner: "yuki24", name: "artemis")
20
20
 
21
- expect(response.data.artist.name).to eq("Yayoi Kusama")
22
- expect(response.data.artist.birthday).to eq("1929/03/22")
21
+ expect(response.data.repository.name).to eq("artemis")
22
+ expect(response.data.repository.name_with_owner).to eq("yuki24/artemis")
23
23
  end
24
24
 
25
25
  it "can mock a GraphQL request with an ERB-enabled fixture" do
26
- stub_graphql(Metaphysics, :artist).to_return(:yuki)
26
+ stub_graphql(Github, :repository).to_return(:yuki24_rambulance)
27
27
 
28
- response = Metaphysics.artist(id: "yuki")
28
+ response = Github.repository(owner: "yuki24", name: "rambulance")
29
29
 
30
- expect(response.data.artist.birthday).to eq("#{Date.today.year}/01/01")
30
+ expect(response.data.repository.name_with_owner).to eq("yuki24/rambulance")
31
31
  end
32
32
 
33
33
  it "can mock a GraphQL request with variables using exact match" do
34
- stub_graphql(Metaphysics, :artist, id: "yayoi-kusama").to_return(:yayoi_kusama)
35
- stub_graphql(Metaphysics, :artist, id: "leonardo-da-vinci").to_return(:leonardo_da_vinci)
34
+ stub_graphql(Github, :repository, owner: "yuki24", name: "artemis").to_return(:yuki24_artemis)
35
+ stub_graphql(Github, :repository, owner: "yuki24", name: "rambulance").to_return(:yuki24_rambulance)
36
36
 
37
- yayoi_kusama = Metaphysics.artist(id: "yayoi-kusama")
38
- da_vinci = Metaphysics.artist(id: "leonardo-da-vinci")
37
+ yuki24_artemis = Github.repository(owner: "yuki24", name: "artemis")
38
+ yuki24_rambulance = Github.repository(owner: "yuki24", name: "rambulance")
39
39
 
40
- expect(yayoi_kusama.data.artist.name).to eq("Yayoi Kusama")
41
- expect(da_vinci.data.artist.name).to eq("Leonardo da Vinci")
40
+ expect(yuki24_artemis.data.repository.name).to eq("artemis")
41
+ expect(yuki24_rambulance.data.repository.name).to eq("rambulance")
42
42
  end
43
43
 
44
44
  it "can mock a GraphQL request with a JSON file" do
45
- stub_graphql(Metaphysics, :artwork).to_return(:the_last_supper)
45
+ stub_graphql(Github, :user).to_return(:yuki24)
46
46
 
47
- response = Metaphysics.artwork(id: "leonardo-da-vinci-the-last-supper")
47
+ response = Github.user
48
48
 
49
- expect(response.data.artwork.title).to eq("The Last Supper")
50
- expect(response.data.artwork.artist.name).to eq("Leonardo da Vinci")
49
+ expect(response.data.user.id).to eq("foobar")
50
+ expect(response.data.user.name).to eq("Yuki Nishijima")
51
51
  end
52
52
 
53
53
  it "can mock a GraphQL request for a query that has a query name"
54
54
 
55
55
  it "raises an exception if the specified fixture file does not exist" do
56
- expect { stub_graphql(Metaphysics, :does_not_exist).to_return(:data) }
56
+ expect { stub_graphql(Github, :does_not_exist).to_return(:data) }
57
57
  .to raise_error(Artemis::FixtureNotFound, %r|does_not_exist.{yml,json}|)
58
58
  end
59
59
 
60
60
  it "raises an exception if the specified fixture file exists but fixture key does not exist" do
61
- expect { stub_graphql(Metaphysics, :artist).to_return(:does_not_exist) }
62
- .to raise_error(Artemis::FixtureNotFound, %r|spec/fixtures/responses/metaphysics/artist.yml|)
61
+ expect { stub_graphql(Github, :repository).to_return(:does_not_exist) }
62
+ .to raise_error(Artemis::FixtureNotFound, %r|spec/fixtures/responses/github/repository.yml|)
63
63
  end
64
64
 
65
- it "picks up the fixture for the given different service if multiple services have the exact same fixture" do
66
- stub_graphql(Metaphysics, :artist).to_return(:yoshiki)
65
+ it "picks up the fixture for the given service if multiple services have the exact same fixture" do
66
+ stub_graphql(Github, :repository).to_return(:yoshiki)
67
67
 
68
- yoshiki = Metaphysics.artist(id: "artist-yoshiki")
68
+ yoshiki = Github.repository(owner: "ruby", name: "did_you_mean")
69
69
 
70
- expect(yoshiki.data.artist.name).to eq("Artist Yoshiki")
70
+ expect(yoshiki.data.repository.name).to eq("did_you_mean")
71
71
  end
72
72
 
73
73
  it "can mock separate GraphQL queries with the same arguments" do
74
- stub_graphql("SpotifyClient", :artist, id: "yoshiki").to_return(:yoshiki)
75
- stub_graphql(Metaphysics, :artist, id: "yoshiki").to_return(:yoshiki)
74
+ stub_graphql("SpotifyClient", :repository, id: "yoshiki").to_return(:yoshiki)
75
+ stub_graphql(Github, :repository, id: "yoshiki").to_return(:yoshiki)
76
76
 
77
- yoshiki = Metaphysics.artist(id: "yoshiki")
77
+ yoshiki = Github.repository(id: "yoshiki")
78
78
 
79
- expect(yoshiki.data.artist.name).to eq("Artist Yoshiki")
79
+ expect(yoshiki.data.repository.name).to eq("did_you_mean")
80
80
  end
81
81
 
82
82
  it "allows to get raw fixture data as a Hash" do
83
- data = stub_graphql("SpotifyClient", :artist).get(:yoshiki)
83
+ data = stub_graphql("SpotifyClient", :repository).get(:yoshiki)
84
84
 
85
85
  expect(data).to eq({
86
86
  "data" => {
87
- "artist" => {
88
- "id" => "pianist-yoshiki",
89
- "name" => "Pianist Yoshiki"
87
+ "repository" => {
88
+ "name" => "did_you_mean",
89
+ "nameWithOwner" => "ruby/did_you_mean",
90
90
  }
91
91
  }
92
92
  })
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artemis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Allured
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-01-05 00:00:00.000000000 Z
12
+ date: 2024-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: '1.8'
48
+ version: '0'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: '1.8'
55
+ version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: graphql-client
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -162,12 +162,14 @@ files:
162
162
  - doc/CHANGELOG.md.erb
163
163
  - doc/changelog_generator.rb
164
164
  - gemfiles/.bundle/config
165
+ - gemfiles/graphql_2_0.gemfile
165
166
  - gemfiles/rails_50.gemfile
166
167
  - gemfiles/rails_51.gemfile
167
168
  - gemfiles/rails_52.gemfile
168
169
  - gemfiles/rails_60.gemfile
169
170
  - gemfiles/rails_61.gemfile
170
171
  - gemfiles/rails_70.gemfile
172
+ - gemfiles/rails_71.gemfile
171
173
  - gemfiles/rails_edge.gemfile
172
174
  - lib/artemis.rb
173
175
  - lib/artemis/adapters.rb
@@ -201,14 +203,14 @@ files:
201
203
  - spec/callbacks_spec.rb
202
204
  - spec/client_spec.rb
203
205
  - spec/endpoint_spec.rb
204
- - spec/fixtures/metaphysics.rb
205
- - spec/fixtures/metaphysics/_artist_fields.graphql
206
- - spec/fixtures/metaphysics/artist.graphql
207
- - spec/fixtures/metaphysics/artists.graphql
208
- - spec/fixtures/metaphysics/artwork.graphql
209
- - spec/fixtures/metaphysics/schema.json
210
- - spec/fixtures/responses/metaphysics/artist.yml
211
- - spec/fixtures/responses/metaphysics/artwork.json
206
+ - spec/fixtures/github.rb
207
+ - spec/fixtures/github/_repository_fields.graphql
208
+ - spec/fixtures/github/repository.graphql
209
+ - spec/fixtures/github/schema.json
210
+ - spec/fixtures/github/user.graphql
211
+ - spec/fixtures/github/user_repositories.graphql
212
+ - spec/fixtures/responses/github/repository.yml
213
+ - spec/fixtures/responses/github/user.json
212
214
  - spec/fixtures/responses/spotify_client/artist.yml
213
215
  - spec/spec_helper.rb
214
216
  - spec/test_helper_spec.rb
@@ -232,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
234
  - !ruby/object:Gem::Version
233
235
  version: '0'
234
236
  requirements: []
235
- rubygems_version: 3.3.7
237
+ rubygems_version: 3.5.3
236
238
  signing_key:
237
239
  specification_version: 4
238
240
  summary: GraphQL on Rails
@@ -1,4 +0,0 @@
1
- fragment on Artist {
2
- hometown
3
- deathday
4
- }
@@ -1,7 +0,0 @@
1
- query($id: String!) {
2
- artist(id: $id) {
3
- name
4
- bio
5
- birthday
6
- }
7
- }
@@ -1,8 +0,0 @@
1
- query($size: Int!) {
2
- artists(size: $size) {
3
- name
4
- bio
5
- birthday
6
- ...Metaphysics::ArtistFields
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- query {
2
- artwork(id: "yayoi-kusama-pumpkin-yellow-and-black") {
3
- title
4
- artist {
5
- name
6
- }
7
- }
8
- }