myrails 2.2.2 → 3.0.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: 71d294e2756c1f51c7aa439017c40cbe9acd134b
4
- data.tar.gz: 9b64493afaf905a2ffa41ea735a35e50d098145a
3
+ metadata.gz: c6835e4654f3921eb1bd5e951dc1b1e9b8792af9
4
+ data.tar.gz: df6dbb5f9bb3cb4ee67014df715da12c44d3ac7e
5
5
  SHA512:
6
- metadata.gz: 279254868738a8e3f44fb2c8344387cee690b190c077f7c06101733d253b3f5e6a01de51b26026ac021527284316ec35938e6c78d86dbb55c4c3957e30d08157
7
- data.tar.gz: 101f0f0e53a1b3a508aaf8ce2fcc92768aab13f0ba8eb0e64f660770e34b9d206781329cd59f846b439ef24c80bb6ba9cd9297f7d50103e2d19054d551b90d89
6
+ metadata.gz: 22f504e636872cea1b66f945e36759e7e6044ecbcd921cdbe25986a0de3cab4a762bd8b5fe1ec31a86f53ca5fdcb5e9a4c0fbf8327b200e36a60e97a28bd116d
7
+ data.tar.gz: 70a8d6cdf73948023c7a16276d32daead723a3eb5d658bc9258dc17a4e847b32ece28cc06fd55a7e1b1345d9dbbc5c87b796feb4775d0fb069d7ccc184158a35
data/README.md CHANGED
@@ -14,7 +14,7 @@ This gem is not compatible with ruby 2.3 (yet).
14
14
 
15
15
  Use 1.1.1 if you are primarily developing in rails 3 & 4
16
16
 
17
- Use 2.x.x if are primarily developing in rails 5
17
+ Use the latest version if are primarily developing in rails 5
18
18
 
19
19
  ## Examples
20
20
 
@@ -0,0 +1,109 @@
1
+ require 'rails_helper'
2
+
3
+ describe '<%= options[:name] %> api' do
4
+ let(:headers) {{"ACCEPT" => "application/json"}}
5
+ let(:<%= options[:name] %>) {create :<%= options[:name] %>}
6
+ let(:<%= options[:name].pluralize %>) {create_list :<%= options[:name] %>, 3}
7
+
8
+ describe 'GET index' do
9
+ before do
10
+ <%= options[:name].pluralize %>
11
+ get '/<%= options[:name].pluralize %>'
12
+ end
13
+
14
+ it 'returns success status' do
15
+ expect(response).to be_success
16
+ end
17
+
18
+ it 'sets @<%= options[:name].pluralize %>' do
19
+ expect(assigns['<%= options[:name].pluralize %>']).to eq <%= options[:name].pluralize %>
20
+ end
21
+
22
+ it_behaves_like 'returns content as json' do
23
+ let(:action) {get '/<%= options[:name].pluralize %>'}
24
+ end
25
+ end
26
+
27
+ describe 'GET show' do
28
+ before {get "/<%= options[:name].pluralize %>/#{<%= options[:name] %>.id}"}
29
+
30
+ it 'returns success status' do
31
+ expect(response).to be_success
32
+ end
33
+
34
+ it 'sets @article' do
35
+ expect(assigns[:<%= options[:name] %>]).to eq <%= options[:name] %>
36
+ end
37
+
38
+ it_behaves_like 'returns content as json' do
39
+ let(:action) {get "/<%= options[:name].pluralize %>/#{<%= options[:name] %>.id}"}
40
+ end
41
+ end
42
+
43
+ describe 'POST create' do
44
+ context 'successful' do
45
+ before {post '/<%= options[:name].pluralize %>', params: {<%= options[:name] %>: {}}, headers: headers}
46
+
47
+ it 'returns created status' do
48
+ expect(response).to have_http_status :created
49
+ end
50
+
51
+ it 'sets @<%= options[:name] %>' do
52
+ expect(assigns[:<%= options[:name] %>]).to be_instance_of <%= options[:name].camelize %>
53
+ end
54
+
55
+ it_behaves_like 'returns content as json' do
56
+ let(:action) {post '/<%= options[:name].pluralize %>', params: {<%= options[:name] %>: {}}, headers: headers}
57
+ end
58
+ end
59
+
60
+ context 'unsuccessful' do
61
+ before {post '/<%= options[:name].pluralize %>', params: {<%= options[:name] %>: {}}, headers: headers}
62
+
63
+ it 'returns unprocessable_entity status' do
64
+ expect(response).to have_http_status :unprocessable_entity
65
+ end
66
+
67
+ it 'sets @<%= options[:name] %>' do
68
+ expect(assigns[:<%= options[:name] %>]).to be_a_new <%= options[:name].camelize %>
69
+ end
70
+ it_behaves_like 'returns content as json' do
71
+ let(:action) {post '/<%= options[:name].pluralize %>', params: {<%= options[:name] %>: {}}, headers: headers}
72
+ end
73
+ end
74
+ end
75
+
76
+ describe 'PUT update' do
77
+ context 'successful' do
78
+ before {put "/<%= options[:name].pluralize %>/#{<%= options[:name] %>.id}", params: {<%= options[:name] %>: {}}, headers: headers}
79
+
80
+ it 'returns success status' do
81
+ expect(response).to have_http_status :success
82
+ end
83
+
84
+ it 'sets @<%= options[:name] %>' do
85
+ expect(assigns['<%= options[:name] %>']).to eq <%= options[:name] %>
86
+ end
87
+
88
+ it_behaves_like 'returns content as json' do
89
+ let(:action) {put "/<%= options[:name].pluralize %>/#{<%= options[:name] %>.id}", params: {<%= options[:name] %>: {}}}
90
+ end
91
+ end
92
+
93
+ context 'unsuccessful' do
94
+ before {put "/<%= options[:name].pluralize %>/#{<%= options[:name] %>.id}", params: {<%= options[:name] %>: {}}, headers: headers}
95
+
96
+ it 'returns unprocessable_entity status' do
97
+ expect(response).to have_http_status :bad_request
98
+ end
99
+
100
+ it 'sets @<%= options[:name] %>' do
101
+ expect(assigns[:<%= options[:name] %>]).to eq <%= options[:name] %>
102
+ end
103
+
104
+ it_behaves_like 'returns content as json' do
105
+ let(:action) {put "/<%= options[:name].pluralize %>/#{<%= options[:name] %>.id}", params: {<%= options[:name] %>: {}}, headers: headers}
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,7 @@
1
+ shared_examples 'returns content as json' do
2
+ before {action}
3
+
4
+ it 'sends content as json' do
5
+ expect(response.content_type).to eq("application/json")
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ shared_examples '<%= options[:text] %>' do
2
+ context '<%= options[:text] %>' do
3
+ before do
4
+ action
5
+ end
6
+
7
+ it '' do
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Myrails
2
- VERSION = "2.2.2"
2
+ VERSION = "3.0.0"
3
3
  end
data/lib/myrails.rb CHANGED
@@ -87,6 +87,7 @@ gem 'rspec-rails', group: :test
87
87
  end
88
88
  run 'bundle install'
89
89
  run 'rails g rspec:install'
90
+ install_rails_helper
90
91
  copy_file 'rspec/database_cleaner.rb', "spec/support/configs/database_cleaner.rb"
91
92
  copy_file 'rspec/factory_girl.rb', 'spec/support/configs/factory_girl.rb'
92
93
  copy_file 'rspec/shoulda_matchers.rb', 'spec/support/configs/shoulda_matchers.rb'
@@ -471,6 +472,7 @@ require 'factory_girl'
471
472
  require 'database_cleaner'
472
473
  CODE
473
474
  end
475
+
474
476
  inject_into_file 'spec/rails_helper.rb', after: "RSpec.configure do |config|\n" do <<-CODE
475
477
  config.mock_with :rspec
476
478
  config.infer_base_class_for_anonymous_controllers = false
@@ -489,6 +491,33 @@ require 'database_cleaner'
489
491
  end
490
492
  end
491
493
 
494
+ desc 'shared_example', 'Generates an RSpec shared example template in the support directory'
495
+ option :text, required: true
496
+ def shared_example
497
+ template 'rspec/shared_example.rb', 'spec/support/shared_examples.rb'
498
+ end
499
+
500
+ desc 'request', 'Generates an RSpec request spec'
501
+ option :name, required: true
502
+ def request
503
+ template 'rspec/request.rb', "spec/requests/#{options[:name]}_spec.rb"
504
+ copy_file 'rspec/request_shared_example.rb', 'spec/support/request_shared_examples.rb'
505
+ end
506
+
507
+ desc 'auto_install', 'Run the most common actions in the right order'
508
+ def base_install
509
+ install_gems
510
+ install_application_helper
511
+ install_assets
512
+ install_layout
513
+ install_css
514
+ install_footer
515
+ install_ui
516
+ install_pundit
517
+ install_rspec
518
+ install_footnotes
519
+ git_init
520
+ end
492
521
  end
493
522
  end
494
523
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myrails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vell
@@ -162,7 +162,10 @@ files:
162
162
  - lib/myrails/templates/rspec/namespace_model.rb
163
163
  - lib/myrails/templates/rspec/pundit.rb
164
164
  - lib/myrails/templates/rspec/pundit_matchers.rb
165
+ - lib/myrails/templates/rspec/request.rb
166
+ - lib/myrails/templates/rspec/request_shared_example.rb
165
167
  - lib/myrails/templates/rspec/router.rb
168
+ - lib/myrails/templates/rspec/shared_example.rb
166
169
  - lib/myrails/templates/rspec/shoulda_matchers.rb
167
170
  - lib/myrails/templates/rspec/silence_backtrace.rb
168
171
  - lib/myrails/templates/ui/index.html.haml