artemis 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +0,0 @@
1
- query {
2
- user(login: "yuki24") {
3
- id
4
- name
5
- }
6
- }
@@ -1,13 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- class Github < Artemis::Client
2
- end
@@ -1,17 +0,0 @@
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
@@ -1,10 +0,0 @@
1
- {
2
- "yuki24": {
3
- "data": {
4
- "user": {
5
- "id": "foobar",
6
- "name": "Yuki Nishijima"
7
- }
8
- }
9
- }
10
- }
@@ -1,5 +0,0 @@
1
- yoshiki:
2
- data:
3
- artist:
4
- id: pianist-yoshiki
5
- name: Pianist Yoshiki
data/spec/spec_helper.rb DELETED
@@ -1,49 +0,0 @@
1
- require 'artemis'
2
- require 'pry'
3
- require 'pry-byebug' if RUBY_ENGINE == 'ruby'
4
-
5
- # This assumes that all of thw following methods are property implemented:
6
- #
7
- # * +Artemis::Client.query_paths+
8
- # * +Artemis::GraphQLEndpoint.register!+
9
- # * +Artemis::GraphQLEndpoint.lookup+
10
- # * +Artemis::GraphQLEndpoint#load_schema!+
11
- #
12
- # The only method that doesn't need test coverage is +Artemis::Client.query_paths+. The rest of the methods should be
13
- # tested, but we don't have any test setup for that yet.
14
- Artemis::Client.query_paths = [File.join(__dir__, 'fixtures')]
15
- Artemis::GraphQLEndpoint.suppress_warnings_on_schema_load = true
16
- Artemis::GraphQLEndpoint.register!(:github, adapter: :test, url: '', schema_path: 'spec/fixtures/github/schema.json')
17
- Artemis::GraphQLEndpoint.lookup(:github).load_schema!
18
-
19
- require 'fixtures/github'
20
-
21
- PROJECT_DIR = FileUtils.pwd
22
-
23
- RSpec.configure do |config|
24
- config.expect_with :rspec do |expectations|
25
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
26
- end
27
-
28
- config.mock_with :rspec do |mocks|
29
- mocks.verify_partial_doubles = true
30
- end
31
-
32
- # config.warnings = true
33
- config.order = :random
34
-
35
- if config.files_to_run.one?
36
- config.default_formatter = "doc"
37
- end
38
-
39
- # Print the 10 slowest examples and example groups at the
40
- # end of the spec run, to help surface which specs are running
41
- # particularly slow.
42
- # config.profile_examples = 10
43
-
44
- # Seed global randomization in this process using the `--seed` CLI option.
45
- # Setting this allows you to use `--seed` to deterministically reproduce
46
- # test failures related to randomization by passing the same `--seed` value
47
- # as the one that triggered the failure.
48
- # Kernel.srand config.seed
49
- end
@@ -1,94 +0,0 @@
1
- require 'artemis/test_helper'
2
- require 'date'
3
-
4
- describe Artemis::TestHelper do
5
- include Artemis::TestHelper
6
-
7
- def graphql_fixture_path
8
- File.join(PROJECT_DIR, "spec/fixtures/responses")
9
- end
10
-
11
- before do
12
- graphql_requests.clear
13
- graphql_responses.clear
14
- end
15
-
16
- it "can mock a GraphQL request" do
17
- stub_graphql(Github, :repository).to_return(:yuki24_artemis)
18
-
19
- response = Github.repository(owner: "yuki24", name: "artemis")
20
-
21
- expect(response.data.repository.name).to eq("artemis")
22
- expect(response.data.repository.name_with_owner).to eq("yuki24/artemis")
23
- end
24
-
25
- it "can mock a GraphQL request with an ERB-enabled fixture" do
26
- stub_graphql(Github, :repository).to_return(:yuki24_rambulance)
27
-
28
- response = Github.repository(owner: "yuki24", name: "rambulance")
29
-
30
- expect(response.data.repository.name_with_owner).to eq("yuki24/rambulance")
31
- end
32
-
33
- it "can mock a GraphQL request with variables using exact match" do
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
-
37
- yuki24_artemis = Github.repository(owner: "yuki24", name: "artemis")
38
- yuki24_rambulance = Github.repository(owner: "yuki24", name: "rambulance")
39
-
40
- expect(yuki24_artemis.data.repository.name).to eq("artemis")
41
- expect(yuki24_rambulance.data.repository.name).to eq("rambulance")
42
- end
43
-
44
- it "can mock a GraphQL request with a JSON file" do
45
- stub_graphql(Github, :user).to_return(:yuki24)
46
-
47
- response = Github.user
48
-
49
- expect(response.data.user.id).to eq("foobar")
50
- expect(response.data.user.name).to eq("Yuki Nishijima")
51
- end
52
-
53
- it "can mock a GraphQL request for a query that has a query name"
54
-
55
- it "raises an exception if the specified fixture file does not exist" do
56
- expect { stub_graphql(Github, :does_not_exist).to_return(:data) }
57
- .to raise_error(Artemis::FixtureNotFound, %r|does_not_exist.{yml,json}|)
58
- end
59
-
60
- it "raises an exception if the specified fixture file exists but fixture key does not exist" do
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
- end
64
-
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
-
68
- yoshiki = Github.repository(owner: "ruby", name: "did_you_mean")
69
-
70
- expect(yoshiki.data.repository.name).to eq("did_you_mean")
71
- end
72
-
73
- it "can mock separate GraphQL queries with the same arguments" do
74
- stub_graphql("SpotifyClient", :repository, id: "yoshiki").to_return(:yoshiki)
75
- stub_graphql(Github, :repository, id: "yoshiki").to_return(:yoshiki)
76
-
77
- yoshiki = Github.repository(id: "yoshiki")
78
-
79
- expect(yoshiki.data.repository.name).to eq("did_you_mean")
80
- end
81
-
82
- it "allows to get raw fixture data as a Hash" do
83
- data = stub_graphql("SpotifyClient", :repository).get(:yoshiki)
84
-
85
- expect(data).to eq({
86
- "data" => {
87
- "repository" => {
88
- "name" => "did_you_mean",
89
- "nameWithOwner" => "ruby/did_you_mean",
90
- }
91
- }
92
- })
93
- end
94
- end