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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d3e32d8587660f9d656a31b1bcf03e99d5ecee0
4
- data.tar.gz: 1333de3788b1b547f9c78d3074d7e21a221677a7
3
+ metadata.gz: 790b8b35a17bfad2d7d24f930e1890070a2ec310
4
+ data.tar.gz: 1c206bc897cb55fe92a9cea52ad9edcb0b2abebe
5
5
  SHA512:
6
- metadata.gz: db05a5a91a6021ad5f66cd04b1f011a97ca6270c48a45af16ed213f3f5ae9624519704c061afa1352e0ca830edf76ec30c045af680979967874b019a1391dc99
7
- data.tar.gz: 8bd05f3a709cda3d3c53c33b56f4bcf6686126dd12cc496805ea24d7993c2d9aceb17fe3be95923454ca53519d86d5d6bd26389da420b779ea7ad4e28495fa64
6
+ metadata.gz: 2c0a04b753111f99785c95ae61de3d7e79dc95e32d1b7bb15510f833454b34eb02c87d1d0290f14aeb362cf5c619cf8f878b70c970e84a30783c3bebf490977c
7
+ data.tar.gz: 3a1e06b66bf9693364b9c9b3a0200fdd96f116ebb183dcf7c315ccf891f3f1d861a1e702f6c9f810dbbf2e93b296421d5918b2f71b7788b6d97f06474c0a2c6f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### 0.2.2
2
+
3
+ - renames `remove` to `rm`
4
+ - adds params to POST, PUT and PATCH specs
5
+ - removes duplication and warning
6
+
1
7
  ### 0.2.1
2
8
 
3
9
  - allows entity removing
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 :remove do |c|
83
+ command :rm do |c|
84
84
  c.desc 'removes also entity file'
85
85
  c.switch [:e, :entity], negatable: false
86
86
 
@@ -37,13 +37,14 @@ module Starter
37
37
  end
38
38
 
39
39
  def save
40
- file_list.each do |new_file|
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
- file_list.map { |x| send("#{x}_name") }
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 put patch delete).each do |verb|
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(get put patch delete).each do |verb|
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
- # CRUD examples
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
- # singular forms
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 { post route }
30
- specify { expect(subject.status).to eql 201 }
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
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Starter
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
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.1
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-05 00:00:00.000000000 Z
11
+ date: 2016-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli