kitestrings 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +10 -0
- data/kitestrings.gemspec +28 -0
- data/lib/array_validator.rb +22 -0
- data/lib/async.rb +26 -0
- data/lib/form_object.rb +96 -0
- data/lib/generators/kitestrings/install_generator.rb +41 -0
- data/lib/generators/kitestrings/messages_generator.rb +11 -0
- data/lib/generators/kitestrings/templates/message.rb.erb +56 -0
- data/lib/generators/templates/deploy.rb +136 -0
- data/lib/generators/templates/deploy/integ.rb +21 -0
- data/lib/generators/templates/deploy/production.rb +26 -0
- data/lib/generators/templates/deploy/uat.rb +23 -0
- data/lib/generators/templates/haml/scaffold/_form.html.haml +17 -0
- data/lib/generators/templates/haml/scaffold/edit.html.haml +6 -0
- data/lib/generators/templates/haml/scaffold/index.html.haml +27 -0
- data/lib/generators/templates/haml/scaffold/new.html.haml +6 -0
- data/lib/generators/templates/haml/scaffold/show.html.haml +10 -0
- data/lib/generators/templates/rails/scaffold_controller/controller.rb +62 -0
- data/lib/generators/templates/rspec/helper/helper_spec.rb +17 -0
- data/lib/generators/templates/rspec/integration/request.rb +4 -0
- data/lib/generators/templates/rspec/model/model_spec.rb +14 -0
- data/lib/generators/templates/rspec/scaffold/controller_spec.rb +131 -0
- data/lib/generators/templates/rspec/scaffold/routing_spec.rb +18 -0
- data/lib/generators/templates/spec_ext/my_ip_spec.rb +7 -0
- data/lib/generators/templates/spec_ext/spec_helper_ext.rb +37 -0
- data/lib/generators/templates/views/application/_navigation.html.haml +0 -0
- data/lib/generators/templates/views/layouts/application.html.haml +23 -0
- data/lib/kitestrings.rb +6 -0
- data/lib/kitestrings/railtie.rb +15 -0
- data/lib/kitestrings/version.rb +3 -0
- data/lib/page_and_sort_helper.rb +99 -0
- data/lib/size_validator.rb +22 -0
- data/lib/tasks/test_prepare_after_migrate.rake +11 -0
- data/lib/uniqueness_without_deleted_validator.rb +7 -0
- data/spec/lib/array_validator_spec.rb +40 -0
- data/spec/lib/async_spec.rb +49 -0
- data/spec/lib/generators/kitestrings/install_generator_spec.rb +53 -0
- data/spec/lib/generators/kitestrings/messages_generator_spec.rb +19 -0
- data/spec/lib/page_and_sort_helper_spec.rb +96 -0
- data/spec/lib/size_validator_spec.rb +40 -0
- data/spec/spec_helper.rb +17 -0
- metadata +181 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
set :rails_env, 'integ'
|
2
|
+
|
3
|
+
set :rvm_ruby_string, "2.1.1"
|
4
|
+
|
5
|
+
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
|
6
|
+
|
7
|
+
set :rvm_install_ruby_params, '--verify-downloads 1'
|
8
|
+
set :rvm_type, :user
|
9
|
+
set :branch, 'develop'
|
10
|
+
|
11
|
+
|
12
|
+
#default_run_option[:pty] = true
|
13
|
+
ssh_options[:forward_agent] = true
|
14
|
+
|
15
|
+
|
16
|
+
# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
|
17
|
+
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
|
18
|
+
|
19
|
+
|
20
|
+
before 'deploy:setup', 'rvm:install_rvm' # update RVM
|
21
|
+
before 'deploy:setup', 'rvm:install_ruby'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
set :rails_env, 'production'
|
2
|
+
|
3
|
+
#set :rvm_ruby_string, "1.9.3-p125@pwi_#{rails_env}"
|
4
|
+
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
|
5
|
+
|
6
|
+
set :rvm_install_ruby_params, '--verify-downloads 1'
|
7
|
+
set :rvm_type, :user
|
8
|
+
set :branch, 'master'
|
9
|
+
|
10
|
+
#default_run_option[:pty] = true
|
11
|
+
ssh_options[:forward_agent] = true
|
12
|
+
|
13
|
+
|
14
|
+
# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
|
15
|
+
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
|
16
|
+
|
17
|
+
|
18
|
+
#server 'standby.unitedsynergies.com.au', :web, :app, :db, primary: true
|
19
|
+
|
20
|
+
|
21
|
+
before 'deploy:setup', 'rvm:install_rvm' # update RVM
|
22
|
+
before 'deploy:setup', 'rvm:install_ruby'
|
23
|
+
|
24
|
+
after 'deploy:update_code' do
|
25
|
+
run "cd #{release_path}; RAILS_ENV=#{rails_env} bundle exec rake assets:precompile"
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
set :rails_env, 'uat'
|
2
|
+
|
3
|
+
#set :rvm_ruby_string, "1.9.3-p125@pwi_#{rails_env}"
|
4
|
+
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
|
5
|
+
|
6
|
+
set :rvm_install_ruby_params, '--verify-downloads 1'
|
7
|
+
set :rvm_type, :user
|
8
|
+
set :branch, 'develop'
|
9
|
+
|
10
|
+
|
11
|
+
#default_run_option[:pty] = true
|
12
|
+
ssh_options[:forward_agent] = true
|
13
|
+
|
14
|
+
|
15
|
+
# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
|
16
|
+
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
|
17
|
+
|
18
|
+
|
19
|
+
#server 'standby.unitedsynergies.com.au', :web, :app, :db, primary: true
|
20
|
+
|
21
|
+
|
22
|
+
before 'deploy:setup', 'rvm:install_rvm' # update RVM
|
23
|
+
before 'deploy:setup', 'rvm:install_ruby'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
= form_for @<%= singular_table_name %>, html: { "role" =>"form", class: "form-horizontal"} do |f|
|
2
|
+
- if @<%= singular_table_name %>.errors.any?
|
3
|
+
#error_explanation
|
4
|
+
%h2= "#{pluralize(@<%= singular_table_name %>.errors.count, 'error')} prohibited this <%= singular_table_name %> from being saved:"
|
5
|
+
%ul
|
6
|
+
- @<%= singular_table_name %>.errors.full_messages.each do |msg|
|
7
|
+
%li= msg
|
8
|
+
|
9
|
+
<% for attribute in attributes -%>
|
10
|
+
.form-group
|
11
|
+
= f.label :<%= attribute.name %>, class: 'col-md-2 control-label'
|
12
|
+
.col-md-6
|
13
|
+
= f.<%= attribute.field_type %> :<%= attribute.name %>, class: 'form-control input-sm'
|
14
|
+
<% end -%>
|
15
|
+
.form-group
|
16
|
+
.col-md-6.col-md-offset-2
|
17
|
+
= f.submit 'Save', class: 'btn btn-success btn-sm'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
.page-header
|
2
|
+
%h1 Listing <%= plural_table_name %>
|
3
|
+
|
4
|
+
.row
|
5
|
+
.col-md-12
|
6
|
+
%table.table.table-striped
|
7
|
+
%tr
|
8
|
+
<% for attribute in attributes -%>
|
9
|
+
%th <%= attribute.human_name %>
|
10
|
+
<% end -%>
|
11
|
+
|
12
|
+
|
13
|
+
- @<%= plural_table_name %>.each do |<%= singular_table_name %>|
|
14
|
+
%tr
|
15
|
+
<% @first = true -%>
|
16
|
+
<% for attribute in attributes -%>
|
17
|
+
<% if @first -%>
|
18
|
+
<% @first = false -%>
|
19
|
+
%td= link_to <%= singular_table_name %>.<%= attribute.name %>, <%= singular_table_name %>_path(<%= singular_table_name %>)
|
20
|
+
<% else -%>
|
21
|
+
%td= <%= singular_table_name %>.<%= attribute.name %>
|
22
|
+
<% end -%>
|
23
|
+
<% end -%>
|
24
|
+
|
25
|
+
%br
|
26
|
+
|
27
|
+
= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path, id: :new_<%= singular_table_name %>_link, class: 'btn btn-primary btn-sm'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
.row
|
2
|
+
.col-md-12
|
3
|
+
|
4
|
+
<% for attribute in attributes -%>
|
5
|
+
%p
|
6
|
+
%b <%= attribute.human_name %>:
|
7
|
+
= @<%= singular_table_name %>.<%= attribute.name %>
|
8
|
+
<% end -%>
|
9
|
+
|
10
|
+
= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), id: :edit_<%= singular_table_name %>_link, class: 'btn btn-sm btn-primary'
|
@@ -0,0 +1,62 @@
|
|
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
|
+
def index
|
10
|
+
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
|
11
|
+
end
|
12
|
+
|
13
|
+
def show
|
14
|
+
end
|
15
|
+
|
16
|
+
def new
|
17
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>
|
18
|
+
end
|
19
|
+
|
20
|
+
def edit
|
21
|
+
end
|
22
|
+
|
23
|
+
# POST <%= route_url %>
|
24
|
+
def create
|
25
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
|
26
|
+
|
27
|
+
if @<%= orm_instance.save %>
|
28
|
+
redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully created.'" %>
|
29
|
+
else
|
30
|
+
render :new
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def update
|
35
|
+
if @<%= orm_instance.update("#{singular_table_name}_params") %>
|
36
|
+
redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully updated.'" %>
|
37
|
+
else
|
38
|
+
render :edit
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def destroy
|
43
|
+
@<%= orm_instance.destroy %>
|
44
|
+
redirect_to <%= index_helper %>_url, notice: <%= "'#{human_name} was successfully destroyed.'" %>
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
# Use callbacks to share common setup or constraints between actions.
|
49
|
+
def set_<%= singular_table_name %>
|
50
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
51
|
+
end
|
52
|
+
|
53
|
+
# Only allow a trusted parameter "white list" through.
|
54
|
+
def <%= "#{singular_table_name}_params" %>
|
55
|
+
<%- if attributes_names.empty? -%>
|
56
|
+
params[:<%= singular_table_name %>]
|
57
|
+
<%- else -%>
|
58
|
+
params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
|
59
|
+
<%- end -%>
|
60
|
+
end
|
61
|
+
end
|
62
|
+
<% end -%>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Specs in this file have access to a helper object that includes
|
4
|
+
# the <%= class_name %>Helper. For example:
|
5
|
+
#
|
6
|
+
# describe <%= class_name %>Helper do
|
7
|
+
# describe "string concat" do
|
8
|
+
# it "concats two strings with spaces" do
|
9
|
+
# helper.concat_strings("this","that").should == "this that"
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
<% module_namespacing do -%>
|
14
|
+
describe <%= class_name %>Helper do
|
15
|
+
|
16
|
+
end
|
17
|
+
<% end -%>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
describe <%= class_name %> do
|
5
|
+
|
6
|
+
common_lets
|
7
|
+
|
8
|
+
# define the <%= file_name %>, <%= file_name %>_other,... instances in
|
9
|
+
# spec/support/common_lets.rb
|
10
|
+
it { expect(<%= file_name %>).to be_valid }
|
11
|
+
# it { expect(<%= file_name %>_other).to be_valid }
|
12
|
+
|
13
|
+
end
|
14
|
+
<% end -%>
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
describe <%= controller_class_name %>Controller do
|
5
|
+
render_views
|
6
|
+
common_lets
|
7
|
+
|
8
|
+
before :all do
|
9
|
+
Fracture.define_selector :new_<%= file_name %>_link
|
10
|
+
Fracture.define_selector :cancel_new_<%= file_name %>_link
|
11
|
+
Fracture.define_selector :edit_<%= file_name %>_link
|
12
|
+
Fracture.define_selector :cancel_edit_<%= file_name %>_link
|
13
|
+
end
|
14
|
+
|
15
|
+
# stub strong params
|
16
|
+
before { controller.stub(<%= file_name %>_params: {}) }
|
17
|
+
|
18
|
+
context 'not logged in' do
|
19
|
+
before do
|
20
|
+
sign_out :user
|
21
|
+
end
|
22
|
+
|
23
|
+
{index: :get, show: :get, new: :get, create: :post, edit: :get, update: :put, destroy: :delete}.each do |v, m|
|
24
|
+
it "#{m} #{v} should logout" do
|
25
|
+
self.send(m, v, id: <%= file_name %>)
|
26
|
+
should redirect_to new_user_session_path
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'logged in as user' do
|
32
|
+
before { sign_in user }
|
33
|
+
|
34
|
+
<% unless options[:singleton] -%>
|
35
|
+
describe 'GET index' do
|
36
|
+
before do
|
37
|
+
<%= file_name %>; <%= file_name %>_other
|
38
|
+
get :index
|
39
|
+
end
|
40
|
+
|
41
|
+
it { should assign_to(:<%= table_name %>).with_items([<%= file_name %>]) }
|
42
|
+
it { should render_template :index }
|
43
|
+
it { should have_only_fractures(:new_<%= file_name %>_link) }
|
44
|
+
end
|
45
|
+
|
46
|
+
<% end -%>
|
47
|
+
describe 'GET show' do
|
48
|
+
before { get :show, id: <%= file_name %> }
|
49
|
+
|
50
|
+
it { should assign_to(:<%= file_name %>).with(<%= file_name %>) }
|
51
|
+
it { should render_template :show }
|
52
|
+
it { should have_only_fractures(:edit_<%= file_name %>_link) }
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'GET new' do
|
56
|
+
before { get :new }
|
57
|
+
|
58
|
+
it { should assign_to(:<%= file_name %>).with_kind_of(<%= class_name %>) }
|
59
|
+
#it { should assign_to('<%= file_name %>.parent').with(parent) }
|
60
|
+
it { should render_template :new }
|
61
|
+
it { should have_only_fractures :cancel_new_<%= file_name %>_link }
|
62
|
+
it { should have_a_form.that_is_new.with_path_of(<%= table_name %>_path)}
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'POST create' do
|
66
|
+
context 'valid' do
|
67
|
+
before do
|
68
|
+
<%= class_name %>.any_instance.stub(:valid?).and_return(true)
|
69
|
+
post :create
|
70
|
+
end
|
71
|
+
|
72
|
+
it { should redirect_to <%= file_name %>_path(<%= class_name %>.last) }
|
73
|
+
it { should assign_to(:<%= file_name %>).with(<%= class_name %>.last) }
|
74
|
+
#it { should assign_to('<%= file_name %>.parent').with(parent) }
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'invalid' do
|
78
|
+
before do
|
79
|
+
<%= class_name %>.any_instance.stub(:valid?).and_return(false)
|
80
|
+
post :create
|
81
|
+
end
|
82
|
+
it { should assign_to(:<%= file_name %>).with_kind_of(<%= class_name %>) }
|
83
|
+
#it { should assign_to('<%= file_name %>.parent').with(parent) }
|
84
|
+
it { should render_template :new }
|
85
|
+
it { should have_only_fractures :cancel_new_<%= file_name %>_link }
|
86
|
+
it { should have_a_form.that_is_new.with_path_of(<%= table_name %>_path)}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe 'GET edit' do
|
91
|
+
before { get :edit, id: <%= file_name %> }
|
92
|
+
|
93
|
+
it { should assign_to(:<%= file_name %>).with(<%= file_name %>) }
|
94
|
+
it { should render_template :edit }
|
95
|
+
it { should have_only_fractures :cancel_edit_<%= file_name %>_link }
|
96
|
+
it { should have_a_form.that_is_edit.with_path_of(<%= file_name %>_path) }
|
97
|
+
end
|
98
|
+
|
99
|
+
describe 'PUT update' do
|
100
|
+
context 'valid' do
|
101
|
+
before do
|
102
|
+
<%= class_name %>.any_instance.stub(:valid?).and_return(true)
|
103
|
+
put :update, id: <%= file_name %>
|
104
|
+
end
|
105
|
+
|
106
|
+
it { should assign_to(:<%= file_name %>).with(<%= file_name %>) }
|
107
|
+
it { should redirect_to <%= file_name %>_path(<%= file_name %>) }
|
108
|
+
end
|
109
|
+
context 'invalid' do
|
110
|
+
before do
|
111
|
+
<%= file_name %>
|
112
|
+
<%= class_name %>.any_instance.stub(:valid?).and_return(false)
|
113
|
+
put :update, id: <%= file_name %>
|
114
|
+
end
|
115
|
+
|
116
|
+
it { should assign_to(:<%= file_name %>).with(<%= file_name %>) }
|
117
|
+
it { should render_template :edit }
|
118
|
+
it { should have_only_fractures :cancel_edit_<%= file_name %>_link }
|
119
|
+
it { should have_a_form.that_is_edit.with_path_of(<%= file_name %>_path) }
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe 'DELETE destroy' do
|
124
|
+
before { delete :destroy, id: <%= file_name %> }
|
125
|
+
|
126
|
+
it { expect(<%= class_name %>.find_by_id(<%= file_name %>.id)).to be_nil }
|
127
|
+
it { should redirect_to <%= index_helper %>_path }
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
<% end -%>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
describe <%= controller_class_name %>Controller do
|
5
|
+
describe 'routing' do
|
6
|
+
|
7
|
+
<% unless options[:singleton] -%>
|
8
|
+
it('routes to #index') { get('/<%= ns_table_name %>').should route_to('<%= ns_table_name %>#index') }
|
9
|
+
<% end -%>
|
10
|
+
it('routes to #new') { get('/<%= ns_table_name %>/new').should route_to('<%= ns_table_name %>#new') }
|
11
|
+
it('routes to #show') { get('/<%= ns_table_name %>/1').should route_to('<%= ns_table_name %>#show', id: '1') }
|
12
|
+
it('routes to #edit') { get('/<%= ns_table_name %>/1/edit').should route_to('<%= ns_table_name %>#edit', id: '1') }
|
13
|
+
it('routes to #create') { post('/<%= ns_table_name %>').should route_to('<%= ns_table_name %>#create') }
|
14
|
+
it('routes to #update') { put('/<%= ns_table_name %>/1').should route_to('<%= ns_table_name %>#update', id: '1') }
|
15
|
+
it('routes to #destroy') { delete('/<%= ns_table_name %>/1').should route_to('<%= ns_table_name %>#destroy', id: '1') }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
<% end -%>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
|
3
|
+
ENV["RAILS_ENV"] ||= 'test'
|
4
|
+
require File.expand_path("../../config/environment", __FILE__)
|
5
|
+
require 'rspec/rails'
|
6
|
+
|
7
|
+
# ensure that we have a network connection to the internet before running any of these tests.
|
8
|
+
begin
|
9
|
+
require 'net/http'
|
10
|
+
Net::HTTP.get("google.com", '/')
|
11
|
+
rescue Interrupt
|
12
|
+
exit 0
|
13
|
+
rescue StandardError
|
14
|
+
puts "Network offline!"
|
15
|
+
exit 1
|
16
|
+
end
|
17
|
+
|
18
|
+
# load support files:
|
19
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
20
|
+
|
21
|
+
RSpec.configure do |config|
|
22
|
+
# Run specs in random order to surface order dependencies. If you find an
|
23
|
+
# order dependency and want to debug it, you can fix the order by providing
|
24
|
+
# the seed, which is printed after each run.
|
25
|
+
# --seed 1234
|
26
|
+
config.order = "random"
|
27
|
+
|
28
|
+
config.use_transactional_fixtures = false
|
29
|
+
|
30
|
+
# include any other modules
|
31
|
+
|
32
|
+
# add global before/after blocks:
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
# turn of deprecation warning.
|
37
|
+
I18n.enforce_available_locales = false
|