gris 0.3.9 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ee4df75cb4ac7a293b7f2796ab5e53b3cbb6219
4
- data.tar.gz: 798bec39179c86bf2dbef41d368d6047c80081e2
3
+ metadata.gz: 5fd7431c1a4ef8cba9d3433e9c4ef99150ce312e
4
+ data.tar.gz: 78bb4402d7fdd2ee04a28640f876238e6381debe
5
5
  SHA512:
6
- metadata.gz: 3f37e39acf05cc99b2ae5ca09d933adbe69a36d741897cf30cb523e2f3c940bebde14f4e14ff2571a361ba3dddead63d131c5ee568cefc12e55c07e9bb8abab9
7
- data.tar.gz: 5c94ff4ce3a9c260c140b3948fdab806dbd484c0176c5f954c0a86e70b834033182a64709219325a74d26c934c25e0150813a40dbbd6f3cf6b791d43c71ad92f
6
+ metadata.gz: b376e89a5cabcc44b96c3c781d0df82e6af0c1c083224dbb525f85918a01f4dfd3714ce2d18bb81971d158ff5c9e5f734dcd5010894ce849746a98d984adddfb
7
+ data.tar.gz: 68e760d526d57c1ea3fbd88390c9f22308013db711e380f91ae9ee819bd606f00e870ebdfb902b7a249ef308419e77e096e764ff1274dd9e1329f52a53fd6503
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gris (0.3.9)
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.2.3)
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
- include_context 'with a running app and client'
5
+ context 'with a running app' do
6
+ include_context 'with a running app'
6
7
 
7
- context '<%= name.tableize %>' do
8
- before(:each) do
9
- 20.times do
10
- Fabricate(:<%= name.underscore %>)
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
- it 'returns 10 <%= name.tableize %> by default' do
15
- expect(client.<%= name.tableize %>.count).to eq 10
16
- end
25
+ it 'returns 10 <%= name.tableize %> by default' do
26
+ expect(client.<%= name.tableize %>.count).to eq 10
27
+ end
17
28
 
18
- it 'returns 2 <%= name.tableize %>' do
19
- expect(client.<%= name.tableize %>(size: 2).count).to eq 2
20
- end
29
+ it 'returns 2 <%= name.tableize %>' do
30
+ expect(client.<%= name.tableize %>(size: 2).count).to eq 2
31
+ end
21
32
 
22
- it 'returns pagination' do
23
- response = client.<%= name.tableize %>(size: 2, page: 2)
24
- expect(response._links.next._url).to eq 'http://example.org/<%= name.tableize %>?page=3&size=2'
25
- expect(response._links.prev._url).to eq 'http://example.org/<%= name.tableize %>?page=1&size=2'
26
- expect(response._links.self._url).to eq 'http://example.org/<%= name.tableize %>?page=2&size=2'
27
- end
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
- it 'returns all unique ids' do
30
- <%= name.tableize %> = client.<%= name.tableize %>
31
- expect(<%= name.tableize %>.map(&:id).uniq.count).to eq 10
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
- context '<%= name.underscore %>' do
36
- let(:<%= name.underscore %>_details) do
37
- {
38
- replace_me: 'braque is not a talented artist'
39
- }
40
- end
41
- let(:<%= name.underscore %>1) { Fabricate(:<%= name.underscore %>, attributes: <%= name.underscore %>_details) }
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
- it 'creates <%= name.underscore.with_indefinite_article %>' do
44
- <%= name.underscore %> = client.<%= name.tableize %>._post(<%= name.underscore %>: <%= name.underscore %>_details)
45
- expect(<%= name.underscore %>.replace_me).to eq <%= name.underscore %>_details[:replace_me]
46
- end
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
- it 'returns <%= name.underscore.with_indefinite_article %>' do
49
- <%= name.underscore %> = client.<%= name.underscore %>(id: <%= name.underscore %>1.id)
50
- expect(<%= name.underscore %>.id).to eq <%= name.underscore %>1.id
51
- expect(<%= name.underscore %>.replace_me).to eq <%= name.underscore %>_details[:replace_me]
52
- end
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
- it 'updates <%= name.underscore.with_indefinite_article %>' do
55
- <%= name.underscore %> = client.<%= name.underscore %>(id: <%= name.underscore %>1.id)._patch(<%= name.underscore %>: { replace_me: 'braque is a talented artist' })
56
- expect(<%= name.underscore %>.id).to eq <%= name.underscore %>1.id
57
- expect(<%= name.underscore %>.replace_me).to eq 'braque is a talented artist'
58
- end
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
- it 'deletes <%= name.underscore.with_indefinite_article %>' do
61
- <%= name.underscore %> = Fabricate(:<%= name.underscore %>, attributes: <%= name.underscore %>_details)
62
- expect do
63
- client.<%= name.underscore %>(id: <%= name.underscore %>.id)._delete
64
- end.to change { <%= name.classify %>.count }.by(-1)
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
@@ -1,5 +1,5 @@
1
1
  module Gris
2
- VERSION = '0.3.9'
2
+ VERSION = '0.4.0'
3
3
 
4
4
  class Version
5
5
  class << self
@@ -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.3.9
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-04 00:00:00.000000000 Z
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