gris 0.3.9 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -7
- data/lib/gris/generators/templates/api/spec/endpoints/%name_tableize%_endpoint_spec.rb.tt +60 -48
- data/lib/gris/generators/templates/scaffold/spec/support/app_helper.rb +1 -1
- data/lib/gris/generators/templates/scaffold/spec/support/shared_authentication_spec_helper.rb +8 -0
- data/lib/gris/version.rb +1 -1
- data/spec/generators/api_generator_spec.rb +2 -0
- data/spec/generators/scaffold_generator_spec.rb +4 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fd7431c1a4ef8cba9d3433e9c4ef99150ce312e
|
4
|
+
data.tar.gz: 78bb4402d7fdd2ee04a28640f876238e6381debe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b376e89a5cabcc44b96c3c781d0df82e6af0c1c083224dbb525f85918a01f4dfd3714ce2d18bb81971d158ff5c9e5f734dcd5010894ce849746a98d984adddfb
|
7
|
+
data.tar.gz: 68e760d526d57c1ea3fbd88390c9f22308013db711e380f91ae9ee819bd606f00e870ebdfb902b7a249ef308419e77e096e764ff1274dd9e1329f52a53fd6503
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gris (0.
|
4
|
+
gris (0.4.0)
|
5
5
|
activesupport (~> 4.2, >= 4.2.0)
|
6
6
|
chronic (~> 0.10.0)
|
7
7
|
dalli (~> 2.7)
|
@@ -113,14 +113,11 @@ GEM
|
|
113
113
|
logging (2.0.0)
|
114
114
|
little-plugger (~> 1.1)
|
115
115
|
multi_json (~> 1.10)
|
116
|
-
mini_portile (0.6.2)
|
117
116
|
minitest (5.7.0)
|
118
117
|
multi_json (1.11.2)
|
119
118
|
multi_xml (0.5.5)
|
120
119
|
multipart-post (2.0.0)
|
121
120
|
net-http-digest_auth (1.4)
|
122
|
-
nokogiri (1.6.6.2)
|
123
|
-
mini_portile (~> 0.6.0)
|
124
121
|
parser (2.2.2.5)
|
125
122
|
ast (>= 1.1, < 3.0)
|
126
123
|
powerpack (0.1.1)
|
@@ -136,9 +133,7 @@ GEM
|
|
136
133
|
rack-test (>= 0.5)
|
137
134
|
rainbow (2.0.0)
|
138
135
|
rake (10.4.2)
|
139
|
-
representable (2.
|
140
|
-
multi_json
|
141
|
-
nokogiri
|
136
|
+
representable (2.3.0)
|
142
137
|
uber (~> 0.0.7)
|
143
138
|
roar (1.0.1)
|
144
139
|
representable (>= 2.0.1, <= 3.0.0)
|
@@ -2,66 +2,78 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe <%= name.classify.pluralize %>Endpoint do
|
4
4
|
include Rack::Test::Methods
|
5
|
-
|
5
|
+
context 'with a running app' do
|
6
|
+
include_context 'with a running app'
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
it_should_behave_like 'an endpoint with token_authentication!', [
|
9
|
+
['get', '/<%= name.tableize %>'], ['post', '/<%= name.tableize %>'],
|
10
|
+
['get', '/<%= name.tableize %>/1'], ['patch', '/<%= name.tableize %>/2'],
|
11
|
+
['delete', '/<%= name.tableize %>/3']
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with a running app and token authorized client' do
|
16
|
+
include_context 'with a running app and token authorized client'
|
17
|
+
|
18
|
+
context '<%= name.tableize %>' do
|
19
|
+
before(:each) do
|
20
|
+
20.times do
|
21
|
+
Fabricate(:<%= name.underscore %>)
|
22
|
+
end
|
11
23
|
end
|
12
|
-
end
|
13
24
|
|
14
|
-
|
15
|
-
|
16
|
-
|
25
|
+
it 'returns 10 <%= name.tableize %> by default' do
|
26
|
+
expect(client.<%= name.tableize %>.count).to eq 10
|
27
|
+
end
|
17
28
|
|
18
|
-
|
19
|
-
|
20
|
-
|
29
|
+
it 'returns 2 <%= name.tableize %>' do
|
30
|
+
expect(client.<%= name.tableize %>(size: 2).count).to eq 2
|
31
|
+
end
|
21
32
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
33
|
+
it 'returns pagination' do
|
34
|
+
response = client.<%= name.tableize %>(size: 2, page: 2)
|
35
|
+
expect(response._links.next._url).to eq 'http://example.org/<%= name.tableize %>?page=3&size=2'
|
36
|
+
expect(response._links.prev._url).to eq 'http://example.org/<%= name.tableize %>?page=1&size=2'
|
37
|
+
expect(response._links.self._url).to eq 'http://example.org/<%= name.tableize %>?page=2&size=2'
|
38
|
+
end
|
28
39
|
|
29
|
-
|
30
|
-
|
31
|
-
|
40
|
+
it 'returns all unique ids' do
|
41
|
+
<%= name.tableize %> = client.<%= name.tableize %>
|
42
|
+
expect(<%= name.tableize %>.map(&:id).uniq.count).to eq 10
|
43
|
+
end
|
32
44
|
end
|
33
|
-
end
|
34
45
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
46
|
+
context '<%= name.underscore %>' do
|
47
|
+
let(:<%= name.underscore %>_details) do
|
48
|
+
{
|
49
|
+
replace_me: 'braque is not a talented artist'
|
50
|
+
}
|
51
|
+
end
|
52
|
+
let(:<%= name.underscore %>1) { Fabricate(:<%= name.underscore %>, attributes: <%= name.underscore %>_details) }
|
42
53
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
54
|
+
it 'creates <%= name.underscore.with_indefinite_article %>' do
|
55
|
+
<%= name.underscore %> = client.<%= name.tableize %>._post(<%= name.underscore %>: <%= name.underscore %>_details)
|
56
|
+
expect(<%= name.underscore %>.replace_me).to eq <%= name.underscore %>_details[:replace_me]
|
57
|
+
end
|
47
58
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
59
|
+
it 'returns <%= name.underscore.with_indefinite_article %>' do
|
60
|
+
<%= name.underscore %> = client.<%= name.underscore %>(id: <%= name.underscore %>1.id)
|
61
|
+
expect(<%= name.underscore %>.id).to eq <%= name.underscore %>1.id
|
62
|
+
expect(<%= name.underscore %>.replace_me).to eq <%= name.underscore %>_details[:replace_me]
|
63
|
+
end
|
53
64
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
65
|
+
it 'updates <%= name.underscore.with_indefinite_article %>' do
|
66
|
+
<%= name.underscore %> = client.<%= name.underscore %>(id: <%= name.underscore %>1.id)._patch(<%= name.underscore %>: { replace_me: 'braque is a talented artist' })
|
67
|
+
expect(<%= name.underscore %>.id).to eq <%= name.underscore %>1.id
|
68
|
+
expect(<%= name.underscore %>.replace_me).to eq 'braque is a talented artist'
|
69
|
+
end
|
59
70
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
71
|
+
it 'deletes <%= name.underscore.with_indefinite_article %>' do
|
72
|
+
<%= name.underscore %> = Fabricate(:<%= name.underscore %>, attributes: <%= name.underscore %>_details)
|
73
|
+
expect do
|
74
|
+
client.<%= name.underscore %>(id: <%= name.underscore %>.id)._delete
|
75
|
+
end.to change { <%= name.classify %>.count }.by(-1)
|
76
|
+
end
|
65
77
|
end
|
66
78
|
end
|
67
79
|
end
|
@@ -9,7 +9,7 @@ shared_context 'with token authorization' do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
shared_context 'with a running app and client' do
|
12
|
+
shared_context 'with a running app and token authorized client' do
|
13
13
|
include_context 'with a running app'
|
14
14
|
include_context 'with token authorization'
|
15
15
|
|
@@ -0,0 +1,8 @@
|
|
1
|
+
shared_examples_for 'an endpoint with token_authentication!' do |route_pairs|
|
2
|
+
route_pairs.each do |route_pair|
|
3
|
+
it "returns 401 for #{route_pair[0].upcase} #{route_pair[1]}" do
|
4
|
+
send route_pair[0], route_pair[1]
|
5
|
+
expect(response_code).to eq 401
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
data/lib/gris/version.rb
CHANGED
@@ -77,6 +77,8 @@ describe Gris::Generators::ApiGenerator do
|
|
77
77
|
api_code = File.read(expected_api_file)
|
78
78
|
expect(api_code).to match(/describe ArticlesEndpoint/)
|
79
79
|
expect(api_code).to match(/returns an article/)
|
80
|
+
expect(api_code).to match(/it_should_behave_like 'an endpoint with token_authentication!'/)
|
81
|
+
expect(api_code).to match %r{'get', '/articles/1'}
|
80
82
|
end
|
81
83
|
|
82
84
|
it 'creates a fabricator' do
|
@@ -97,5 +97,9 @@ describe Gris::Generators::ScaffoldGenerator do
|
|
97
97
|
expect(RootPresenter).to include(Gris::Presenter)
|
98
98
|
end
|
99
99
|
end
|
100
|
+
|
101
|
+
it 'generates a token authentication spec helper endpoint' do
|
102
|
+
expect(File).to exist("#{app_path}/spec/support/shared_authentication_spec_helper.rb")
|
103
|
+
end
|
100
104
|
end
|
101
105
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gris
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Fareed
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -368,6 +368,7 @@ files:
|
|
368
368
|
- lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
|
369
369
|
- lib/gris/generators/templates/scaffold/spec/spec_helper.rb
|
370
370
|
- lib/gris/generators/templates/scaffold/spec/support/app_helper.rb
|
371
|
+
- lib/gris/generators/templates/scaffold/spec/support/shared_authentication_spec_helper.rb
|
371
372
|
- lib/gris/grape_extensions/authentication_helpers.rb
|
372
373
|
- lib/gris/grape_extensions/crud_helpers.rb
|
373
374
|
- lib/gris/grape_extensions/date_time_helpers.rb
|