grape-starter 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/bin/grape-starter +2 -2
- data/lib/starter/builder.rb +3 -2
- data/lib/starter/builder/template_endpoints.rb +15 -3
- data/lib/starter/rspec/request_specs.rb +17 -48
- data/lib/starter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 790b8b35a17bfad2d7d24f930e1890070a2ec310
|
4
|
+
data.tar.gz: 1c206bc897cb55fe92a9cea52ad9edcb0b2abebe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c0a04b753111f99785c95ae61de3d7e79dc95e32d1b7bb15510f833454b34eb02c87d1d0290f14aeb362cf5c619cf8f878b70c970e84a30783c3bebf490977c
|
7
|
+
data.tar.gz: 3a1e06b66bf9693364b9c9b3a0200fdd96f116ebb183dcf7c315ccf891f3f1d861a1e702f6c9f810dbbf2e93b296421d5918b2f71b7788b6d97f06474c0a2c6f
|
data/CHANGELOG.md
CHANGED
data/bin/grape-starter
CHANGED
@@ -69,7 +69,7 @@ command :add do |c|
|
|
69
69
|
builder_options = global_options.merge(set: set).merge(options)
|
70
70
|
Starter::Builder.call!(resource, builder_options)
|
71
71
|
created_files = Starter::Builder.save
|
72
|
-
|
72
|
+
p created_files
|
73
73
|
`bundle exec rubocop -a #{created_files.join(' ')}`
|
74
74
|
$stdout.puts "added resource: #{resource}"
|
75
75
|
rescue => e
|
@@ -80,7 +80,7 @@ end
|
|
80
80
|
|
81
81
|
desc 'Removes a resource - run from inside the project'
|
82
82
|
arg_name 'resource'
|
83
|
-
command :
|
83
|
+
command :rm do |c|
|
84
84
|
c.desc 'removes also entity file'
|
85
85
|
c.switch [:e, :entity], negatable: false
|
86
86
|
|
data/lib/starter/builder.rb
CHANGED
@@ -37,13 +37,14 @@ module Starter
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def save
|
40
|
-
file_list.
|
40
|
+
created_files = file_list.each_with_object([]) do |new_file, memo|
|
41
|
+
memo << send("#{new_file}_name")
|
41
42
|
save_file(new_file)
|
42
43
|
end
|
43
44
|
|
44
45
|
add_moint_point
|
45
46
|
|
46
|
-
|
47
|
+
created_files
|
47
48
|
end
|
48
49
|
|
49
50
|
def endpoints
|
@@ -74,24 +74,36 @@ module Starter
|
|
74
74
|
# request specs shared examples
|
75
75
|
#
|
76
76
|
def post_spec
|
77
|
-
"it_behaves_like 'POST', base_path: '/api/v1', resource: '#{resource}'"
|
77
|
+
"it_behaves_like 'POST', base_path: '/api/v1', resource: '#{resource}', params: {}"
|
78
78
|
end
|
79
79
|
|
80
80
|
def get_all_spec
|
81
81
|
"it_behaves_like 'GET all', base_path: '/api/v1', resource: '#{resource}'"
|
82
82
|
end
|
83
83
|
|
84
|
-
%w(get
|
84
|
+
%w(get delete).each do |verb|
|
85
85
|
define_method(:"#{verb}_one_spec") do
|
86
86
|
"it_behaves_like '#{verb.upcase} one', base_path: '/api/v1', resource: '#{resource}'"
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
%w(
|
90
|
+
%w(put patch).each do |verb|
|
91
|
+
define_method(:"#{verb}_one_spec") do
|
92
|
+
"it_behaves_like '#{verb.upcase} one', base_path: '/api/v1', resource: '#{resource}', params: {}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
%w(get delete).each do |verb|
|
91
97
|
define_method(:"#{verb}_specific_spec") do
|
92
98
|
"it_behaves_like '#{verb.upcase} specific', base_path: '/api/v1', resource: '#{resource}', key: 1"
|
93
99
|
end
|
94
100
|
end
|
101
|
+
|
102
|
+
%w(put patch).each do |verb|
|
103
|
+
define_method(:"#{verb}_specific_spec") do
|
104
|
+
"it_behaves_like '#{verb.upcase} specific', base_path: '/api/v1', resource: '#{resource}', key: 1, params: {}"
|
105
|
+
end
|
106
|
+
end
|
95
107
|
end
|
96
108
|
end
|
97
109
|
end
|
@@ -1,35 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
RSpec.shared_examples 'POST' do |base_path: '/api/v1', resource: '', params: {}|
|
3
|
+
let(:route) { "#{base_path}/#{resource}" }
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
# for single
|
6
|
-
RSpec.shared_examples 'single CRUD' do |base_path: '/api/v1', resource: ''|
|
7
|
-
it_behaves_like 'POST', base_path: base_path, resource: resource
|
8
|
-
it_behaves_like 'GET one', base_path: base_path, resource: resource
|
9
|
-
it_behaves_like 'PUT one', base_path: base_path, resource: resource
|
10
|
-
it_behaves_like 'PATCH one', base_path: base_path, resource: resource
|
11
|
-
it_behaves_like 'DELETE one', base_path: base_path, resource: resource
|
12
|
-
end
|
13
|
-
#
|
14
|
-
# for plural
|
15
|
-
RSpec.shared_examples 'plural CRUD' do |base_path: '/api/v1', resource: '', key: nil|
|
16
|
-
it_behaves_like 'POST', base_path: base_path, resource: resource
|
17
|
-
it_behaves_like 'GET all', base_path: base_path, resource: resource
|
18
|
-
it_behaves_like 'GET specific', base_path: base_path, resource: resource, key: key
|
19
|
-
it_behaves_like 'PUT specific', base_path: base_path, resource: resource, key: key
|
20
|
-
it_behaves_like 'PATCH specific', base_path: base_path, resource: resource, key: key
|
21
|
-
it_behaves_like 'DELETE specific', base_path: base_path, resource: resource, key: key
|
5
|
+
subject { post route, params }
|
6
|
+
specify { expect(subject.status).to eql 201 }
|
22
7
|
end
|
23
8
|
|
24
|
-
|
25
|
-
#
|
26
|
-
RSpec.shared_examples 'POST' do |base_path: '/api/v1', resource: ''|
|
9
|
+
RSpec.shared_examples 'GET all' do |base_path: '/api/v1', resource: ''|
|
27
10
|
let(:route) { "#{base_path}/#{resource}" }
|
28
11
|
|
29
|
-
subject {
|
30
|
-
specify { expect(subject.status).to eql
|
12
|
+
subject { get route }
|
13
|
+
specify { expect(subject.status).to eql 200 }
|
31
14
|
end
|
32
15
|
|
16
|
+
# singular forms
|
17
|
+
#
|
33
18
|
RSpec.shared_examples 'GET one' do |base_path: '/api/v1', resource: ''|
|
34
19
|
let(:route) { "#{base_path}/#{resource}" }
|
35
20
|
|
@@ -37,17 +22,17 @@ RSpec.shared_examples 'GET one' do |base_path: '/api/v1', resource: ''|
|
|
37
22
|
specify { expect(subject.status).to eql 200 }
|
38
23
|
end
|
39
24
|
|
40
|
-
RSpec.shared_examples 'PUT one' do |base_path: '/api/v1', resource: ''|
|
25
|
+
RSpec.shared_examples 'PUT one' do |base_path: '/api/v1', resource: '', params: {}|
|
41
26
|
let(:route) { "#{base_path}/#{resource}" }
|
42
27
|
|
43
|
-
subject { put route }
|
28
|
+
subject { put route, params }
|
44
29
|
specify { expect(subject.status).to eql 200 }
|
45
30
|
end
|
46
31
|
|
47
|
-
RSpec.shared_examples 'PATCH one' do |base_path: '/api/v1', resource: ''|
|
32
|
+
RSpec.shared_examples 'PATCH one' do |base_path: '/api/v1', resource: '', params: {}|
|
48
33
|
let(:route) { "#{base_path}/#{resource}" }
|
49
34
|
|
50
|
-
subject { patch route }
|
35
|
+
subject { patch route, params }
|
51
36
|
specify { expect(subject.status).to eql 200 }
|
52
37
|
end
|
53
38
|
|
@@ -60,22 +45,6 @@ end
|
|
60
45
|
|
61
46
|
# plural forms
|
62
47
|
#
|
63
|
-
RSpec.shared_examples 'POST' do |base_path: '/api/v1', resource: '', key: nil|
|
64
|
-
let(:route) { "#{base_path}/#{resource}" }
|
65
|
-
let(:specific_route) { "#{route}/#{key}" }
|
66
|
-
|
67
|
-
subject { post route }
|
68
|
-
specify { expect(subject.status).to eql 201 }
|
69
|
-
end
|
70
|
-
|
71
|
-
RSpec.shared_examples 'GET all' do |base_path: '/api/v1', resource: '', key: nil|
|
72
|
-
let(:route) { "#{base_path}/#{resource}" }
|
73
|
-
let(:specific_route) { "#{route}/#{key}" }
|
74
|
-
|
75
|
-
subject { get route }
|
76
|
-
specify { expect(subject.status).to eql 200 }
|
77
|
-
end
|
78
|
-
|
79
48
|
RSpec.shared_examples 'GET specific' do |base_path: '/api/v1', resource: '', key: nil|
|
80
49
|
let(:route) { "#{base_path}/#{resource}" }
|
81
50
|
let(:specific_route) { "#{route}/#{key}" }
|
@@ -84,19 +53,19 @@ RSpec.shared_examples 'GET specific' do |base_path: '/api/v1', resource: '', key
|
|
84
53
|
specify { expect(subject.status).to eql 200 }
|
85
54
|
end
|
86
55
|
|
87
|
-
RSpec.shared_examples 'PUT specific' do |base_path: '/api/v1', resource: '', key: nil|
|
56
|
+
RSpec.shared_examples 'PUT specific' do |base_path: '/api/v1', resource: '', key: nil, params: {}|
|
88
57
|
let(:route) { "#{base_path}/#{resource}" }
|
89
58
|
let(:specific_route) { "#{route}/#{key}" }
|
90
59
|
|
91
|
-
subject { put specific_route }
|
60
|
+
subject { put specific_route, params }
|
92
61
|
specify { expect(subject.status).to eql 200 }
|
93
62
|
end
|
94
63
|
|
95
|
-
RSpec.shared_examples 'PATCH specific' do |base_path: '/api/v1', resource: '', key: nil|
|
64
|
+
RSpec.shared_examples 'PATCH specific' do |base_path: '/api/v1', resource: '', key: nil, params: {}|
|
96
65
|
let(:route) { "#{base_path}/#{resource}" }
|
97
66
|
let(:specific_route) { "#{route}/#{key}" }
|
98
67
|
|
99
|
-
subject { patch specific_route }
|
68
|
+
subject { patch specific_route, params }
|
100
69
|
specify { expect(subject.status).to eql 200 }
|
101
70
|
end
|
102
71
|
|
data/lib/starter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-starter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LeFnord
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|