myrails 6.0.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +48 -30
  3. data/lib/myrails.rb +46 -122
  4. data/lib/myrails/modules/application_generator_actions.rb +61 -0
  5. data/lib/myrails/modules/application_generators.rb +80 -0
  6. data/lib/myrails/modules/assets.rb +28 -2
  7. data/lib/myrails/modules/bootstrap.rb +16 -12
  8. data/lib/myrails/modules/capistrano.rb +11 -6
  9. data/lib/myrails/modules/database_generator.rb +33 -0
  10. data/lib/myrails/modules/database_generator_actions.rb +18 -0
  11. data/lib/myrails/modules/devise.rb +11 -5
  12. data/lib/myrails/modules/dotenv.rb +30 -6
  13. data/lib/myrails/modules/draper.rb +29 -0
  14. data/lib/myrails/modules/engine_generator_actions.rb +117 -0
  15. data/lib/myrails/modules/engine_generators.rb +66 -0
  16. data/lib/myrails/modules/figaro.rb +18 -2
  17. data/lib/myrails/modules/gems.rb +7 -2
  18. data/lib/myrails/modules/heroku.rb +28 -9
  19. data/lib/myrails/modules/material.rb +23 -13
  20. data/lib/myrails/modules/pundit.rb +30 -6
  21. data/lib/myrails/modules/rails_generator_actions.rb +110 -0
  22. data/lib/myrails/modules/rails_generators.rb +49 -95
  23. data/lib/myrails/modules/rspec.rb +70 -40
  24. data/lib/myrails/modules/rspec_generator_actions.rb +56 -0
  25. data/lib/myrails/modules/rspec_generators.rb +36 -35
  26. data/lib/myrails/modules/ui.rb +24 -7
  27. data/lib/myrails/templates/rails/app/assets/javascripts/application.js +0 -4
  28. data/lib/myrails/templates/rails/app/controllers/controller.rb +6 -6
  29. data/lib/myrails/templates/rails/app/controllers/namespace_controller.rb +1 -1
  30. data/lib/myrails/templates/rails/app/decorators/application_decorator.rb +10 -0
  31. data/lib/myrails/templates/rails/app/decorators/decoration.rb +13 -0
  32. data/lib/myrails/templates/rails/app/helpers/application_helper.rb +0 -7
  33. data/lib/myrails/templates/rails/app/mailers/dev_mail_interceptor.rb +1 -1
  34. data/lib/myrails/templates/rails/app/models/model.rb +1 -1
  35. data/lib/myrails/templates/rails/app/models/namespace_model.rb +2 -2
  36. data/lib/myrails/templates/rails/app/policies/pundit.rb +2 -8
  37. data/lib/myrails/templates/rails/app/presenters/presenter.rb +5 -5
  38. data/lib/myrails/templates/rails/app/presenters/presenter_spec.rb +4 -4
  39. data/lib/myrails/templates/rails/app/views/layout/material/footer.html.haml +24 -0
  40. data/lib/myrails/templates/rails/config/application.example.yml +23 -23
  41. data/lib/myrails/templates/rails/config/initializers/sendgrid.rb +10 -0
  42. data/lib/myrails/templates/spec/controller.rb +37 -37
  43. data/lib/myrails/templates/spec/decorator_spec.rb +16 -0
  44. data/lib/myrails/templates/spec/factory.rb +1 -1
  45. data/lib/myrails/templates/spec/feature.rb +2 -2
  46. data/lib/myrails/templates/spec/helper.rb +1 -1
  47. data/lib/myrails/templates/spec/model.rb +1 -1
  48. data/lib/myrails/templates/spec/pundit.rb +5 -4
  49. data/lib/myrails/templates/spec/request.rb +27 -27
  50. data/lib/myrails/templates/spec/shared_example.rb +2 -2
  51. data/lib/myrails/templates/{rails/app/presenters/presenter_config.rb → spec/support/configs/decorator_presenter.rb} +0 -0
  52. data/lib/myrails/templates/ui/ui_controller.rb +1 -1
  53. data/lib/myrails/version.rb +1 -1
  54. data/myrails.gemspec +3 -3
  55. metadata +24 -15
  56. data/lib/myrails/modules/application.rb +0 -13
  57. data/lib/myrails/modules/database.rb +0 -15
  58. data/lib/myrails/modules/engine.rb +0 -107
  59. data/lib/myrails/modules/footnotes.rb +0 -19
  60. data/lib/myrails/templates/rails/app/mailers/sendgrid.rb +0 -8
@@ -1,16 +1,16 @@
1
1
  require 'rails_helper'
2
2
  #
3
- describe <%= options[:name].camelize %>Presenter do
3
+ describe <%= @name.camelize %>Presenter do
4
4
  include_behavior
5
5
 
6
- let(:presenter) {<%= options[:name].camelize %>Presenter.new(<%= options[:name] %>, view)}
7
- let(:<%= options[:name] %>) {create :<%= options[:name] %>}
6
+ let(:presenter) {<%= @name.camelize %>Presenter.new(<%= @name %>, view)}
7
+ let(:<%= @name %>) {create :<%= @name %>}
8
8
 
9
9
  it 'returns name' do
10
10
  expect(presenter.name).to eq object.attribute + " " + object.attribute
11
11
  end
12
12
 
13
13
  it 'returns edit path' do
14
- expect(presenter.edit_link).to eq link_to :Edit, edit_<%= options[:name] %>_path(<%= options[:name] %>)
14
+ expect(presenter.edit_link).to eq link_to :Edit, edit_<%= @name %>_path(<%= @name %>)
15
15
  end
16
16
  end
@@ -0,0 +1,24 @@
1
+ %footer.page-footer
2
+ .container
3
+ .row
4
+ .col.l6.s12
5
+ %h5.white-text NAME
6
+ %p.grey-text.text-lighten-4 SLOGAN
7
+ .col.l4.offset-l2.s12
8
+ %h5.white-text Connect
9
+ %ul
10
+ %li
11
+ =link_to 'Contact Me', new_contact_path, class: 'grey-text text-lighten-3'
12
+ %li
13
+ =link_to :Github, 'https://www.github.com/username', class: 'grey-text text-lighten-3', target: :blank
14
+ %li
15
+ =link_to :LinkedIn, 'https://www.linkedin.com/username', class: 'grey-text text-lighten-3', target: :blank
16
+ %li
17
+ =link_to :Twitter, 'https://twitter.com/username', class: 'grey-text text-lighten-3', target: :blank
18
+ .footer-copyright
19
+ .container
20
+ © #{Date.today.year} Full Name
21
+ -# %a.grey-text.text-lighten-4.right{:href => "#!"} More Links
22
+ %br/
23
+ Version:
24
+ =ENV.fetch('VERZION')
@@ -3,29 +3,29 @@ DB_PASS:
3
3
  EMAIL:
4
4
  DEVISE_SECRET_KEY:
5
5
  # use YAML.load(ENV['FILE_TYPES'])
6
- FILE_TYPES:
7
- - image/gif
8
- - image/jpeg
9
- - image/jpg
10
- - image/png
11
- - application/vnd.apple.keynote
12
- - application/vnd.apple.pages
13
- - application/vnd.apple.numbers
14
- - application/vnd.ms-excel
15
- - application/vnd.ms-powerpoint
16
- - application/vnd.ms-word
17
- - application/pdf
18
- - text/plain
19
- - application/zip
20
- - application/x-zip
21
- - application/x-zip-compressed
22
- # Not tested yet
23
- # - application/vnd.oasis.opendocument.text
24
- # - application/vnd.oasis.opendocument.spreadsheet
25
- # - application/vnd.oasis.opendocument.presentation
26
- # - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
27
- # - application/vnd.openxmlformats-officedocument.presentationml.presentation
28
- # - application/vnd.openxmlformats-officedocument.wordprocessingml.document
6
+ # FILE_TYPES:
7
+ # - image/gif
8
+ # - image/jpeg
9
+ # - image/jpg
10
+ # - image/png
11
+ # - application/vnd.apple.keynote
12
+ # - application/vnd.apple.pages
13
+ # - application/vnd.apple.numbers
14
+ # - application/vnd.ms-excel
15
+ # - application/vnd.ms-powerpoint
16
+ # - application/vnd.ms-word
17
+ # - application/pdf
18
+ # - text/plain
19
+ # - application/zip
20
+ # - application/x-zip
21
+ # - application/x-zip-compressed
22
+ # # Not tested yet
23
+ # # - application/vnd.oasis.opendocument.text
24
+ # # - application/vnd.oasis.opendocument.spreadsheet
25
+ # # - application/vnd.oasis.opendocument.presentation
26
+ # # - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
27
+ # # - application/vnd.openxmlformats-officedocument.presentationml.presentation
28
+ # # - application/vnd.openxmlformats-officedocument.wordprocessingml.document
29
29
  # - application/octet-stream
30
30
  development:
31
31
  DEFAULT_HOST: 'http://localhost:3000'
@@ -0,0 +1,10 @@
1
+ config.action_mailer.delivery_method = :smtp
2
+ config.action_mailer.smtp_settings = {
3
+ address: 'smtp.sendgrid.net',
4
+ port: 587,
5
+ domain: 'yourdomain.com',
6
+ user_name: 'someuser',
7
+ password: 'somepassword',
8
+ authentication: 'plain',
9
+ enable_starttls_auto: true
10
+ }
@@ -1,49 +1,49 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe <%= options[:name].pluralize.camelize %>Controller do
3
+ describe <%= @name.pluralize.camelize %>Controller do
4
4
  # let(:user) {create :user}
5
- let(:<%= options[:name].pluralize %>) {create_list :<%= options[:name] %>, 3 }
6
- let(:<%= options[:name].singularize %>) {create :<%= options[:name].singularize %>}
5
+ let(:<%= @name.pluralize %>) {create_list :<%= @name %>, 3 }
6
+ let(:<%= @name.singularize %>) {create :<%= @name.singularize %>}
7
7
 
8
8
  # before {sign_in user}
9
9
 
10
10
  describe 'GET index' do
11
11
  before do
12
- <%= options[:name].pluralize %>
12
+ <%= @name.pluralize %>
13
13
  get :index
14
14
  end
15
15
 
16
- subject {assigns[:<%= options[:name].pluralize %>]}
16
+ subject {assigns[:<%= @name.pluralize %>]}
17
17
 
18
- it {is_expected.to eq <%= options[:name].pluralize %>}
18
+ it {is_expected.to eq <%= @name.pluralize %>}
19
19
  end
20
20
 
21
21
  describe 'GET show' do
22
- before {get :show, params: {id: <%= options[:name].singularize %>}}
22
+ before {get :show, params: {id: <%= @name.singularize %>}}
23
23
 
24
- subject(:<%= options[:name].first %>) {assigns[:<%= options[:name].singularize %>]}
24
+ subject(:<%= @name.first %>) {assigns[:<%= @name.singularize %>]}
25
25
 
26
- it {is_expected.to eq <%= options[:name].singularize %>}
26
+ it {is_expected.to eq <%= @name.singularize %>}
27
27
  end
28
28
 
29
29
  describe 'GET new' do
30
30
  before {get :new}
31
31
 
32
- subject(:<%= options[:name].first %>) {assigns[:<%= options[:name].singularize %>]}
32
+ subject(:<%= @name.first %>) {assigns[:<%= @name.singularize %>]}
33
33
 
34
- it {is_expected.to be_a_new <%= options[:name].singularize.camelize %>}
34
+ it {is_expected.to be_a_new <%= @name.singularize.camelize %>}
35
35
  end
36
36
 
37
37
  describe 'POST create' do
38
38
  context 'successful create' do
39
- before {post :create, params: {<%= options[:name].singularize %>: attributes_for(:<%= options[:name].singularize %>)}}
39
+ before {post :create, params: {<%= @name.singularize %>: attributes_for(:<%= @name.singularize %>)}}
40
40
 
41
- subject(:<%= options[:name].first %>){assigns[:<%= options[:name].singularize %>]}
41
+ subject(:<%= @name.first %>){assigns[:<%= @name.singularize %>]}
42
42
 
43
43
  it 'redirects to :show'
44
- it {is_expected.to be_instance_of <%= options[:name].singularize.camelize %>}
44
+ it {is_expected.to be_instance_of <%= @name.singularize.camelize %>}
45
45
 
46
- it 'sets flash[:success]' do
46
+ it 'sets flash message' do
47
47
  expect(flash[:success]).to_not be_nil
48
48
  end
49
49
 
@@ -51,72 +51,72 @@ describe <%= options[:name].pluralize.camelize %>Controller do
51
51
  end
52
52
 
53
53
  context 'unsuccessful create' do
54
- before {post :create, params: {<%= options[:name].singularize %>: attributes_for(:<%= options[:name].singularize %>, attr: nil)}}
54
+ before {post :create, params: {<%= @name.singularize %>: attributes_for(:<%= @name.singularize %>, attr: nil)}}
55
55
 
56
- subject(:<%= options[:name].first %>){assigns[:<%= options[:name].singularize %>]}
56
+ subject(:<%= @name.first %>){assigns[:<%= @name.singularize %>]}
57
57
 
58
58
  it 'renders :new template'
59
- it {is_expected.to be_a_new <%= options[:name].singularize.camelize %>}
59
+ it {is_expected.to be_a_new <%= @name.singularize.camelize %>}
60
60
 
61
- it 'sets flash[:error]' do
61
+ it 'sets flash message' do
62
62
  expect(flash[:error]).to_not be_nil
63
63
  end
64
64
  end
65
65
  end
66
66
 
67
67
  describe 'GET edit' do
68
- before {get :edit, params: {id: <%= options[:name].singularize %>}}
68
+ before {get :edit, params: {id: <%= @name.singularize %>}}
69
69
 
70
- subject(:<%= options[:name].first %>){assigns[:<%= options[:name].singularize %>]}
70
+ subject(:<%= @name.first %>){assigns[:<%= @name.singularize %>]}
71
71
 
72
- it {is_expected.to eq <%= options[:name].singularize %>}
72
+ it {is_expected.to eq <%= @name.singularize %>}
73
73
  end
74
74
 
75
75
  describe 'PUT/PATCH update' do
76
76
  context 'successful update' do
77
- before {put :update, params: {id: <%= options[:name].singularize %>, <%= options[:name].singularize %>: attributes_for(:<%= options[:name].singularize %>)}}
77
+ before {put :update, params: {id: <%= @name.singularize %>, <%= @name.singularize %>: attributes_for(:<%= @name.singularize %>)}}
78
78
 
79
- subject(:<%= options[:name].first %>) {assigns[:<%= options[:name].singularize %>]}
79
+ subject(:<%= @name.first %>) {assigns[:<%= @name.singularize %>]}
80
80
 
81
81
  it 'redirects to :show'
82
- it {is_expected.to eq <%= options[:name].singularize %>}
82
+ it {is_expected.to eq <%= @name.singularize %>}
83
83
 
84
- it 'sets flash[:success]' do
84
+ it 'sets flash message' do
85
85
  expect(flash[:success]).to_not be_nil
86
86
  end
87
87
  it 'tags current_user as updater'
88
88
  end
89
89
 
90
90
  context 'unsuccessful update' do
91
- before {put :update, params: {id: <%= options[:name].singularize %>, <%= options[:name].singularize %>: attributes_for(:<%= options[:name].singularize %>, attr: nil)}}
91
+ before {put :update, params: {id: <%= @name.singularize %>, <%= @name.singularize %>: attributes_for(:<%= @name.singularize %>, attr: nil)}}
92
92
 
93
- subject(:<%= options[:name].first %>) {assigns[:<%= options[:name].singularize %>]}
93
+ subject(:<%= @name.first %>) {assigns[:<%= @name.singularize %>]}
94
94
 
95
95
  it 'renders :edit template'
96
- it {is_expected.to eq <%= options[:name].singularize %>}
96
+ it {is_expected.to eq <%= @name.singularize %>}
97
97
 
98
- it 'sets flash[:error]' do
98
+ it 'sets flash message' do
99
99
  expect(flash[:error]).to_not be_nil
100
100
  end
101
101
  end
102
102
  end
103
103
 
104
104
  describe 'DELETE destroy' do
105
- before {delete :destroy, params: {id: <%= options[:name].singularize %>}}
105
+ before {delete :destroy, params: {id: <%= @name.singularize %>}}
106
106
 
107
- subject(:<%= options[:name].first %>) {assigns[:<%= options[:name].singularize %>]}
107
+ subject(:<%= @name.first %>) {assigns[:<%= @name.singularize %>]}
108
108
 
109
109
  it 'redirects to :index' do
110
- expect(response).to redirect_to <%= options[:name].pluralize %>_path
110
+ expect(response).to redirect_to <%= @name.pluralize %>_path
111
111
  end
112
112
 
113
- it {is_expected.to eq <%= options[:name].singularize %>}
113
+ it {is_expected.to eq <%= @name.singularize %>}
114
114
 
115
- it 'deletes @<%= options[:name].singularize %>' do
116
- expect(<%= options[:name].singularize.camelize %>.find_by_id(<%= options[:name].singularize %>.id)).to be_nil
115
+ it 'deletes @<%= @name.singularize %>' do
116
+ expect(<%= @name.singularize.camelize %>.find_by_id(<%= @name.singularize %>.id)).to be_nil
117
117
  end
118
118
 
119
- it 'sets flash[success]' do
119
+ it 'sets flash message' do
120
120
  expect(flash[:success]).to_not be_nil
121
121
  end
122
122
  end
@@ -0,0 +1,16 @@
1
+ require 'rails_helper'
2
+
3
+ describe <%= @name.camelize %>Decorator do
4
+ include_behavior
5
+
6
+ let(:decorator) {<%= @name.camelize %>Decorator.new(<%= @name %>, view)}
7
+ let(:<%= @name %>) {create :<%= @name %>}
8
+
9
+ it 'returns name' do
10
+ expect(decorator.name).to eq object.attribute + " " + object.attribute
11
+ end
12
+
13
+ it 'returns edit path' do
14
+ expect(decorator.edit_link).to eq link_to :Edit, edit_<%= @name %>_path(<%= @name %>)
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  FactoryBot.define do
2
- factory :<%= options[:name].gsub("/", "_") %>, class: "<%= options[:name].camelize %>" do
2
+ factory :<%= @name.gsub("/", "_") %>, class: "<%= @name.camelize %>" do
3
3
 
4
4
  end
5
5
  end
@@ -1,8 +1,8 @@
1
1
  require 'rails_helper'
2
2
 
3
- feature 'some-object management' do
3
+ feature '<%= @description %>' do
4
4
  let(:var){}
5
5
  before {}
6
- scenario 'scenario text' do
6
+ scenario '<%= @scenario %>' do
7
7
  end
8
8
  end
@@ -1,2 +1,2 @@
1
- module <%= options[:name].gsub("\s", '_').camelize %>Helper
1
+ module <%= @param.gsub("\s", '_').camelize %>Helper
2
2
  end
@@ -1,4 +1,4 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe <%= options[:name].camelize %> do
3
+ describe <%= @name.camelize %> do
4
4
  end
@@ -1,9 +1,10 @@
1
1
  # Use with Pundit Matches: https://github.com/chrisalley/pundit-matchers
2
2
  require 'rails_helper'
3
- describe <%= options[:name].camelize %>Policy do
4
- subject { <%= options[:name].camelize %>Policy.new(user, <%= options[:name].split("/").last %>) }
5
3
 
6
- let(:<%= options[:name].split("/").last %>) { create :<%= options[:name].gsub("/", "_") %> }
4
+ describe <%= @name.camelize %>Policy do
5
+ subject { <%= @name.camelize %>Policy.new(user, <%= @name.split("/").last %>) }
6
+
7
+ let(:<%= @name.split("/").last %>) { create :<%= @name.gsub("/", "_") %> }
7
8
 
8
9
  context 'for a visitor' do
9
10
  it {is_expected.to permit_action(:new)}
@@ -16,7 +17,7 @@ describe <%= options[:name].camelize %>Policy do
16
17
 
17
18
  context "for an admin" do
18
19
 
19
- let(:user) { <%= options[:name].split("/").last %>.user }
20
+ let(:user) { <%= @name.split("/").last %>.user }
20
21
 
21
22
  it {is_expected.to permit_action(:new)}
22
23
  it {is_expected.to permit_action(:create)}
@@ -1,108 +1,108 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe '<%= options[:name] %> api' do
3
+ describe '<%= @param %> api' do
4
4
  let(:headers) {{"ACCEPT" => "application/json"}}
5
- let(:<%= options[:name] %>) {create :<%= options[:name] %>}
6
- let(:<%= options[:name].pluralize %>) {create_list :<%= options[:name] %>, 3}
5
+ let(:<%= @param %>) {create :<%= @param %>}
6
+ let(:<%= @param.pluralize %>) {create_list :<%= @param %>, 3}
7
7
 
8
8
  describe 'GET index' do
9
9
  before do
10
- <%= options[:name].pluralize %>
11
- get '/<%= options[:name].pluralize %>'
10
+ <%= @param.pluralize %>
11
+ get '/<%= @param.pluralize %>'
12
12
  end
13
13
 
14
14
  it 'returns success status' do
15
15
  expect(response).to be_success
16
16
  end
17
17
 
18
- it 'sets @<%= options[:name].pluralize %>' do
19
- expect(assigns['<%= options[:name].pluralize %>']).to eq <%= options[:name].pluralize %>
18
+ it 'sets @<%= @param.pluralize %>' do
19
+ expect(assigns['<%= @param.pluralize %>']).to eq <%= @param.pluralize %>
20
20
  end
21
21
 
22
22
  it_behaves_like 'returns content as json' do
23
- let(:action) {get '/<%= options[:name].pluralize %>'}
23
+ let(:action) {get '/<%= @param.pluralize %>'}
24
24
  end
25
25
  end
26
26
 
27
27
  describe 'GET show' do
28
- before {get "/<%= options[:name].pluralize %>/#{<%= options[:name] %>.id}"}
28
+ before {get "/<%= @param.pluralize %>/#{<%= @param %>.id}"}
29
29
 
30
30
  it 'returns success status' do
31
31
  expect(response).to be_success
32
32
  end
33
33
 
34
34
  it 'sets @article' do
35
- expect(assigns[:<%= options[:name] %>]).to eq <%= options[:name] %>
35
+ expect(assigns[:<%= @param %>]).to eq <%= @param %>
36
36
  end
37
37
 
38
38
  it_behaves_like 'returns content as json' do
39
- let(:action) {get "/<%= options[:name].pluralize %>/#{<%= options[:name] %>.id}"}
39
+ let(:action) {get "/<%= @param.pluralize %>/#{<%= @param %>.id}"}
40
40
  end
41
41
  end
42
42
 
43
43
  describe 'POST create' do
44
44
  context 'successful' do
45
- before {post '/<%= options[:name].pluralize %>', params: {<%= options[:name] %>: {}}, headers: headers}
45
+ before {post '/<%= @param.pluralize %>', params: {<%= @param %>: {}}, headers: headers}
46
46
 
47
47
  it 'returns created status' do
48
48
  expect(response).to have_http_status :created
49
49
  end
50
50
 
51
- it 'sets @<%= options[:name] %>' do
52
- expect(assigns[:<%= options[:name] %>]).to be_instance_of <%= options[:name].camelize %>
51
+ it 'sets @<%= @param %>' do
52
+ expect(assigns[:<%= @param %>]).to be_instance_of <%= @param.camelize %>
53
53
  end
54
54
 
55
55
  it_behaves_like 'returns content as json' do
56
- let(:action) {post '/<%= options[:name].pluralize %>', params: {<%= options[:name] %>: {}}, headers: headers}
56
+ let(:action) {post '/<%= @param.pluralize %>', params: {<%= @param %>: {}}, headers: headers}
57
57
  end
58
58
  end
59
59
 
60
60
  context 'unsuccessful' do
61
- before {post '/<%= options[:name].pluralize %>', params: {<%= options[:name] %>: {}}, headers: headers}
61
+ before {post '/<%= @param.pluralize %>', params: {<%= @param %>: {}}, headers: headers}
62
62
 
63
63
  it 'returns unprocessable_entity status' do
64
64
  expect(response).to have_http_status :unprocessable_entity
65
65
  end
66
66
 
67
- it 'sets @<%= options[:name] %>' do
68
- expect(assigns[:<%= options[:name] %>]).to be_a_new <%= options[:name].camelize %>
67
+ it 'sets @<%= @param %>' do
68
+ expect(assigns[:<%= @param %>]).to be_a_new <%= @param.camelize %>
69
69
  end
70
70
  it_behaves_like 'returns content as json' do
71
- let(:action) {post '/<%= options[:name].pluralize %>', params: {<%= options[:name] %>: {}}, headers: headers}
71
+ let(:action) {post '/<%= @param.pluralize %>', params: {<%= @param %>: {}}, headers: headers}
72
72
  end
73
73
  end
74
74
  end
75
75
 
76
76
  describe 'PUT update' do
77
77
  context 'successful' do
78
- before {put "/<%= options[:name].pluralize %>/#{<%= options[:name] %>.id}", params: {<%= options[:name] %>: {}}, headers: headers}
78
+ before {put "/<%= @param.pluralize %>/#{<%= @param %>.id}", params: {<%= @param %>: {}}, headers: headers}
79
79
 
80
80
  it 'returns success status' do
81
81
  expect(response).to have_http_status :success
82
82
  end
83
83
 
84
- it 'sets @<%= options[:name] %>' do
85
- expect(assigns['<%= options[:name] %>']).to eq <%= options[:name] %>
84
+ it 'sets @<%= @param %>' do
85
+ expect(assigns['<%= @param %>']).to eq <%= @param %>
86
86
  end
87
87
 
88
88
  it_behaves_like 'returns content as json' do
89
- let(:action) {put "/<%= options[:name].pluralize %>/#{<%= options[:name] %>.id}", params: {<%= options[:name] %>: {}}}
89
+ let(:action) {put "/<%= @param.pluralize %>/#{<%= @param %>.id}", params: {<%= @param %>: {}}}
90
90
  end
91
91
  end
92
92
 
93
93
  context 'unsuccessful' do
94
- before {put "/<%= options[:name].pluralize %>/#{<%= options[:name] %>.id}", params: {<%= options[:name] %>: {}}, headers: headers}
94
+ before {put "/<%= @param.pluralize %>/#{<%= @param %>.id}", params: {<%= @param %>: {}}, headers: headers}
95
95
 
96
96
  it 'returns unprocessable_entity status' do
97
97
  expect(response).to have_http_status :bad_request
98
98
  end
99
99
 
100
- it 'sets @<%= options[:name] %>' do
101
- expect(assigns[:<%= options[:name] %>]).to eq <%= options[:name] %>
100
+ it 'sets @<%= @param %>' do
101
+ expect(assigns[:<%= @param %>]).to eq <%= @param %>
102
102
  end
103
103
 
104
104
  it_behaves_like 'returns content as json' do
105
- let(:action) {put "/<%= options[:name].pluralize %>/#{<%= options[:name] %>.id}", params: {<%= options[:name] %>: {}}, headers: headers}
105
+ let(:action) {put "/<%= @param.pluralize %>/#{<%= @param %>.id}", params: {<%= @param %>: {}}, headers: headers}
106
106
  end
107
107
  end
108
108
  end