gris 0.3.4 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -3
- data/gris.gemspec +1 -0
- data/lib/gris.rb +1 -0
- data/lib/gris/generators/templates/api/spec/endpoints/%name_tableize%_endpoint_spec.rb.tt +8 -6
- data/lib/gris/generators/templates/scaffold/README.md.tt +3 -7
- data/lib/gris/generators/templates/scaffold/spec/spec_helper.rb +1 -0
- data/lib/gris/setup.rb +5 -1
- data/lib/gris/version.rb +1 -1
- data/spec/generators/api_generator_spec.rb +25 -24
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19396544178bfbc38bc5a434941b3fd053e40e02
|
4
|
+
data.tar.gz: 4c35fb83a5586052a941f9933490b04409d4709b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0984a2bbedf2cf1d8408c8cae3d119dee87d76fd9934cd03da8e645806d779ce49055cda98c6b2b6cc17cbfc14917ec7d2caf31ee88d992e4feff00dfa64dff4
|
7
|
+
data.tar.gz: e9ab0808f54bf5903393d407598ed4c015e8051b86d089b20d9e5d10dbcd21d9ce60dc2bfb5a2bdec91eef68b9c41b33625a8abc4832f3e7ce57e1911d839a38
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gris (0.3.
|
4
|
+
gris (0.3.6)
|
5
5
|
activesupport (~> 4.2, >= 4.2.0)
|
6
6
|
chronic (~> 0.10.0)
|
7
7
|
dalli (~> 2.7)
|
@@ -10,6 +10,7 @@ PATH
|
|
10
10
|
grape-roar (~> 0.3.0, >= 0.3.0)
|
11
11
|
grape-swagger (~> 0.10.0)
|
12
12
|
hashie-forbidden_attributes (~> 0.1.0)
|
13
|
+
indefinite_article (~> 0.2)
|
13
14
|
logging (~> 2.0)
|
14
15
|
racksh (~> 1.0)
|
15
16
|
rake (~> 10.4, >= 10.4.2)
|
@@ -105,6 +106,8 @@ GEM
|
|
105
106
|
uri_template (~> 0.5)
|
106
107
|
i18n (0.7.0)
|
107
108
|
ice_nine (0.11.1)
|
109
|
+
indefinite_article (0.2.4)
|
110
|
+
activesupport
|
108
111
|
json (1.8.3)
|
109
112
|
little-plugger (1.1.3)
|
110
113
|
logging (2.0.0)
|
@@ -112,7 +115,7 @@ GEM
|
|
112
115
|
multi_json (~> 1.10)
|
113
116
|
mini_portile (0.6.2)
|
114
117
|
minitest (5.7.0)
|
115
|
-
multi_json (1.11.
|
118
|
+
multi_json (1.11.2)
|
116
119
|
multi_xml (0.5.5)
|
117
120
|
multipart-post (2.0.0)
|
118
121
|
net-http-digest_auth (1.4)
|
@@ -133,7 +136,7 @@ GEM
|
|
133
136
|
rack-test (>= 0.5)
|
134
137
|
rainbow (2.0.0)
|
135
138
|
rake (10.4.2)
|
136
|
-
representable (2.2.
|
139
|
+
representable (2.2.3)
|
137
140
|
multi_json
|
138
141
|
nokogiri
|
139
142
|
uber (~> 0.0.7)
|
data/gris.gemspec
CHANGED
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.add_runtime_dependency 'hashie-forbidden_attributes', '~> 0.1.0'
|
32
32
|
s.add_runtime_dependency 'chronic', '~> 0.10.0'
|
33
33
|
s.add_runtime_dependency 'dalli', '~> 2.7'
|
34
|
+
s.add_runtime_dependency 'indefinite_article', '~> 0.2'
|
34
35
|
|
35
36
|
s.add_development_dependency 'bundler', '~> 1'
|
36
37
|
s.add_development_dependency 'rspec', '~> 3.2'
|
data/lib/gris.rb
CHANGED
@@ -40,26 +40,28 @@ describe <%= name.classify.pluralize %>Endpoint do
|
|
40
40
|
end
|
41
41
|
let(:<%= name.underscore %>1) { Fabricate(:<%= name.underscore %>, attributes: <%= name.underscore %>_details) }
|
42
42
|
|
43
|
-
it 'creates
|
43
|
+
it 'creates <%= name.underscore.with_indefinite_article %>' do
|
44
44
|
<%= name.underscore %> = client.<%= name.tableize %>._post(<%= name.underscore %>: <%= name.underscore %>_details)
|
45
45
|
expect(<%= name.underscore %>.replace_me).to eq <%= name.underscore %>_details[:replace_me]
|
46
46
|
end
|
47
47
|
|
48
|
-
it 'returns
|
48
|
+
it 'returns <%= name.underscore.with_indefinite_article %>' do
|
49
49
|
<%= name.underscore %> = client.<%= name.underscore %>(id: <%= name.underscore %>1.id)
|
50
50
|
expect(<%= name.underscore %>.id).to eq <%= name.underscore %>1.id
|
51
51
|
expect(<%= name.underscore %>.replace_me).to eq <%= name.underscore %>_details[:replace_me]
|
52
52
|
end
|
53
53
|
|
54
|
-
it 'updates
|
54
|
+
it 'updates <%= name.underscore.with_indefinite_article %>' do
|
55
55
|
<%= name.underscore %> = client.<%= name.underscore %>(id: <%= name.underscore %>1.id)._patch(<%= name.underscore %>: { replace_me: 'braque is a talented artist' })
|
56
56
|
expect(<%= name.underscore %>.id).to eq <%= name.underscore %>1.id
|
57
57
|
expect(<%= name.underscore %>.replace_me).to eq 'braque is a talented artist'
|
58
58
|
end
|
59
59
|
|
60
|
-
it 'deletes
|
61
|
-
<%= name.underscore %> =
|
62
|
-
expect
|
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)
|
63
65
|
end
|
64
66
|
end
|
65
67
|
end
|
@@ -14,16 +14,12 @@ Set-Up for Development
|
|
14
14
|
cd your-fork-directory
|
15
15
|
bundle
|
16
16
|
```
|
17
|
-
- `DATABASE_NAME` and `PERMITTED_TOKENS` are required environment variables. Prior to executing rake tasks, running the gris console or booting the application, set up your environment by doing **one** of the following:
|
18
|
-
* Use [Dotenv](https://github.com/bkeepers/dotenv)—copy `.env.example` to `.env` and `.env.test` and modify it where appropriate
|
19
|
-
* Export the minimum required environment variables `DATABASE_NAME` and `PERMITTED_TOKENS`
|
20
17
|
- Set up the database
|
21
18
|
```
|
22
|
-
|
23
|
-
|
19
|
+
RACK_ENV=test bundle exec rake db:create
|
20
|
+
RACK_ENV=test bundle exec rake db:migrate
|
24
21
|
```
|
25
22
|
- Verify that [Rubocop](https://github.com/bbatsov/rubocop) and specs pass.
|
26
23
|
```
|
27
|
-
|
24
|
+
bundle exec rake
|
28
25
|
```
|
29
|
-
|
@@ -3,6 +3,7 @@ ENV['RACK_ENV'] = 'test'
|
|
3
3
|
require File.expand_path('../../config/application', __FILE__)
|
4
4
|
require 'gris/rspec_extensions/response_helpers'
|
5
5
|
require 'gris/rspec_extensions/active_record_shared_connection'
|
6
|
+
ActiveRecord::Migration.check_pending!
|
6
7
|
|
7
8
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
8
9
|
# in spec/support/ and its subdirectories.
|
data/lib/gris/setup.rb
CHANGED
@@ -28,7 +28,11 @@ module Gris
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def db_connection_details
|
31
|
-
|
31
|
+
if ENV['DATABASE_URL']
|
32
|
+
ActiveRecord::ConnectionAdapters::ConnectionSpecification::ConnectionUrlResolver.new(ENV['DATABASE_URL']).to_hash
|
33
|
+
else
|
34
|
+
YAML.load(ERB.new(File.read('./config/database.yml')).result)[Gris.env]
|
35
|
+
end
|
32
36
|
end
|
33
37
|
|
34
38
|
def cache
|
data/lib/gris/version.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Gris::Generators::ApiGenerator do
|
4
4
|
include_context 'with generator'
|
5
|
-
let(:api_name) { '
|
5
|
+
let(:api_name) { 'article' }
|
6
6
|
|
7
7
|
before do
|
8
8
|
endpoints_directory_path = "#{generator_tmp_directory}/app/endpoints"
|
@@ -16,78 +16,79 @@ describe Gris::Generators::ApiGenerator do
|
|
16
16
|
|
17
17
|
describe 'app' do
|
18
18
|
it 'creates an endpoint class' do
|
19
|
-
expected_api_file = File.join(generator_tmp_directory, 'app/endpoints/
|
19
|
+
expected_api_file = File.join(generator_tmp_directory, 'app/endpoints/articles_endpoint.rb')
|
20
20
|
api_code = File.read(expected_api_file)
|
21
|
-
expect(api_code).to match(/class
|
21
|
+
expect(api_code).to match(/class ArticlesEndpoint/)
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'creates a model class' do
|
25
|
-
expected_model_file = File.join(generator_tmp_directory, 'app/models/
|
25
|
+
expected_model_file = File.join(generator_tmp_directory, 'app/models/article.rb')
|
26
26
|
model_code = File.read(expected_model_file)
|
27
|
-
expect(model_code).to match(/class
|
27
|
+
expect(model_code).to match(/class Article/)
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'creates an item presenter module' do
|
31
|
-
expected_presenter_file = File.join(generator_tmp_directory, 'app/presenters/
|
31
|
+
expected_presenter_file = File.join(generator_tmp_directory, 'app/presenters/article_presenter.rb')
|
32
32
|
presenter_code = File.read(expected_presenter_file)
|
33
|
-
expect(presenter_code).to match(/module
|
33
|
+
expect(presenter_code).to match(/module ArticlePresenter/)
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'item presenter includes Gris::Presenter' do
|
37
|
-
presenter_file = File.join(generator_tmp_directory, 'app/presenters/
|
37
|
+
presenter_file = File.join(generator_tmp_directory, 'app/presenters/article_presenter.rb')
|
38
38
|
require "./#{presenter_file}"
|
39
|
-
expect(
|
39
|
+
expect(ArticlePresenter).to include(Gris::Presenter)
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'creates a collection presenter module' do
|
43
|
-
expected_presenter_file = File.join(generator_tmp_directory, 'app/presenters/
|
43
|
+
expected_presenter_file = File.join(generator_tmp_directory, 'app/presenters/articles_presenter.rb')
|
44
44
|
presenter_code = File.read(expected_presenter_file)
|
45
|
-
expect(presenter_code).to match(/module
|
45
|
+
expect(presenter_code).to match(/module ArticlesPresenter/)
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'collection presenter includes Gris::Presenter' do
|
49
|
-
presenter_file = File.join(generator_tmp_directory, 'app/presenters/
|
49
|
+
presenter_file = File.join(generator_tmp_directory, 'app/presenters/articles_presenter.rb')
|
50
50
|
require "./#{presenter_file}"
|
51
|
-
expect(
|
51
|
+
expect(ArticlesPresenter).to include(Gris::Presenter)
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'collection presenter includes Gris::PaginatedPresenter' do
|
55
|
-
presenter_file = File.join(generator_tmp_directory, 'app/presenters/
|
55
|
+
presenter_file = File.join(generator_tmp_directory, 'app/presenters/articles_presenter.rb')
|
56
56
|
require "./#{presenter_file}"
|
57
|
-
expect(
|
57
|
+
expect(ArticlesPresenter).to include(Gris::PaginatedPresenter)
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'mounts new endpoint in ApplicationEndpoint' do
|
61
61
|
expected_endpoint_file = File.join(generator_tmp_directory, 'app/endpoints/application_endpoint.rb')
|
62
62
|
endpoint_file = File.read(expected_endpoint_file)
|
63
|
-
expect(endpoint_file).to match(/mount
|
63
|
+
expect(endpoint_file).to match(/mount ArticlesEndpoint/)
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'adds links to RootPresenter' do
|
67
67
|
expected_root_presenter_file = File.join(generator_tmp_directory, 'app/presenters/root_presenter.rb')
|
68
68
|
presenter_file = File.read(expected_root_presenter_file)
|
69
|
-
expect(presenter_file).to match(/link :
|
70
|
-
expect(presenter_file).to match(/link :
|
69
|
+
expect(presenter_file).to match(/link :article do |opts|/)
|
70
|
+
expect(presenter_file).to match(/link :articles do |opts|/)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
describe 'spec' do
|
75
75
|
it 'creates an api spec' do
|
76
|
-
expected_api_file = File.join(generator_tmp_directory, 'spec/endpoints/
|
76
|
+
expected_api_file = File.join(generator_tmp_directory, 'spec/endpoints/articles_endpoint_spec.rb')
|
77
77
|
api_code = File.read(expected_api_file)
|
78
|
-
expect(api_code).to match(/describe
|
78
|
+
expect(api_code).to match(/describe ArticlesEndpoint/)
|
79
|
+
expect(api_code).to match(/returns an article/)
|
79
80
|
end
|
80
81
|
|
81
82
|
it 'creates a fabricator' do
|
82
|
-
expected_fabricator_file = File.join(generator_tmp_directory, 'spec/fabricators/
|
83
|
+
expected_fabricator_file = File.join(generator_tmp_directory, 'spec/fabricators/articles_fabricator.rb')
|
83
84
|
fabricator_code = File.read(expected_fabricator_file)
|
84
|
-
expect(fabricator_code).to include 'Fabricator(:
|
85
|
+
expect(fabricator_code).to include 'Fabricator(:article) do'
|
85
86
|
end
|
86
87
|
|
87
88
|
it 'creates a model spec' do
|
88
|
-
expected_model_file = File.join(generator_tmp_directory, 'spec/models/
|
89
|
+
expected_model_file = File.join(generator_tmp_directory, 'spec/models/article_spec.rb')
|
89
90
|
model_code = File.read(expected_model_file)
|
90
|
-
expect(model_code).to match(/describe
|
91
|
+
expect(model_code).to match(/describe Article/)
|
91
92
|
end
|
92
93
|
end
|
93
94
|
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.
|
4
|
+
version: 0.3.6
|
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-
|
11
|
+
date: 2015-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -222,6 +222,20 @@ dependencies:
|
|
222
222
|
- - "~>"
|
223
223
|
- !ruby/object:Gem::Version
|
224
224
|
version: '2.7'
|
225
|
+
- !ruby/object:Gem::Dependency
|
226
|
+
name: indefinite_article
|
227
|
+
requirement: !ruby/object:Gem::Requirement
|
228
|
+
requirements:
|
229
|
+
- - "~>"
|
230
|
+
- !ruby/object:Gem::Version
|
231
|
+
version: '0.2'
|
232
|
+
type: :runtime
|
233
|
+
prerelease: false
|
234
|
+
version_requirements: !ruby/object:Gem::Requirement
|
235
|
+
requirements:
|
236
|
+
- - "~>"
|
237
|
+
- !ruby/object:Gem::Version
|
238
|
+
version: '0.2'
|
225
239
|
- !ruby/object:Gem::Dependency
|
226
240
|
name: bundler
|
227
241
|
requirement: !ruby/object:Gem::Requirement
|