graphiti-rails 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/generators/graphiti/api_test_generator.rb +6 -0
- data/lib/generators/graphiti/generator_mixin.rb +14 -0
- data/lib/generators/graphiti/resource_generator.rb +8 -0
- data/lib/generators/graphiti/templates/index_request_spec.rb.erb +1 -1
- data/lib/generators/graphiti/templates/resource_reads_spec.rb.erb +6 -6
- data/lib/generators/graphiti/templates/show_request_spec.rb.erb +1 -1
- data/lib/graphiti/rails/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9bdb3311560b5685654994efde20e4f5bb73345034ffa64590ffda5a88ea8be6
|
4
|
+
data.tar.gz: 6180b0e0e4645602774e968b161206d47d493da7a200bcbdcb7d9ba99a674eb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcda213c7e5722a8ab22429a1f9b841bc6a7e5699c45b7c0d6dc2a6cec87cf9c5ad9e992eb5338371e90d9fc3fb64167c5df9141c7d815ee02eb5d6826701932
|
7
|
+
data.tar.gz: 7b3b8dfdfb0b0bf472f335531abb4d049f6e93a551b3e5330a799233305d4ecbd4f0ac024f5bc5297023b26917b20590c0df21afc078435ad61980f2045481ae
|
@@ -13,6 +13,12 @@ module Graphiti
|
|
13
13
|
aliases: ["--actions", "-a"],
|
14
14
|
desc: 'Array of controller actions, e.g. "index show destroy"'
|
15
15
|
|
16
|
+
class_option :'rawid',
|
17
|
+
type: :boolean,
|
18
|
+
default: false,
|
19
|
+
aliases: ["--rawid", "-r"],
|
20
|
+
desc: "Generate tests using rawid"
|
21
|
+
|
16
22
|
desc "Generates rspec request specs at spec/api"
|
17
23
|
def generate
|
18
24
|
generate_api_specs
|
@@ -41,5 +41,19 @@ module Graphiti
|
|
41
41
|
config = graphiti_config.merge(attrs)
|
42
42
|
File.open(".graphiticfg.yml", "w") { |f| f.write(config.to_yaml) }
|
43
43
|
end
|
44
|
+
|
45
|
+
def id_or_rawid
|
46
|
+
@options["rawid"] ? "rawid" : "id"
|
47
|
+
end
|
48
|
+
|
49
|
+
def sort_raw_ids
|
50
|
+
return unless @options["rawid"]
|
51
|
+
".sort"
|
52
|
+
end
|
53
|
+
|
54
|
+
def sort_raw_ids_descending
|
55
|
+
return unless @options["rawid"]
|
56
|
+
".sort.reverse"
|
57
|
+
end
|
44
58
|
end
|
45
59
|
end
|
@@ -14,6 +14,12 @@ module Graphiti
|
|
14
14
|
aliases: ["--omit-comments", "-c"],
|
15
15
|
desc: "Generate without documentation comments"
|
16
16
|
|
17
|
+
class_option :'rawid',
|
18
|
+
type: :boolean,
|
19
|
+
default: false,
|
20
|
+
aliases: ["--rawid", "-r"],
|
21
|
+
desc: "Generate tests using rawid"
|
22
|
+
|
17
23
|
class_option :actions,
|
18
24
|
type: :array,
|
19
25
|
default: nil,
|
@@ -143,12 +149,14 @@ module Graphiti
|
|
143
149
|
def generate_resource_specs
|
144
150
|
opts = {}
|
145
151
|
opts[:actions] = @options[:actions] if @options[:actions]
|
152
|
+
opts[:rawid] = @options[:rawid] if @options[:rawid]
|
146
153
|
invoke "graphiti:resource_test", [resource_klass], opts
|
147
154
|
end
|
148
155
|
|
149
156
|
def generate_api_specs
|
150
157
|
opts = {}
|
151
158
|
opts[:actions] = @options[:actions] if @options[:actions]
|
159
|
+
opts[:rawid] = @options[:rawid] if @options[:rawid]
|
152
160
|
invoke "graphiti:api_test", [resource_klass], opts
|
153
161
|
end
|
154
162
|
|
@@ -16,7 +16,7 @@ RSpec.describe "<%= type %>#index", type: :request do
|
|
16
16
|
make_request
|
17
17
|
expect(response.status).to eq(200), response.body
|
18
18
|
expect(d.map(&:jsonapi_type).uniq).to match_array(['<%= type %>'])
|
19
|
-
expect(d.map(
|
19
|
+
expect(d.map(&:<%= id_or_rawid %>)).to match_array([<%= var %>1.id, <%= var %>2.id])
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -7,7 +7,7 @@ RSpec.describe <%= resource_class %>, type: :resource do
|
|
7
7
|
it 'works' do
|
8
8
|
render
|
9
9
|
data = jsonapi_data[0]
|
10
|
-
expect(data
|
10
|
+
expect(data.<%= id_or_rawid %>).to eq(<%= var %>.id)
|
11
11
|
expect(data.jsonapi_type).to eq('<%= type %>')
|
12
12
|
<%- attributes.each do |a| -%>
|
13
13
|
<%- if [:created_at, :updated_at].include?(a.name.to_sym) -%>
|
@@ -31,7 +31,7 @@ RSpec.describe <%= resource_class %>, type: :resource do
|
|
31
31
|
|
32
32
|
it 'works' do
|
33
33
|
render
|
34
|
-
expect(d.map(
|
34
|
+
expect(d.map(&:<%= id_or_rawid %>)).to eq([<%= var %>2.id])
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -48,10 +48,10 @@ RSpec.describe <%= resource_class %>, type: :resource do
|
|
48
48
|
|
49
49
|
it 'works' do
|
50
50
|
render
|
51
|
-
expect(d.map(
|
51
|
+
expect(d.map(&:<%= id_or_rawid %>)).to eq([
|
52
52
|
<%= var %>1.id,
|
53
53
|
<%= var %>2.id
|
54
|
-
])
|
54
|
+
]<%= sort_raw_ids %>)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -62,10 +62,10 @@ RSpec.describe <%= resource_class %>, type: :resource do
|
|
62
62
|
|
63
63
|
it 'works' do
|
64
64
|
render
|
65
|
-
expect(d.map(
|
65
|
+
expect(d.map(&:<%= id_or_rawid %>)).to eq([
|
66
66
|
<%= var %>2.id,
|
67
67
|
<%= var %>1.id
|
68
|
-
])
|
68
|
+
]<%= sort_raw_ids_descending %>)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
@@ -15,7 +15,7 @@ RSpec.describe "<%= type %>#show", type: :request do
|
|
15
15
|
make_request
|
16
16
|
expect(response.status).to eq(200)
|
17
17
|
expect(d.jsonapi_type).to eq('<%= type %>')
|
18
|
-
expect(d
|
18
|
+
expect(d.<%= id_or_rawid %>).to eq(<%= var %>.id)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphiti-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Wagenet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphiti
|
@@ -237,8 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
237
|
- !ruby/object:Gem::Version
|
238
238
|
version: '0'
|
239
239
|
requirements: []
|
240
|
-
|
241
|
-
rubygems_version: 2.6.13
|
240
|
+
rubygems_version: 3.0.6
|
242
241
|
signing_key:
|
243
242
|
specification_version: 4
|
244
243
|
summary: Rails integration for Graphiti
|