artemis 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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: 0.9.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: 2023-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -43,16 +43,16 @@ dependencies:
43
43
  name: graphql
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - "<"
47
47
  - !ruby/object:Gem::Version
48
- version: '1.8'
48
+ version: '2.1'
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: '2.1'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: graphql-client
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -168,6 +168,7 @@ files:
168
168
  - gemfiles/rails_60.gemfile
169
169
  - gemfiles/rails_61.gemfile
170
170
  - gemfiles/rails_70.gemfile
171
+ - gemfiles/rails_71.gemfile
171
172
  - gemfiles/rails_edge.gemfile
172
173
  - lib/artemis.rb
173
174
  - lib/artemis/adapters.rb
@@ -201,14 +202,14 @@ files:
201
202
  - spec/callbacks_spec.rb
202
203
  - spec/client_spec.rb
203
204
  - 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
205
+ - spec/fixtures/github.rb
206
+ - spec/fixtures/github/_repository_fields.graphql
207
+ - spec/fixtures/github/repository.graphql
208
+ - spec/fixtures/github/schema.json
209
+ - spec/fixtures/github/user.graphql
210
+ - spec/fixtures/github/user_repositories.graphql
211
+ - spec/fixtures/responses/github/repository.yml
212
+ - spec/fixtures/responses/github/user.json
212
213
  - spec/fixtures/responses/spotify_client/artist.yml
213
214
  - spec/spec_helper.rb
214
215
  - spec/test_helper_spec.rb
@@ -232,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
233
  - !ruby/object:Gem::Version
233
234
  version: '0'
234
235
  requirements: []
235
- rubygems_version: 3.3.7
236
+ rubygems_version: 3.4.19
236
237
  signing_key:
237
238
  specification_version: 4
238
239
  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
- }