kitestrings 1.1.0 → 1.2.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: bbe25d2970bba5ce75054165c911485a02b2133c
4
- data.tar.gz: 404bb3f6a631c64651a2dc7467e98f26d2ca519d
3
+ metadata.gz: 09a1d7d5265a7012cea917f77889c82ee15d3735
4
+ data.tar.gz: 27aeeb8c04ef9a59318dee5f57962fbc812c99d9
5
5
  SHA512:
6
- metadata.gz: f9120863220ddf55e5360113153ed3628c596b398c9ba29a4e9a04d6fcc73cc1df22a1875da863c9006f0997ae9b31dd1967899d3f8125412f360eea2f1d2bf0
7
- data.tar.gz: 3c6df627e4878a585cae84e4512a1b8be27267efe6bcb88cca799a0a5e9a2a0e05ce01911f14a9023fd4b4169909923e103cb7aab23ab781522a492b5ec6c338
6
+ metadata.gz: 2de52f0b07968416e93b1a1e20ca4206018d96f02f25690317cc6cd892fb81f9971cd6aefd5b186ff300e9b021f817406ab3dc8f82c0c693d65ad43ab82c182d
7
+ data.tar.gz: 9136bbdc03df7fac3b93973dc555d24dcb340feee6b228b4218035fba4b14cccafaaf509969480f70ef830298b7a4bbf2d496502b6e76c44bf5638b0b147c21b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Version history:
2
2
 
3
+ ## 1.2.0
4
+ * reformatting for rubocop
5
+
3
6
  ## Next
4
7
 
5
8
  * Added Kitestrings::Menu classes/modules to assist with rendering menus in web pages.
@@ -14,6 +14,14 @@ module Kitestrings
14
14
  directory "config/environments", "config/environments"
15
15
  end
16
16
 
17
+ def copy_seeds_file
18
+ copy_file "db/seeds.rb", "db/seeds.rb"
19
+ end
20
+
21
+ def copy_rubocop_file
22
+ copy_file "rubocop/.rubocop.yml", ".rubocop.yml"
23
+ end
24
+
17
25
  def copy_haml_files
18
26
  directory "haml", "lib/templates/haml"
19
27
  end
@@ -44,6 +52,7 @@ module Kitestrings
44
52
  inject_into_file "app/controllers/application_controller.rb", :after => /protect_from_forgery.*$/ do
45
53
  <<-EOF
46
54
 
55
+ respond_to :html
47
56
 
48
57
  unless Rails.application.config.consider_all_requests_local
49
58
  rescue_from CanCan::AccessDenied do |exception|
@@ -52,10 +61,25 @@ module Kitestrings
52
61
  render 'public/403', status: 403, layout: 'none'
53
62
  end
54
63
  end
55
- EOF
64
+ EOF
56
65
  end
57
66
  end
58
67
 
68
+
69
+ def setup_application_config
70
+ generators_configuration = <<-END
71
+ config.generators do |g|
72
+ g.view_specs false
73
+ end
74
+
75
+ config.app_generators do |g|
76
+ g.templates.unshift File.expand_path('../lib/templates', __FILE__)
77
+ end
78
+ END
79
+
80
+ environment generators_configuration
81
+ end
82
+
59
83
  end
60
84
  end
61
85
  end
@@ -1,7 +1,6 @@
1
- load File.expand_path("../production.rb", __FILE__)
1
+ load File.expand_path('../production.rb', __FILE__)
2
2
 
3
3
  Rails.application.configure do
4
-
5
4
  config.loglevel = :debug
6
5
 
7
6
  # config.airbrake_api_key = 'AIRBRAKE_KEY'
@@ -1,7 +1,6 @@
1
- load File.expand_path("../production.rb", __FILE__)
1
+ load File.expand_path('../production.rb', __FILE__)
2
2
 
3
3
  Rails.application.configure do
4
-
5
4
  config.log_level = :info
6
5
 
7
6
  # config.airbrake_api_key = 'AIRBRAKE_KEY'
@@ -0,0 +1,2 @@
1
+ Rake::Task['db:fixtures:load'].invoke
2
+ Rake::Task['tmp:clear'].invoke unless ENV['RAILS_ENV'] == 'test'
@@ -44,18 +44,19 @@ class <%= controller_class_name %>Controller < ApplicationController
44
44
  end
45
45
 
46
46
  private
47
- # Use callbacks to share common setup or constraints between actions.
48
- def set_<%= singular_table_name %>
49
- @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
50
- end
51
47
 
52
- # Only allow a trusted parameter "white list" through.
53
- def <%= "#{singular_table_name}_params" %>
54
- <%- if attributes_names.empty? -%>
55
- params[:<%= singular_table_name %>]
56
- <%- else -%>
57
- params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
58
- <%- end -%>
59
- end
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
60
61
  end
61
62
  <% end -%>
@@ -12,6 +12,5 @@ require 'rails_helper'
12
12
  # end
13
13
  <% module_namespacing do -%>
14
14
  describe <%= class_name %>Helper do
15
-
16
15
  end
17
16
  <% end -%>
@@ -0,0 +1,10 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe '<%= class_name.pluralize %>', <%= type_metatag(:request) %> do
4
+ describe 'GET /<%= table_name %>' do
5
+ it 'works! (now write some real specs)' do
6
+ get <%= index_helper %>_path
7
+ expect(response).to have_http_status(200)
8
+ end
9
+ end
10
+ end
@@ -2,13 +2,11 @@ require 'rails_helper'
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  describe <%= class_name %> do
5
-
6
5
  common_lets
7
6
 
8
7
  # define the <%= file_name %>, <%= file_name %>_other,... instances in
9
8
  # spec/support/common_lets.rb
10
9
  it { expect(<%= file_name %>).to be_valid }
11
- # it { expect(<%= file_name %>_other).to be_valid }
12
-
10
+ # it { expect(<%= file_name %>_other).to be_valid }
13
11
  end
14
12
  <% end -%>
@@ -12,16 +12,17 @@ describe <%= controller_class_name %>Controller do
12
12
  end
13
13
 
14
14
  # stub strong params
15
- before { controller.stub(<%= file_name %>_params: {}) }
15
+ before { allow(controller).to receive(:<%= file_name %>_params).and_return({}) }
16
16
 
17
17
  context 'not logged in' do
18
18
  before do
19
19
  sign_out :user
20
20
  end
21
21
 
22
- {index: :get, show: :get, new: :get, create: :post, edit: :get, update: :put, destroy: :delete}.each do |v, m|
22
+ { index: :get, show: :get, new: :get, create: :post, edit: :get, update: :put,
23
+ destroy: :delete }.each do |v, m|
23
24
  it "#{m} #{v} should logout" do
24
- self.send(m, v, id: <%= file_name %>)
25
+ send(m, v, id: <%= file_name %>)
25
26
  expect(response).to redirect_to new_user_session_path
26
27
  end
27
28
  end
@@ -40,9 +41,9 @@ describe <%= controller_class_name %>Controller do
40
41
  it { expect(response).to assign_to(:<%= table_name %>).with_items([<%= file_name %>]) }
41
42
  it { expect(response).to render_template :index }
42
43
  it { expect(response).to have_only_fractures(:new_<%= file_name %>_link) }
43
- end
44
+ end
45
+ <% end -%>
44
46
 
45
- <% end -%>
46
47
  describe 'GET show' do
47
48
  before { get :show, id: <%= file_name %> }
48
49
 
@@ -55,10 +56,10 @@ describe <%= controller_class_name %>Controller do
55
56
  before { get :new }
56
57
 
57
58
  it { expect(response).to assign_to(:<%= file_name %>).with_kind_of(<%= class_name %>) }
58
- #it { expect(response).to assign_to('<%= file_name %>.parent').with(parent) }
59
+ # it { expect(response).to assign_to('<%= file_name %>.parent').with(parent) }
59
60
  it { expect(response).to render_template :new }
60
61
  it { expect(response).to have_only_fractures :cancel_new_<%= file_name %>_link }
61
- it { expect(response).to have_a_form.that_is_new.with_path_of(<%= table_name %>_path)}
62
+ it { expect(response).to have_a_form.that_is_new.with_path_of(<%= table_name %>_path) }
62
63
  end
63
64
 
64
65
  describe 'POST create' do
@@ -70,7 +71,7 @@ describe <%= controller_class_name %>Controller do
70
71
 
71
72
  it { expect(response).to redirect_to <%= file_name %>_path(<%= class_name %>.last) }
72
73
  it { expect(response).to assign_to(:<%= file_name %>).with(<%= class_name %>.last) }
73
- #it { expect(response).to assign_to('<%= file_name %>.parent').with(parent) }
74
+ # it { expect(response).to assign_to('<%= file_name %>.parent').with(parent) }
74
75
  end
75
76
 
76
77
  context 'invalid' do
@@ -79,10 +80,10 @@ describe <%= controller_class_name %>Controller do
79
80
  post :create
80
81
  end
81
82
  it { expect(response).to assign_to(:<%= file_name %>).with_kind_of(<%= class_name %>) }
82
- #it { expect(response).to assign_to('<%= file_name %>.parent').with(parent) }
83
+ # it { expect(response).to assign_to('<%= file_name %>.parent').with(parent) }
83
84
  it { expect(response).to render_template :new }
84
85
  it { expect(response).to have_only_fractures :cancel_new_<%= file_name %>_link }
85
- it { expect(response).to have_a_form.that_is_new.with_path_of(<%= table_name %>_path)}
86
+ it { expect(response).to have_a_form.that_is_new.with_path_of(<%= table_name %>_path) }
86
87
  end
87
88
  end
88
89
 
@@ -3,7 +3,6 @@ require 'rails_helper'
3
3
  <% module_namespacing do -%>
4
4
  describe <%= controller_class_name %>Controller do
5
5
  describe 'routing' do
6
-
7
6
  <% unless options[:singleton] -%>
8
7
  it('routes to #index') { expect(get('/<%= ns_table_name %>')).to route_to('<%= ns_table_name %>#index') }
9
8
  <% end -%>
@@ -0,0 +1,57 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'db/schema.rb'
4
+ - '**/db/schema.rb'
5
+ - 'config/**/*'
6
+ - 'db/migrate/*'
7
+ - '**/db/migrate/*'
8
+ - 'lib/templates/**/*'
9
+ - 'bin/*'
10
+ RunRailsCops: true
11
+
12
+ Style/Documentation:
13
+ Description: Document classes and non-namespace modules.
14
+ Enabled: false
15
+
16
+ Style/StringLiterals:
17
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
18
+ Enabled: true
19
+ EnforcedStyle: single_quotes
20
+ SupportedStyles:
21
+ - single_quotes
22
+ - double_quotes
23
+
24
+ Style/CaseIndentation:
25
+ Description: Indentation of when in a case/when/[else/]end.
26
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#indent-when-to-case
27
+ Enabled: true
28
+ IndentWhenRelativeTo: case
29
+ SupportedStyles:
30
+ - case
31
+ - end
32
+ IndentOneStep: true
33
+
34
+ #LineLength:
35
+ # Max: 100
36
+ Metrics/LineLength:
37
+ Description: Limit lines to 100 characters.
38
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits
39
+ Enabled: true
40
+ Max: 100
41
+ AllowURI: true
42
+ URISchemes:
43
+ - http
44
+ - https
45
+
46
+ Style/SymbolProc:
47
+ Description: Use symbols as procs instead of blocks when possible.
48
+ Enabled: true
49
+ IgnoredMethods:
50
+ - respond_to
51
+ # - configure
52
+
53
+ Style/Semicolon:
54
+ Description: Don't use semicolons to terminate expressions.
55
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-semicolon
56
+ Enabled: true
57
+ AllowAsExpressionSeparator: true
@@ -1,13 +1,13 @@
1
1
  # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- ENV["RAILS_ENV"] ||= 'test'
2
+ ENV['RAILS_ENV'] ||= 'test'
3
3
  require 'spec_helper'
4
- require File.expand_path("../../config/environment", __FILE__)
4
+ require File.expand_path('../../config/environment', __FILE__)
5
5
  require 'rspec/rails'
6
- require 'rspec/autorun'
6
+ # require 'rspec/autorun'
7
7
 
8
8
  # Requires supporting ruby files with custom matchers and macros, etc,
9
9
  # in spec/support/ and its subdirectories.
10
- Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
10
+ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
11
11
 
12
12
  # Checks for pending migrations before tests are run.
13
13
  # If you are not using ActiveRecord, you can remove this line.
@@ -15,7 +15,7 @@ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
15
15
 
16
16
  RSpec.configure do |config|
17
17
  # clear the test log file before we start.
18
- log_file = Rails.root.join("log/test.log")
18
+ log_file = Rails.root.join('log/test.log')
19
19
  File.truncate(log_file, 0) if File.exist?(log_file)
20
20
 
21
21
  config.include Devise::TestHelpers, type: :controller
@@ -47,8 +47,7 @@ RSpec.configure do |config|
47
47
  # order dependency and want to debug it, you can fix the order by providing
48
48
  # the seed, which is printed after each run.
49
49
  # --seed 1234
50
- config.order = "random"
51
-
50
+ config.order = 'random'
52
51
 
53
52
  # RSpec Rails can automatically mix in different behaviours to your tests
54
53
  # based on their file location, for example enabling you to call `get` and
@@ -64,4 +63,4 @@ RSpec.configure do |config|
64
63
  # The different available types are documented in the features, such as in
65
64
  # https://relishapp.com/rspec/rspec-rails/docs
66
65
  config.infer_spec_type_from_file_location!
67
- end
66
+ end
@@ -0,0 +1,2 @@
1
+ def common_lets
2
+ end
@@ -1,21 +1,21 @@
1
1
  RSpec.configure do |config|
2
- config.before(:suite) do
3
- DatabaseCleaner.clean_with(:truncation)
4
- end
5
-
6
- config.before(:each) do
7
- DatabaseCleaner.strategy = :transaction
8
- end
9
-
10
- config.before(:each, :js => true) do
2
+ # config.before(:suite) do
3
+ # DatabaseCleaner.clean_with(:truncation)
4
+ # end
5
+ #
6
+ # config.before(:each) do
7
+ # DatabaseCleaner.strategy = :transaction
8
+ # end
9
+ #
10
+ config.before(:each, js: true) do
11
11
  DatabaseCleaner.strategy = :truncation
12
12
  end
13
-
14
- config.before(:each) do
15
- DatabaseCleaner.start
16
- end
17
-
18
- config.after(:each) do
19
- DatabaseCleaner.clean
20
- end
21
- end
13
+ #
14
+ # config.before(:each) do
15
+ # DatabaseCleaner.start
16
+ # end
17
+ #
18
+ # config.after(:each) do
19
+ # DatabaseCleaner.clean
20
+ # end
21
+ end
@@ -2,4 +2,4 @@ RSpec.configure do |config|
2
2
  config.after(:all) do
3
3
  Fracture.clear
4
4
  end
5
- end
5
+ end
@@ -1,3 +1 @@
1
- RSpec.configure do |config|
2
- config.render_views
3
- end
1
+ RSpec.configure(&:render_views)
@@ -1,3 +1,3 @@
1
1
  module Kitestrings
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -18,6 +18,7 @@ describe Kitestrings::Generators::InstallGenerator do
18
18
  context "check files" do
19
19
  %w[
20
20
  spec/rails_helper.rb
21
+ .rubocop.yml
21
22
  config/deploy.rb
22
23
  config/deploy/integ.rb
23
24
  config/deploy/uat.rb
@@ -31,7 +32,7 @@ describe Kitestrings::Generators::InstallGenerator do
31
32
  lib/templates/haml/scaffold/show.html.haml
32
33
  lib/templates/rails/scaffold_controller/controller.rb
33
34
  lib/templates/rspec/helper/helper_spec.rb
34
- lib/templates/rspec/integration/request.rb
35
+ lib/templates/rspec/integration/request_spec.rb
35
36
  lib/templates/rspec/model/model_spec.rb
36
37
  lib/templates/rspec/scaffold/controller_spec.rb
37
38
  lib/templates/rspec/scaffold/routing_spec.rb
@@ -49,6 +50,9 @@ describe Kitestrings::Generators::InstallGenerator do
49
50
  it "inserted into application_controller" do
50
51
  file_contents("app/controllers/application_controller.rb").should match(/rescue_from CanCan::AccessDenied/)
51
52
  end
53
+ it "appended to db/seeds" do
54
+ file_contents("db/seeds.rb").should match(/Rake::Task/)
55
+ end
52
56
 
53
57
  # otherwise it wants to run the specs in the tmp/spec directory
54
58
  after(:all) { rm_rf(destination_root) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitestrings
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Ridge
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-02-09 00:00:00.000000000 Z
13
+ date: 2015-02-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -135,6 +135,7 @@ files:
135
135
  - lib/generators/templates/config/deploy/uat.rb
136
136
  - lib/generators/templates/config/environments/integ.rb
137
137
  - lib/generators/templates/config/environments/uat.rb
138
+ - lib/generators/templates/db/seeds.rb
138
139
  - lib/generators/templates/haml/scaffold/_form.html.haml
139
140
  - lib/generators/templates/haml/scaffold/edit.html.haml
140
141
  - lib/generators/templates/haml/scaffold/index.html.haml
@@ -142,11 +143,13 @@ files:
142
143
  - lib/generators/templates/haml/scaffold/show.html.haml
143
144
  - lib/generators/templates/rails/scaffold_controller/controller.rb
144
145
  - lib/generators/templates/rspec/helper/helper_spec.rb
145
- - lib/generators/templates/rspec/integration/request.rb
146
+ - lib/generators/templates/rspec/integration/request_spec.rb
146
147
  - lib/generators/templates/rspec/model/model_spec.rb
147
148
  - lib/generators/templates/rspec/scaffold/controller_spec.rb
148
149
  - lib/generators/templates/rspec/scaffold/routing_spec.rb
150
+ - lib/generators/templates/rubocop/.rubocop.yml
149
151
  - lib/generators/templates/spec/rails_helper.rb
152
+ - lib/generators/templates/support/common_lets.rb
150
153
  - lib/generators/templates/support/database_cleaner.rb
151
154
  - lib/generators/templates/support/fracture.rb
152
155
  - lib/generators/templates/support/render_views.rb
@@ -196,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
199
  version: '0'
197
200
  requirements: []
198
201
  rubyforge_project:
199
- rubygems_version: 2.2.2
202
+ rubygems_version: 2.4.2
200
203
  signing_key:
201
204
  specification_version: 4
202
205
  summary: For all the 2rk goodness
@@ -1,4 +0,0 @@
1
- require 'rails_helper'
2
-
3
- describe "<%= class_name.pluralize %>" do
4
- end