arrate 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +76 -0
- data/HISTORY.md +6 -0
- data/LICENSE +19 -0
- data/README.md +53 -0
- data/Rakefile +4 -0
- data/arrate.gemspec +39 -0
- data/lib/arrate.rb +21 -0
- data/lib/arrate/version.rb +3 -0
- data/lib/templates/haml/scaffold/_form.html.haml +10 -0
- data/lib/templates/haml/scaffold/edit.html.haml +3 -0
- data/lib/templates/haml/scaffold/index.html.haml +9 -0
- data/lib/templates/haml/scaffold/new.html.haml +3 -0
- data/lib/templates/haml/scaffold/show.html.haml +7 -0
- data/lib/templates/rails/scaffold_controller/controller.rb +70 -0
- data/lib/templates/rspec/model/model_spec.rb +6 -0
- data/lib/templates/rspec/scaffold/controller_spec.rb +159 -0
- data/lib/templates/rspec/scaffold/routing_spec.rb +17 -0
- metadata +137 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dd505f6786dafff17e384c0feb8881bb6caa0e9b
|
4
|
+
data.tar.gz: ba8c6243873eb767219b588531e3b3b65564a614
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c470c36636a5469cb0e84f5e0c4a0345b19647813cf62a80e755491ab8536227ba9be6b86ee35801b2e90dc506bd4ee8505662fe304198b4ebe0f99796770f44
|
7
|
+
data.tar.gz: c111386580c3f27660677b18805e37d915bb0fbc0d94d00dcecec0af66fdc079665cdc9b91c7d0df09bd7904d2c14545680672238bf697dfb21901a0d5a39805
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
arrate (0.0.1)
|
5
|
+
factory_girl_rails
|
6
|
+
haml-rails
|
7
|
+
rspec-rails
|
8
|
+
simple_form
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
actionpack (4.0.0)
|
14
|
+
activesupport (= 4.0.0)
|
15
|
+
builder (~> 3.1.0)
|
16
|
+
erubis (~> 2.7.0)
|
17
|
+
rack (~> 1.5.2)
|
18
|
+
rack-test (~> 0.6.2)
|
19
|
+
activesupport (4.0.0)
|
20
|
+
i18n (~> 0.6, >= 0.6.4)
|
21
|
+
minitest (~> 4.2)
|
22
|
+
multi_json (~> 1.3)
|
23
|
+
thread_safe (~> 0.1)
|
24
|
+
tzinfo (~> 0.3.37)
|
25
|
+
atomic (1.1.13)
|
26
|
+
builder (3.1.4)
|
27
|
+
diff-lcs (1.2.4)
|
28
|
+
erubis (2.7.0)
|
29
|
+
factory_girl (4.2.0)
|
30
|
+
activesupport (>= 3.0.0)
|
31
|
+
factory_girl_rails (4.2.1)
|
32
|
+
factory_girl (~> 4.2.0)
|
33
|
+
railties (>= 3.0.0)
|
34
|
+
haml (4.0.3)
|
35
|
+
tilt
|
36
|
+
haml-rails (0.4)
|
37
|
+
actionpack (>= 3.1, < 4.1)
|
38
|
+
activesupport (>= 3.1, < 4.1)
|
39
|
+
haml (>= 3.1, < 4.1)
|
40
|
+
railties (>= 3.1, < 4.1)
|
41
|
+
i18n (0.6.5)
|
42
|
+
minitest (4.7.5)
|
43
|
+
multi_json (1.7.9)
|
44
|
+
rack (1.5.2)
|
45
|
+
rack-test (0.6.2)
|
46
|
+
rack (>= 1.0)
|
47
|
+
railties (4.0.0)
|
48
|
+
actionpack (= 4.0.0)
|
49
|
+
activesupport (= 4.0.0)
|
50
|
+
rake (>= 0.8.7)
|
51
|
+
thor (>= 0.18.1, < 2.0)
|
52
|
+
rake (10.1.0)
|
53
|
+
rspec-core (2.14.5)
|
54
|
+
rspec-expectations (2.14.2)
|
55
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
56
|
+
rspec-mocks (2.14.3)
|
57
|
+
rspec-rails (2.14.0)
|
58
|
+
actionpack (>= 3.0)
|
59
|
+
activesupport (>= 3.0)
|
60
|
+
railties (>= 3.0)
|
61
|
+
rspec-core (~> 2.14.0)
|
62
|
+
rspec-expectations (~> 2.14.0)
|
63
|
+
rspec-mocks (~> 2.14.0)
|
64
|
+
simple_form (1.4.1)
|
65
|
+
thor (0.18.1)
|
66
|
+
thread_safe (0.1.2)
|
67
|
+
atomic
|
68
|
+
tilt (1.4.1)
|
69
|
+
tzinfo (0.3.37)
|
70
|
+
|
71
|
+
PLATFORMS
|
72
|
+
ruby
|
73
|
+
|
74
|
+
DEPENDENCIES
|
75
|
+
arrate!
|
76
|
+
rake
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2013 Arjan van der Gaag
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Arrate: Arjan's Rails templates
|
2
|
+
|
3
|
+
## Introduction
|
4
|
+
|
5
|
+
This gem overrides some commonly used Rails generator templates to better suit
|
6
|
+
what I would normally write.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add the gem to your Gemfile:
|
11
|
+
|
12
|
+
gem 'arrate'
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
Use generators like you would normally. New templates provided by this gem will
|
17
|
+
be automatically picked up. Templates include:
|
18
|
+
|
19
|
+
* Scaffold controller
|
20
|
+
* Haml views
|
21
|
+
* RSpec controller specs
|
22
|
+
|
23
|
+
## Other
|
24
|
+
|
25
|
+
### Note on Patches/Pull Requests
|
26
|
+
|
27
|
+
1. Fork the project.
|
28
|
+
2. Make your feature addition or bug fix.
|
29
|
+
3. Add tests for it. This is important so I don't break it in a future version
|
30
|
+
unintentionally.
|
31
|
+
4. Commit, do not mess with rakefile, version, or history. (if you want to have
|
32
|
+
your own version, that is fine but bump version in a commit by itself I can
|
33
|
+
ignore when I pull)
|
34
|
+
5. Send me a pull request. Bonus points for topic branches.
|
35
|
+
|
36
|
+
### Issues
|
37
|
+
|
38
|
+
Please report any issues, defects or suggestions in the [Github issue
|
39
|
+
tracker](https://github.com/avdgaag/arrate/issues).
|
40
|
+
|
41
|
+
### What has changed?
|
42
|
+
|
43
|
+
See the [HISTORY](https://github.com/avdgaag/arrate/blob/master/HISTORY.md) file
|
44
|
+
for a detailed changelog.
|
45
|
+
|
46
|
+
### Credits
|
47
|
+
|
48
|
+
Created by: Arjan van der Gaag
|
49
|
+
URL: [http://arjanvandergaag.nl](http://arjanvandergaag.nl)
|
50
|
+
Project homepage:
|
51
|
+
[http://avdgaag.github.com/arrate](http://avdgaag.github.com/arrate)
|
52
|
+
Date: april 2012
|
53
|
+
License: [MIT-license](https://github.com/avdgaag/arrate/blob/master/LICENSE) (same as Ruby)
|
data/Rakefile
ADDED
data/arrate.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/arrate/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
# Metadata
|
6
|
+
s.name = 'arrate'
|
7
|
+
s.version = Arrate::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Arjan van der Gaag']
|
10
|
+
s.email = %q{arjan@arjanvandergaag.nl}
|
11
|
+
s.description = %q{Custom templates for Rails generators}
|
12
|
+
s.homepage = %q{http://avdgaag.github.com/arrate}
|
13
|
+
s.summary = <<-EOS
|
14
|
+
A set of templates to override default Rails generator templates that better
|
15
|
+
suit my preferences. This assumes you want to use gems like simple_form, rspec,
|
16
|
+
factory_girl and haml.
|
17
|
+
EOS
|
18
|
+
|
19
|
+
# Files
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
|
25
|
+
# Rdoc
|
26
|
+
s.rdoc_options = ['--charset=UTF-8']
|
27
|
+
s.extra_rdoc_files = [
|
28
|
+
'LICENSE',
|
29
|
+
'README.md',
|
30
|
+
'HISTORY.md'
|
31
|
+
]
|
32
|
+
|
33
|
+
# Dependencies
|
34
|
+
s.add_development_dependency 'rake'
|
35
|
+
s.add_dependency 'haml-rails'
|
36
|
+
s.add_dependency 'rspec-rails'
|
37
|
+
s.add_dependency 'factory_girl_rails'
|
38
|
+
s.add_dependency 'simple_form'
|
39
|
+
end
|
data/lib/arrate.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'arrate/version'
|
2
|
+
require 'rails'
|
3
|
+
|
4
|
+
module Arrate
|
5
|
+
module Rails
|
6
|
+
class Railtie < ::Rails::Railtie
|
7
|
+
config.app_generators do |g|
|
8
|
+
g.templates.unshift File.expand_path('../templates', __FILE__)
|
9
|
+
g.template_engine :haml
|
10
|
+
g.test_framework :rspec, fixture: true, fixture_replacement: :factory_girl
|
11
|
+
g.view_specs false
|
12
|
+
g.helper_specs false
|
13
|
+
g.helper false
|
14
|
+
g.javascripts false
|
15
|
+
g.stylesheets false
|
16
|
+
g.fixture_replacement :factory_girl, dir: 'spec/factories'
|
17
|
+
g.assets false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
= simple_form_for(<%= singular_table_name %>) do |f|
|
2
|
+
= f.error_notification
|
3
|
+
|
4
|
+
.form-inputs
|
5
|
+
<%- attributes.each do |attribute| -%>
|
6
|
+
= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %>
|
7
|
+
<%- end -%>
|
8
|
+
|
9
|
+
.form-actions
|
10
|
+
= f.button :submit
|
@@ -0,0 +1,9 @@
|
|
1
|
+
%h1 Listing <%= plural_table_name %>
|
2
|
+
|
3
|
+
= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path
|
4
|
+
|
5
|
+
- <%= plural_table_name %>.each do |<%= singular_table_name %>|
|
6
|
+
%div[<%= singular_table_name %>]
|
7
|
+
= link_to 'Show', <%= singular_table_name %>
|
8
|
+
= link_to 'Edit', [:edit, <%= singular_table_name %>]
|
9
|
+
= link_to 'Destroy', <%= singular_table_name %>, method: :delete, data: { confirm: 'Are you sure?' }
|
@@ -0,0 +1,70 @@
|
|
1
|
+
<% if namespaced? -%>
|
2
|
+
require_dependency "<%= namespaced_file_path %>/application_controller"
|
3
|
+
|
4
|
+
<% end -%>
|
5
|
+
<% module_namespacing do -%>
|
6
|
+
class <%= controller_class_name %>Controller < ApplicationController
|
7
|
+
before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
|
8
|
+
|
9
|
+
# GET <%= route_url %>
|
10
|
+
def index
|
11
|
+
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET <%= route_url %>/1
|
15
|
+
def show
|
16
|
+
end
|
17
|
+
|
18
|
+
# GET <%= route_url %>/new
|
19
|
+
def new
|
20
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>
|
21
|
+
end
|
22
|
+
|
23
|
+
# GET <%= route_url %>/1/edit
|
24
|
+
def edit
|
25
|
+
end
|
26
|
+
|
27
|
+
# POST <%= route_url %>
|
28
|
+
def create
|
29
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
|
30
|
+
|
31
|
+
if @<%= orm_instance.save %>
|
32
|
+
redirect_to @<%= singular_table_name %>, notice: t(:notice, scope: [:flash, :<%= controller_file_name %>, :create], default: <%= "'#{human_name} was successfully created.'" %>)
|
33
|
+
else
|
34
|
+
render action: 'new'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# PATCH/PUT <%= route_url %>/1
|
39
|
+
def update
|
40
|
+
if @<%= orm_instance.update("#{singular_table_name}_params") %>
|
41
|
+
redirect_to @<%= singular_table_name %>, notice: t(:notice, scope: [:flash, :<%= controller_file_name %>, :update], default: <%= "'#{human_name} was successfully updated.'" %>)
|
42
|
+
else
|
43
|
+
render action: 'edit'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# DELETE <%= route_url %>/1
|
48
|
+
def destroy
|
49
|
+
@<%= orm_instance.destroy %>
|
50
|
+
redirect_to <%= index_helper %>_url, notice: t(:notice, scope: [:flash, :<%= controller_file_name %>, :destroy], default: <%= "'#{human_name} was successfully destroyed.'" %>)
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
attr_reader :<%= singular_table_name %>
|
56
|
+
helper_method :<%= singular_table_name %>
|
57
|
+
|
58
|
+
def set_<%= singular_table_name %>
|
59
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
60
|
+
end
|
61
|
+
|
62
|
+
def <%= "#{singular_table_name}_params" %>
|
63
|
+
<%- if attributes_names.empty? -%>
|
64
|
+
params[<%= ":#{singular_table_name}" %>]
|
65
|
+
<%- else -%>
|
66
|
+
params.require(<%= ":#{singular_table_name}" %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
|
67
|
+
<%- end -%>
|
68
|
+
end
|
69
|
+
end
|
70
|
+
<% end -%>
|
@@ -0,0 +1,159 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
describe <%= controller_class_name %>Controller do
|
5
|
+
|
6
|
+
<% unless options[:singleton] -%>
|
7
|
+
describe 'GET index' do
|
8
|
+
describe 'response' do
|
9
|
+
before { get :index }
|
10
|
+
it { should render_template('index') }
|
11
|
+
it { should respond_with(:success) }
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>' do
|
15
|
+
<%= file_name %> = create :<%= file_name %>
|
16
|
+
get :index
|
17
|
+
expect(assigns(:<%= table_name %>)).to eq([<%= file_name %>])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
<% end -%>
|
22
|
+
describe 'GET show' do
|
23
|
+
let(:<%= file_name %>) { create :<%= file_name %> }
|
24
|
+
|
25
|
+
describe 'response' do
|
26
|
+
before { get :show, id: <%= file_name %>.to_param }
|
27
|
+
it { should render_template('show') }
|
28
|
+
it { should respond_with(:success) }
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>' do
|
32
|
+
get :show, id: <%= file_name %>.to_param
|
33
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'GET new' do
|
38
|
+
describe 'response' do
|
39
|
+
before { get :new }
|
40
|
+
it { should render_template('new') }
|
41
|
+
it { should respond_with(:success) }
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'assigns a new <%= ns_file_name %> as @<%= ns_file_name %>' do
|
45
|
+
get :new
|
46
|
+
expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'GET edit' do
|
51
|
+
let(:<%= file_name %>) { create :<%= file_name %> }
|
52
|
+
|
53
|
+
describe 'response' do
|
54
|
+
before { get :edit, id: <%= file_name %>.to_param }
|
55
|
+
it { should render_template('edit') }
|
56
|
+
it { should respond_with(:success) }
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>' do
|
60
|
+
get :edit, id: <%= file_name %>.to_param
|
61
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'POST create' do
|
66
|
+
describe 'with valid params' do
|
67
|
+
it 'creates a new <%= class_name %>' do
|
68
|
+
expect {
|
69
|
+
post :create, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
70
|
+
}.to change { <%= class_name %>.count }.by(1)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'assigns a newly created <%= ns_file_name %> as @<%= ns_file_name %>' do
|
74
|
+
post :create, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
75
|
+
expect(assigns(:<%= ns_file_name %>)).to be_a(<%= class_name %>)
|
76
|
+
expect(assigns(:<%= ns_file_name %>)).to be_persisted
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'redirects to the created <%= ns_file_name %>' do
|
80
|
+
post :create, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
81
|
+
expect(response).to redirect_to(<%= class_name %>.last)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe 'with invalid params' do
|
86
|
+
before do
|
87
|
+
<%= class_name %>.any_instance.stub(:save).and_return(false)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>' do
|
91
|
+
post :create, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
92
|
+
expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
|
93
|
+
end
|
94
|
+
|
95
|
+
it 're-renders the "new" template' do
|
96
|
+
post :create, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
97
|
+
expect(response).to render_template('new')
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe 'PUT update' do
|
103
|
+
let(:<%= file_name %>) { create :<%= file_name %> }
|
104
|
+
|
105
|
+
before do
|
106
|
+
allow(<%= class_name %>).to receive(:find).and_return(<%= file_name %>)
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'with valid params' do
|
110
|
+
it 'updates the requested <%= ns_file_name %>' do
|
111
|
+
expect(<%= file_name %>).to receive(:update).with(attributes_for(:<%= file_name %>).stringify_keys)
|
112
|
+
put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>' do
|
116
|
+
put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
117
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'redirects to the <%= ns_file_name %>' do
|
121
|
+
put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
122
|
+
expect(response).to redirect_to(<%= file_name %>)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe 'with invalid params' do
|
127
|
+
before do
|
128
|
+
allow(<%= file_name %>).to receive(:save).and_return(false)
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'assigns the <%= ns_file_name %> as @<%= ns_file_name %>' do
|
132
|
+
put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
133
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
134
|
+
end
|
135
|
+
|
136
|
+
it 're-renders the "edit" template' do
|
137
|
+
put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
138
|
+
expect(response).to render_template('edit')
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe 'DELETE destroy' do
|
144
|
+
let!(:<%= file_name %>) { create :<%= file_name %> }
|
145
|
+
|
146
|
+
it 'destroys the requested <%= ns_file_name %>' do
|
147
|
+
expect {
|
148
|
+
delete :destroy, id: <%= file_name %>.to_param
|
149
|
+
}.to change(<%= class_name %>, :count).by(-1)
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'redirects to the <%= table_name %> list' do
|
153
|
+
delete :destroy, id: <%= file_name %>.to_param
|
154
|
+
expect(response).to redirect_to(<%= index_helper %>_url)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
<% end -%>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
describe <%= controller_class_name %>Controller do
|
5
|
+
describe 'routing' do
|
6
|
+
<% unless options[:singleton] -%>
|
7
|
+
it { expect(get: '/<%= ns_table_name %>').to route_to('<%= ns_table_name %>#index') }
|
8
|
+
<% end -%>
|
9
|
+
it { expect(get: '/<%= ns_table_name %>/new').to route_to('<%= ns_table_name %>#new') }
|
10
|
+
it { expect(get: '/<%= ns_table_name %>/1').to route_to('<%= ns_table_name %>#show', id: '1') }
|
11
|
+
it { expect(get: '/<%= ns_table_name %>/1/edit').to route_to('<%= ns_table_name %>#edit', id: '1') }
|
12
|
+
it { expect(post: '/<%= ns_table_name %>').to route_to('<%= ns_table_name %>#create') }
|
13
|
+
it { expect(put: '/<%= ns_table_name %>/1').to route_to('<%= ns_table_name %>#update', id: '1') }
|
14
|
+
it { expect(delete: '/<%= ns_table_name %>/1').to route_to('<%= ns_table_name %>#destroy', id: '1') }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
<% end -%>
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: arrate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Arjan van der Gaag
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: haml-rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: factory_girl_rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simple_form
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Custom templates for Rails generators
|
84
|
+
email: arjan@arjanvandergaag.nl
|
85
|
+
executables: []
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files:
|
88
|
+
- LICENSE
|
89
|
+
- README.md
|
90
|
+
- HISTORY.md
|
91
|
+
files:
|
92
|
+
- .gitignore
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- HISTORY.md
|
96
|
+
- LICENSE
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- arrate.gemspec
|
100
|
+
- lib/arrate.rb
|
101
|
+
- lib/arrate/version.rb
|
102
|
+
- lib/templates/haml/scaffold/_form.html.haml
|
103
|
+
- lib/templates/haml/scaffold/edit.html.haml
|
104
|
+
- lib/templates/haml/scaffold/index.html.haml
|
105
|
+
- lib/templates/haml/scaffold/new.html.haml
|
106
|
+
- lib/templates/haml/scaffold/show.html.haml
|
107
|
+
- lib/templates/rails/scaffold_controller/controller.rb
|
108
|
+
- lib/templates/rspec/model/model_spec.rb
|
109
|
+
- lib/templates/rspec/scaffold/controller_spec.rb
|
110
|
+
- lib/templates/rspec/scaffold/routing_spec.rb
|
111
|
+
homepage: http://avdgaag.github.com/arrate
|
112
|
+
licenses: []
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options:
|
116
|
+
- --charset=UTF-8
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.0.7
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: A set of templates to override default Rails generator templates that better
|
135
|
+
suit my preferences. This assumes you want to use gems like simple_form, rspec,
|
136
|
+
factory_girl and haml.
|
137
|
+
test_files: []
|