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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be41d5677f98282ad274f675f696c6d092fb7d0279d8986492a615e81c024d93
4
- data.tar.gz: d9877242e814d7c20b24b217eb2a3c762699ae21d69ddf1e926e762c79854e59
3
+ metadata.gz: 67885289ab96c6ee04586b1c448bfa3832ecdb6b8ce2b28726d988a24801aee4
4
+ data.tar.gz: 788127f71e696536fd2f6e2076f97f2bb8af6d9374af5760782da12c85005660
5
5
  SHA512:
6
- metadata.gz: 3c16b35fa42042a378ea42920155fd4ea35d1289f65868be9883a50d3ba5dfd329978ea24847f4de4372c585bdb351ab8f4a6c65072fa7d49013d9948d5f08ed
7
- data.tar.gz: a6c6034a1b524165b193a5dc96efa60a4516aa28a36fbb0a16b5fdec5bdcb868d4142f97c756cb62cfc46926d14de8aaf233b7c1876627e5806366088c898f57
6
+ metadata.gz: e4099922005bf7f838d9e6147253b8403b9381fa5ea7c29a1317045b64c8cbe08e2bcc8ea0060ff60da41b7fba9325f47cce079ae1c8d217d0d47dcfee437c5f
7
+ data.tar.gz: f633c25ba1ddbe8bcec167425f4f48b9ed8d6f94bac6048dc75c9a68bb13745af76b4572bb1b4e3a869bbf542a0928c8a0235e9ee835726e52325085e089d42b
@@ -2,26 +2,37 @@ name: build
2
2
 
3
3
  on:
4
4
  - push
5
- - pull_request
6
5
 
7
6
  jobs:
8
7
  mri:
9
8
  strategy:
10
9
  matrix:
11
10
  ruby_version:
11
+ - '3.3'
12
12
  - '3.2'
13
13
  - '3.1'
14
14
  - '3.0'
15
15
  - '2.7'
16
- - '2.6'
17
16
  gemfile:
17
+ - gemfiles/rails_71.gemfile
18
18
  - gemfiles/rails_70.gemfile
19
19
  - gemfiles/rails_61.gemfile
20
20
  - gemfiles/rails_60.gemfile
21
21
  - gemfiles/rails_52.gemfile
22
22
  - gemfiles/rails_51.gemfile
23
23
  - gemfiles/rails_50.gemfile
24
+ - gemfiles/graphql_2_0.gemfile
24
25
  exclude:
26
+ - ruby_version: '3.3'
27
+ gemfile: gemfiles/rails_61.gemfile
28
+ - ruby_version: '3.3'
29
+ gemfile: gemfiles/rails_60.gemfile
30
+ - ruby_version: '3.3'
31
+ gemfile: gemfiles/rails_52.gemfile
32
+ - ruby_version: '3.3'
33
+ gemfile: gemfiles/rails_51.gemfile
34
+ - ruby_version: '3.3'
35
+ gemfile: gemfiles/rails_50.gemfile
25
36
  - ruby_version: '3.2'
26
37
  gemfile: gemfiles/rails_61.gemfile
27
38
  - ruby_version: '3.2'
@@ -48,14 +59,18 @@ jobs:
48
59
  gemfile: gemfiles/rails_51.gemfile
49
60
  - ruby_version: '3.0'
50
61
  gemfile: gemfiles/rails_50.gemfile
62
+ - ruby_version: '3.0'
63
+ gemfile: gemfiles/graphql_2_0.gemfile
64
+ - ruby_version: '2.7'
65
+ gemfile: gemfiles/rails_71.gemfile
51
66
  - ruby_version: '2.7'
52
67
  gemfile: gemfiles/rails_52.gemfile
53
68
  - ruby_version: '2.7'
54
69
  gemfile: gemfiles/rails_51.gemfile
55
70
  - ruby_version: '2.7'
56
71
  gemfile: gemfiles/rails_50.gemfile
57
- - ruby_version: '2.6'
58
- gemfile: gemfiles/rails_70.gemfile
72
+ - ruby_version: '2.7'
73
+ gemfile: gemfiles/graphql_2_0.gemfile
59
74
  runs-on: ubuntu-22.04
60
75
  env:
61
76
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
@@ -83,7 +98,7 @@ jobs:
83
98
  - name: Set up Ruby
84
99
  uses: ruby/setup-ruby@v1
85
100
  with:
86
- ruby-version: 3.2
101
+ ruby-version: 3.3
87
102
  bundler-cache: true
88
103
  - run: bundle exec rake || echo "Rails edge test is done."
89
104
 
@@ -96,7 +111,7 @@ jobs:
96
111
  - 'ruby-head'
97
112
  gemfile:
98
113
  - gemfiles/rails_edge.gemfile
99
- - gemfiles/rails_70.gemfile
114
+ - gemfiles/rails_71.gemfile
100
115
  runs-on: ubuntu-22.04
101
116
  env:
102
117
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
data/Appraisals CHANGED
@@ -4,6 +4,24 @@ appraise "rails_edge" do
4
4
  gem "railties"
5
5
  gem "activesupport"
6
6
  end
7
+
8
+ gem "rackup"
9
+ end
10
+
11
+ appraise "graphql_2_0" do
12
+ gem "rails", '~> 7.1.0'
13
+ gem "railties", '~> 7.1.0'
14
+ gem "activesupport", '~> 7.1.0'
15
+ gem "rackup"
16
+
17
+ gem "graphql", "< 2.1"
18
+ end
19
+
20
+ appraise "rails_71" do
21
+ gem "rails", '~> 7.1.0'
22
+ gem "railties", '~> 7.1.0'
23
+ gem "activesupport", '~> 7.1.0'
24
+ gem "rackup"
7
25
  end
8
26
 
9
27
  appraise "rails_70" do
@@ -19,9 +37,9 @@ appraise "rails_61" do
19
37
  end
20
38
 
21
39
  appraise "rails_60" do
22
- gem "rails", '~> 6.0.0.rc1'
23
- gem "railties", '~> 6.0.0.rc1'
24
- gem "activesupport", '~> 6.0.0.rc1'
40
+ gem "rails", '~> 6.0.0'
41
+ gem "railties", '~> 6.0.0'
42
+ gem "activesupport", '~> 6.0.0'
25
43
  end
26
44
 
27
45
  appraise "rails_52" do
data/CHANGELOG.md CHANGED
@@ -1,6 +1,38 @@
1
- ## Unreleased
1
+ ## v1.0.0
2
2
 
3
- - New entries come here...
3
+ #### 🚨 Breaking Changes
4
+
5
+ - Drop support for Ruby 2.6. For those of you looking to use Artemis on Ruby 2.6, please use the `artemis` version
6
+ `0.9.0` and the `graphql-client` version `0.17.0`.
7
+
8
+ #### ⭐️ New Features
9
+
10
+ - Add support for Ruby 3.3.
11
+ - Add support for the latest versinos of the `graphql` gem.
12
+
13
+ #### 🐞 Bug Fixes
14
+
15
+ - No bug fixes.
16
+
17
+ ## [v0.9.0](https://github.com/yuki24/artemis/tree/v0.9.0)
18
+
19
+ _<sup>released at 2023-09-18 01:08:34 UTC</sup>_
20
+
21
+ #### New Features
22
+
23
+ - Rails 7.1.0.beta1 is now officially supported ([<tt>f25ba29</tt>](https://github.com/yuki24/artemis/commit/f25ba296f15b26ffba7e4ec0f5b4cbeb061c97a1))
24
+
25
+ #### Fixes
26
+
27
+ - Fixes an issue where `graphql` gem `2.1.0` may not work with `graphql-client` ([<tt>b144ee2</tt>](https://github.com/yuki24/artemis/commit/b144ee2fbca2c23b4aaed8236f6fc07f65d8239d))
28
+
29
+ ## [v0.8.0](https://github.com/yuki24/artemis/tree/v0.8.0)
30
+
31
+ _<sup>released at 2023-01-05 05:29:37 UTC</sup>_
32
+
33
+ #### New Features
34
+
35
+ - Ruby 3.2 is now officially supported
4
36
 
5
37
  ## [v0.7.0](https://github.com/yuki24/artemis/tree/v0.7.0)
6
38
 
@@ -25,7 +57,6 @@ _<sup>released at 2021-09-03 04:17:55 UTC</sup>_
25
57
 
26
58
  #### Fixes
27
59
 
28
- - ~~Generate fixture YAML files on `rails g artemis:query queryName` ([#78](https://github.com/yuki24/artemis/pull/78))~~ Removed due to a bug for now.
29
60
  - Address warnings from Ruby 2.7 ([<tt>408adcb</tt>](https://github.com/yuki24/artemis/commit/408adcb3f39912f7afb7b3690a52f1d593662b7b))
30
61
  - Avoid crashing when config/graphql.yml does not exist ([@dlackty](https://github.com/dlackty), [#76](https://github.com/yuki24/artemis/pull/76))
31
62
 
@@ -93,5 +124,5 @@ _<sup>released at 2018-10-30 02:09:59 UTC</sup>_
93
124
 
94
125
  _<sup>released at 2018-10-16 20:57:51 UTC</sup>_
95
126
 
96
- First release of Artemis! <g-emoji class="g-emoji" alias="tada" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f389.png">&#127881;</g-emoji>
127
+ First release of Artemis! 🎉
97
128
 
data/artemis.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.add_dependency "activesupport", ">= 4.0.0"
19
19
  spec.add_dependency "railties", ">= 4.0.0"
20
- spec.add_dependency "graphql", ">= 1.8"
20
+ spec.add_dependency "graphql"
21
21
  spec.add_dependency "graphql-client", ">= 0.13.0"
22
22
 
23
23
  spec.add_development_dependency "appraisal", ">= 2.2"
data/bin/console CHANGED
@@ -4,9 +4,9 @@ require "bundler/setup"
4
4
  require "artemis"
5
5
 
6
6
  Artemis::Client.query_paths = [File.join(__dir__, '../spec/fixtures')]
7
- Artemis::GraphQLEndpoint.register!(:metaphysics, adapter: :test, url: '', schema_path: 'spec/fixtures/metaphysics/schema.json')
8
- Artemis::GraphQLEndpoint.lookup(:metaphysics).load_schema!
9
- require_relative '../spec/fixtures/metaphysics'
7
+ Artemis::GraphQLEndpoint.register!(:github, adapter: :test, url: '', schema_path: 'spec/fixtures/github/schema.json')
8
+ Artemis::GraphQLEndpoint.lookup(:github).load_schema!
9
+ require_relative '../spec/fixtures/github'
10
10
 
11
11
  require "pry"
12
12
  Pry.start
@@ -0,0 +1,15 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "pry"
6
+ gem "pry-byebug", platforms: :mri
7
+ gem "curb", ">= 0.9.6"
8
+ gem "webrick"
9
+ gem "rails", "~> 7.1.0"
10
+ gem "railties", "~> 7.1.0"
11
+ gem "activesupport", "~> 7.1.0"
12
+ gem "rackup"
13
+ gem "graphql", "< 2.1"
14
+
15
+ gemspec path: "../"
@@ -6,8 +6,8 @@ gem "pry"
6
6
  gem "pry-byebug", platforms: :mri
7
7
  gem "curb", ">= 0.9.6"
8
8
  gem "webrick"
9
- gem "rails", "~> 6.0.0.rc1"
10
- gem "railties", "~> 6.0.0.rc1"
11
- gem "activesupport", "~> 6.0.0.rc1"
9
+ gem "rails", "~> 6.0.0"
10
+ gem "railties", "~> 6.0.0"
11
+ gem "activesupport", "~> 6.0.0"
12
12
 
13
13
  gemspec path: "../"
@@ -0,0 +1,14 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "pry"
6
+ gem "pry-byebug", platforms: :mri
7
+ gem "curb", ">= 0.9.6"
8
+ gem "webrick"
9
+ gem "rails", "~> 7.1.0"
10
+ gem "railties", "~> 7.1.0"
11
+ gem "activesupport", "~> 7.1.0"
12
+ gem "rackup"
13
+
14
+ gemspec path: "../"
@@ -12,5 +12,6 @@ gem "pry"
12
12
  gem "pry-byebug", platforms: :mri
13
13
  gem "curb", ">= 0.9.6"
14
14
  gem "webrick"
15
+ gem "rackup"
15
16
 
16
17
  gemspec path: "../"
@@ -8,6 +8,12 @@ rescue LoadError
8
8
  # no-op... Rails 7.0 requires this.
9
9
  end
10
10
 
11
+ begin
12
+ require 'active_support/deprecation'
13
+ require 'active_support/deprecator'
14
+ rescue LoadError
15
+ end
16
+
11
17
  require 'active_support/core_ext/numeric/time'
12
18
  require 'net/http/persistent'
13
19
 
@@ -61,7 +61,7 @@ module Artemis
61
61
  if app.config.eager_load && app.config.cache_classes
62
62
  Artemis::GraphQLEndpoint.registered_services.each do |endpoint_name|
63
63
  begin
64
- require endpoint_name # Rails 7.0 requires this.
64
+ require_dependency endpoint_name # Rails 7.0+ requires this.
65
65
  rescue LoadError
66
66
  # no-op...
67
67
  end
@@ -1,3 +1,3 @@
1
1
  module Artemis
2
- VERSION = "0.8.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -2,6 +2,13 @@ require 'json'
2
2
  require 'rack'
3
3
  require 'webrick'
4
4
 
5
+ RACK_SERVER = begin
6
+ require 'rackup/handler/webrick'
7
+ Rackup::Handler::WEBrick
8
+ rescue LoadError
9
+ Rack::Handler::WEBrick
10
+ end
11
+
5
12
  describe 'Adapters' do
6
13
  FakeServer = ->(env) {
7
14
  case env['PATH_INFO']
@@ -61,7 +68,7 @@ describe 'Adapters' do
61
68
  Artemis::Adapters::AbstractAdapter.send(:attr_writer, :uri, :timeout)
62
69
 
63
70
  @server_thread = Thread.new do
64
- Rack::Handler::WEBrick.run(FakeServer, Port: 8000, Logger: WEBrick::Log.new('/dev/null'), AccessLog: [])
71
+ RACK_SERVER.run(FakeServer, Port: 8000, Logger: WEBrick::Log.new('/dev/null'), AccessLog: [])
65
72
  end
66
73
 
67
74
  loop do
@@ -75,7 +82,7 @@ describe 'Adapters' do
75
82
  end
76
83
 
77
84
  after :all do
78
- Rack::Handler::WEBrick.shutdown
85
+ RACK_SERVER.shutdown
79
86
  @server_thread.terminate
80
87
  end
81
88
 
@@ -1,56 +1,63 @@
1
1
  describe "#{GraphQL::Client} Autoloading" do
2
2
  describe ".load_constant" do
3
3
  it "loads the specified constant if there is a matching graphql file" do
4
- Metaphysics.send(:remove_const, :Artist) if Metaphysics.constants.include?(:Artist)
4
+ Github.send(:remove_const, :User) if Github.constants.include?(:User)
5
5
 
6
- Metaphysics.load_constant(:Artist)
6
+ Github.load_constant(:User)
7
7
 
8
- expect(defined?(Metaphysics::Artist)).to eq('constant')
8
+ expect(defined?(Github::User)).to eq('constant')
9
9
  end
10
10
 
11
11
  it "does nothing and returns nil if there is no matching file" do
12
- expect(Metaphysics.load_constant(:DoesNotExist)).to be_nil
12
+ expect(Github.load_constant(:DoesNotExist)).to be_nil
13
13
  end
14
14
  end
15
15
 
16
16
  describe ".preload!" do
17
17
  it "preloads all the graphQL files in the query paths" do
18
- %i(Artist Artists Artwork ArtistFields)
19
- .select {|const_name| Metaphysics.constants.include?(const_name) }
20
- .each {|const_name| Metaphysics.send(:remove_const, const_name) }
18
+ %i(User UserRepositories Repository RepositoryFields)
19
+ .select {|const_name| Github.constants.include?(const_name) }
20
+ .each {|const_name| Github.send(:remove_const, const_name) }
21
21
 
22
- Metaphysics.preload!
22
+ Github.preload!
23
23
 
24
- expect(defined?(Metaphysics::Artist)).to eq('constant')
25
- expect(defined?(Metaphysics::Artwork)).to eq('constant')
24
+ expect(defined?(Github::User)).to eq('constant')
25
+ expect(defined?(Github::Repository)).to eq('constant')
26
26
  end
27
27
  end
28
28
 
29
29
  it "dynamically loads the matching GraphQL query and sets it to a constant" do
30
- Metaphysics.send(:remove_const, :Artist) if Metaphysics.constants.include?(:Artist)
30
+ Github.send(:remove_const, :User) if Github.constants.include?(:User)
31
31
 
32
- query = Metaphysics::Artist
32
+ query = Github::User
33
33
 
34
34
  expect(query.document.to_query_string).to eq(<<~GRAPHQL.strip)
35
- query Metaphysics__Artist($id: String!) {
36
- artist(id: $id) {
35
+ query Github__User {
36
+ user(login: "yuki24") {
37
+ id
37
38
  name
38
- bio
39
- birthday
40
39
  }
41
40
  }
42
41
  GRAPHQL
43
42
  end
44
43
 
45
44
  it "dynamically loads the matching GraphQL fragment and sets it to a constant" do
46
- Metaphysics.send(:remove_const, :ArtistFields) if Metaphysics.constants.include?(:ArtistFields)
45
+ Github.send(:remove_const, :RepositoryFields) if Github.constants.include?(:RepositoryFields)
47
46
 
48
- query = Metaphysics::ArtistFields
47
+ query = Github::RepositoryFields
49
48
 
50
49
  expect(query.document.to_query_string).to eq(<<~GRAPHQL.strip)
51
- fragment Metaphysics__ArtistFields on Artist {
52
- hometown
53
- deathday
50
+ fragment Github__RepositoryFields on Repository {
51
+ name
52
+ nameWithOwner
53
+ url
54
+ updatedAt
55
+ languages(first: 1) {
56
+ nodes {
57
+ name
58
+ color
59
+ }
60
+ }
54
61
  }
55
62
  GRAPHQL
56
63
  end
@@ -58,25 +65,24 @@ describe "#{GraphQL::Client} Autoloading" do
58
65
  it "correctly loads the matching GraphQL query even when the top-level constant with the same name exists" do
59
66
  # In Ruby <= 2.4 top-level constants can be looked up through a namespace, which turned out to be a bad practice.
60
67
  # This has been removed in 2.5, but in earlier versions still suffer from this behaviour.
61
- Metaphysics.send(:remove_const, :Artist) if Metaphysics.constants.include?(:Artist)
62
- Object.send(:remove_const, :Artist) if Object.constants.include?(:Artist)
68
+ Github.send(:remove_const, :User) if Github.constants.include?(:User)
69
+ Object.send(:remove_const, :User) if Object.constants.include?(:User)
63
70
 
64
71
  begin
65
- Object.send(:const_set, :Artist, 1)
72
+ Object.send(:const_set, :User, 1)
66
73
 
67
- Metaphysics.artist
74
+ Github.user
68
75
  ensure
69
- Object.send(:remove_const, :Artist)
76
+ Object.send(:remove_const, :User)
70
77
  end
71
78
 
72
- query = Metaphysics::Artist
79
+ query = Github::User
73
80
 
74
81
  expect(query.document.to_query_string).to eq(<<~GRAPHQL.strip)
75
- query Metaphysics__Artist($id: String!) {
76
- artist(id: $id) {
82
+ query Github__User {
83
+ user(login: "yuki24") {
84
+ id
77
85
  name
78
- bio
79
- birthday
80
86
  }
81
87
  }
82
88
  GRAPHQL
@@ -84,63 +90,63 @@ describe "#{GraphQL::Client} Autoloading" do
84
90
 
85
91
  it "raises an exception when the path was resolved but the file does not exist" do
86
92
  begin
87
- Metaphysics.graphql_file_paths << "metaphysics/removed.graphql"
93
+ Github.graphql_file_paths << "github/removed.graphql"
88
94
 
89
- expect { Metaphysics::Removed }.to raise_error(Errno::ENOENT)
95
+ expect { Github::Removed }.to raise_error(Errno::ENOENT)
90
96
  ensure
91
- Metaphysics.graphql_file_paths.delete("metaphysics/removed.graphql")
97
+ Github.graphql_file_paths.delete("github/removed.graphql")
92
98
  end
93
99
  end
94
100
 
95
101
  it "raises an NameError when there is no graphql file that matches the const name" do
96
- expect { Metaphysics::DoesNotExist }.to raise_error(NameError)
102
+ expect { Github::DoesNotExist }.to raise_error(NameError)
97
103
  end
98
104
 
99
105
  xit "defines the query method when the matching class method gets called for the first time" do
100
- Metaphysics.undef_method(:artwork) if Metaphysics.public_instance_methods.include?(:artwork)
106
+ Github.undef_method(:user) if Github.public_instance_methods.include?(:user)
101
107
 
102
- Metaphysics.artwork
108
+ Github.user
103
109
 
104
- expect(Metaphysics.public_instance_methods).to include(:artwork)
110
+ expect(Github.public_instance_methods).to include(:user)
105
111
  end
106
112
 
107
113
  it "raises an NameError when there is no graphql file that matches the class method name" do
108
- expect { Metaphysics.does_not_exist }.to raise_error(NameError)
114
+ expect { Github.does_not_exist }.to raise_error(NameError)
109
115
  end
110
116
 
111
117
  it "raises an NameError when the class method name matches a fragment name" do
112
- expect { Metaphysics.artist_fragment }.to raise_error(NameError)
118
+ expect { Github.repository_fields_fragment }.to raise_error(NameError)
113
119
  end
114
120
 
115
121
  it "responds to a class method that has a matching graphQL file" do
116
- expect(Metaphysics).to respond_to(:artwork)
122
+ expect(Github).to respond_to(:user)
117
123
  end
118
124
 
119
125
  it "does not respond to class methods that do not have a matching graphQL file" do
120
- expect(Metaphysics).not_to respond_to(:does_not_exist)
126
+ expect(Github).not_to respond_to(:does_not_exist)
121
127
  end
122
128
 
123
129
  xit "defines the query method when the matching instance method gets called for the first time" do
124
- Metaphysics.undef_method(:artwork) if Metaphysics.public_instance_methods.include?(:artwork)
130
+ Github.undef_method(:user) if Github.public_instance_methods.include?(:user)
125
131
 
126
- Metaphysics.new.artwork
132
+ Github.new.user
127
133
 
128
- expect(Metaphysics.public_instance_methods).to include(:artwork)
134
+ expect(Github.public_instance_methods).to include(:user)
129
135
  end
130
136
 
131
137
  it "raises an NameError when there is no graphql file that matches the instance method name" do
132
- expect { Metaphysics.new.does_not_exist }.to raise_error(NameError)
138
+ expect { Github.new.does_not_exist }.to raise_error(NameError)
133
139
  end
134
140
 
135
141
  it "raises an NameError when the instance method name matches a fragment name" do
136
- expect { Metaphysics.new.artist_fragment }.to raise_error(NameError)
142
+ expect { Github.new.repository_fields_fragment }.to raise_error(NameError)
137
143
  end
138
144
 
139
145
  it "responds to the method that has a matching graphQL file" do
140
- expect(Metaphysics.new).to respond_to(:artwork)
146
+ expect(Github.new).to respond_to(:user)
141
147
  end
142
148
 
143
149
  it "does not respond to methods that do not have a matching graphQL file" do
144
- expect(Metaphysics.new).not_to respond_to(:does_not_exist)
150
+ expect(Github.new).not_to respond_to(:does_not_exist)
145
151
  end
146
152
  end
@@ -3,7 +3,7 @@ require 'active_support/core_ext/module/attribute_accessors'
3
3
  describe "#{GraphQL::Client} Callbacks" do
4
4
  Client = Class.new(Artemis::Client) do
5
5
  def self.name
6
- 'Metaphysics'
6
+ 'Github'
7
7
  end
8
8
 
9
9
  mattr_accessor :before_callback, :after_callback
@@ -35,20 +35,20 @@ describe "#{GraphQL::Client} Callbacks" do
35
35
 
36
36
  describe ".before_execute" do
37
37
  it "gets invoked before executing" do
38
- Client.artist(id: 'yayoi-kusama', context: { user_id: 'yuki24' })
38
+ Client.repository(owner: "yuki24", name: "artemis", context: { user_id: 'yuki24' })
39
39
 
40
40
  document, operation_name, variables, context = Client.before_callback
41
41
 
42
- expect(document).to eq(Client::Artist.document)
43
- expect(operation_name).to eq('Client__Artist')
44
- expect(variables).to eq('id' => 'yayoi-kusama')
42
+ expect(document).to eq(Client::Repository.document)
43
+ expect(operation_name).to eq('Client__Repository')
44
+ expect(variables).to eq("name" => "artemis", "owner" => "yuki24")
45
45
  expect(context).to eq(user_id: 'yuki24')
46
46
  end
47
47
  end
48
48
 
49
49
  describe ".after_execute" do
50
50
  it "gets invoked after executing" do
51
- Client.artwork
51
+ Client.user
52
52
 
53
53
  data, errors, extensions = Client.after_callback
54
54