stationed 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +4 -0
  3. data/lib/stationed/generators/app_generator.rb +1 -1
  4. data/lib/stationed/generators/plugins/poltergeist.rb +21 -0
  5. data/lib/stationed/generators/plugins/stationed.rb +3 -1
  6. data/lib/stationed/generators/plugins/styles.rb +7 -5
  7. data/lib/stationed/generators/templates/_error_notification.scss +3 -0
  8. data/lib/stationed/generators/templates/_input_wrapper_default.scss +68 -0
  9. data/lib/stationed/generators/templates/application.scss +1 -1
  10. data/lib/stationed/generators/templates/database_cleaner.rb +1 -1
  11. data/lib/stationed/generators/templates/paginating_decorator.rb +1 -1
  12. data/lib/stationed/generators/templates/poltergeist.rb +2 -0
  13. data/lib/stationed/generators/templates/rubocop.rake +1 -1
  14. data/lib/stationed/version.rb +1 -1
  15. data/lib/templates/haml/scaffold/_form.html.haml +2 -2
  16. data/lib/templates/rails/scaffold_controller/controller.rb +1 -1
  17. data/lib/templates/rspec/scaffold/controller_spec.rb +15 -14
  18. data/lib/templates/rspec/scaffold/edit_spec.rb +1 -3
  19. data/lib/templates/rspec/scaffold/index_spec.rb +1 -3
  20. data/lib/templates/rspec/scaffold/new_spec.rb +1 -3
  21. data/lib/templates/rspec/scaffold/routing_spec.rb +1 -3
  22. data/lib/templates/rspec/scaffold/show_spec.rb +1 -3
  23. data/spec/dummy/log/test.log +0 -1742
  24. metadata +7 -9
  25. data/lib/stationed/generators/plugins/capybara_webkit.rb +0 -22
  26. data/lib/stationed/generators/templates/capybara_webkit.rb +0 -1
  27. data/spec/dummy/db/test.sqlite3 +0 -0
  28. data/spec/dummy/log/development.log +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd0eef67b43417e7fd36f910d756d88eb01be768
4
- data.tar.gz: 86a8f6cce7c8084573de3c9228b592bed0b1ef83
3
+ metadata.gz: 733060c6d3cd4844ae711d77c2dd16da04120350
4
+ data.tar.gz: 0fca0d5e034005561d405c615d95c5eef12f998e
5
5
  SHA512:
6
- metadata.gz: 64faf83906f6206d63eda4c13e8232b8492dfcbcc4cd503bd911d01de0456503737d1ff2bc4fd84e6bb62401adbcb6efe40c0c21527b653a47e91816401440dd
7
- data.tar.gz: a87de8d7e9358cf86f7ffb9df76cf244b737edff1eb6d43ebf01bb525928186053d3da024ecc058a962f00973b0d2c55d2d5c5aebbe473d59ea41903cca5b069
6
+ metadata.gz: 58fba6b9f02dddbf43f2a416a274f5e858beb8803ada47d7486e509ca27d5de6534691c987e1d604372fb736c5d1a15febe821ba1be743dfcca000f4796aa0f5
7
+ data.tar.gz: cf84b738ea05008af6a972f6cd3ab1a6af97b0d4b941dc7c6b338b6c4db90f4d3e216f7a7e00208b91ea46f2fb145b0565d5453d06881b96f882d54c28865805
data/HISTORY.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # HISTORY
2
2
 
3
+ ## Unreleased
4
+
5
+ * Include default form element and error styles
6
+
3
7
  ## 0.4.0
4
8
 
5
9
  * Improve default layout and actually remove Erb layout file
@@ -17,7 +17,7 @@ module Stationed
17
17
  prepend Plugins::FactoryGirl
18
18
  prepend Plugins::DatabaseCleaner
19
19
  prepend Plugins::Capybara
20
- prepend Plugins::CapybaraWebkit
20
+ prepend Plugins::Poltergeist
21
21
  prepend Plugins::Pundit
22
22
  prepend Plugins::Yard
23
23
  prepend Plugins::Foreman
@@ -0,0 +1,21 @@
1
+ module Stationed
2
+ module Generators
3
+ module Plugins
4
+ module Poltergeist
5
+ def self.prepended(base)
6
+ base.class_option :poltergeist,
7
+ type: :boolean,
8
+ default: true,
9
+ desc: 'Include Poltergeist for headless browser testing'
10
+ end
11
+
12
+ def finish_template
13
+ return super unless options[:capybara] && options[:poltergeist]
14
+ gem 'poltergeist', group: :test
15
+ copy_file 'poltergeist.rb', 'spec/support/poltergeist.rb'
16
+ super
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,5 @@
1
+ require 'stationed/version'
2
+
1
3
  module Stationed
2
4
  module Generators
3
5
  module Plugins
@@ -11,7 +13,7 @@ module Stationed
11
13
 
12
14
  def finish_template
13
15
  return super unless options[:stationed]
14
- gem 'stationed', path: '~/code/stationed'
16
+ gem 'stationed', ::Stationed::VERSION
15
17
  super
16
18
  end
17
19
  end
@@ -15,9 +15,11 @@ module Stationed
15
15
  gem 'neat'
16
16
  gem 'bitters'
17
17
  remove_file 'app/assets/stylesheets/application.css'
18
- copy_file 'application.scss', 'app/assets/stylesheets/application.scss'
19
- copy_file 'layout.scss', 'app/assets/stylesheets/_layout.scss'
20
- copy_file 'normalize.css', 'vendor/assets/stylesheets/normalize.css'
18
+ copy_file 'application.scss', 'app/assets/stylesheets/application.scss'
19
+ copy_file 'layout.scss', 'app/assets/stylesheets/_layout.scss'
20
+ copy_file '_input_wrapper_default.scss', 'app/assets/stylesheets/modules/_input_wrapper_default.scss'
21
+ copy_file '_error_notification.scss', 'app/assets/stylesheets/modules/_error_notification.scss'
22
+ copy_file 'normalize.css', 'vendor/assets/stylesheets/normalize.css'
21
23
  super
22
24
  end
23
25
 
@@ -25,8 +27,8 @@ module Stationed
25
27
  super
26
28
  return unless options[:styles]
27
29
  run 'bitters install'
28
- FileUtils.mv 'bitters', 'app/assets/stylesheets/bitters'
29
- gsub_file 'app/assets/stylesheets/bitters/_bitters.scss', %r{// @import}, '@import'
30
+ FileUtils.mv 'base', 'app/assets/stylesheets/base'
31
+ gsub_file 'app/assets/stylesheets/base/_base.scss', %r{// @import}, '@import'
30
32
  end
31
33
  end
32
34
  end
@@ -0,0 +1,3 @@
1
+ .error-notification {
2
+ color: darken($error-color, 60);
3
+ }
@@ -0,0 +1,68 @@
1
+ .input {
2
+ @include row;
3
+ margin-bottom: $base-line-height / 2;
4
+
5
+ abbr[title=required] {
6
+ border: none;
7
+ color: darken($error-color, 60);
8
+ }
9
+
10
+ label {
11
+ font-weight: normal;
12
+
13
+ &.required:after {
14
+ content: "";
15
+ }
16
+
17
+ abbr {
18
+ display: inline;
19
+ }
20
+ }
21
+
22
+ .hint {
23
+ color: $medium-gray;
24
+ }
25
+
26
+ &.field-with-errors {
27
+ label {
28
+ font-weight: bold;
29
+ color: darken($error-color, 60);
30
+ }
31
+
32
+ textarea,
33
+ #{$all-text-inputs},
34
+ select[multiple=multiple] {
35
+ border-color: darken($error-color, 60);
36
+ border-bottom-left-radius: 0;
37
+ border-bottom-right-radius: 0;
38
+ }
39
+ }
40
+
41
+ .error {
42
+ @include flash($error-color);
43
+ border: 1px solid darken($error-color, 60);
44
+ border-top: 0;
45
+ padding: ($base-line-height / 4);
46
+ margin: 0 0 ($base-line-height / 2);
47
+ border-bottom-left-radius: $form-border-radius;
48
+ border-bottom-right-radius: $form-border-radius;
49
+ }
50
+
51
+ .input-label {
52
+ @include span-columns(3);
53
+ }
54
+
55
+ .input-field {
56
+ @include span-columns(9);
57
+ }
58
+
59
+ textarea,
60
+ #{$all-text-inputs},
61
+ select {
62
+ margin: 0;
63
+ }
64
+
65
+ &.datetime select {
66
+ display: inline;
67
+ }
68
+ }
@@ -3,4 +3,4 @@
3
3
  @import 'bitters/bitters';
4
4
  @import 'neat';
5
5
  @import 'layout';
6
- // @import 'modules/*';
6
+ @import 'modules/*';
@@ -4,7 +4,7 @@ RSpec.configure do |config|
4
4
  DatabaseCleaner.clean_with(:truncation)
5
5
  end
6
6
 
7
- config.before(:each) do
7
+ config.before(:each) do |example|
8
8
  if example.metadata[:js]
9
9
  DatabaseCleaner.strategy = :truncation
10
10
  else
@@ -3,5 +3,5 @@
3
3
  # {ApplicationDecorator}.
4
4
  class PaginatingDecorator < Draper::CollectionDecorator
5
5
  delegate :current_page, :total_pages, :limit_value, :total_count,
6
- :offset_value, :last_page?
6
+ :offset_value, :last_page?, :model_name
7
7
  end
@@ -0,0 +1,2 @@
1
+ require 'capybara/poltergeist'
2
+ Capybara.javascript_driver = :poltergeist
@@ -1,5 +1,5 @@
1
1
  begin
2
2
  require 'rubocop/rake_task'
3
- Rubocop::RakeTask.new
3
+ RuboCop::RakeTask.new
4
4
  rescue LoadError
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module Stationed
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
@@ -1,6 +1,6 @@
1
1
  = form_for(@<%= singular_table_name %>) do |f|
2
2
  = f.error_notification
3
- = f.base_errors
3
+ = f.full_error :base
4
4
 
5
5
  .form-inputs
6
6
  <%- attributes.each do |attribute| -%>
@@ -8,4 +8,4 @@
8
8
  <%- end -%>
9
9
 
10
10
  .form-actions
11
- = f.submit_or_cancel
11
+ = f.button :submit
@@ -8,7 +8,7 @@ class <%= controller_class_name %>Controller < ApplicationController
8
8
  before_action :set_<%= singular_table_name %>, only: %i[show edit update destroy]
9
9
 
10
10
  def index
11
- @<%= plural_table_name %> = policy_scope(<%= orm_class.all(class_name) %>).decorate
11
+ @<%= plural_table_name %> = policy_scope(<%= orm_class.all(class_name) %>).page(params[:page]).decorate
12
12
  respond_with @<%= plural_table_name %>
13
13
  end
14
14
 
@@ -1,7 +1,5 @@
1
- require 'spec_helper'
2
-
3
1
  <% module_namespacing do -%>
4
- describe <%= controller_class_name %>Controller do
2
+ RSpec.describe <%= controller_class_name %>Controller, type: :controller do
5
3
  subject { response }
6
4
 
7
5
  <% unless options[:singleton] -%>
@@ -10,8 +8,9 @@ describe <%= controller_class_name %>Controller do
10
8
 
11
9
  before do
12
10
  allow(<%= class_name %>).to receive(:all).and_return(<%= table_name %>)
13
- <%= class_name %>Policy.any_instance.stub(:index?).and_return(true)
11
+ allow_any_instance_of(<%= class_name %>Policy).to receive(:index?).and_return(true)
14
12
  allow(Array).to receive(:policy_class).and_return(<%= class_name %>Policy)
13
+ allow(<%= table_name %>).to receive(:page).and_return(<%= table_name %>)
15
14
  allow(<%= table_name %>).to receive(:decorate).and_return(<%= table_name %>)
16
15
  end
17
16
 
@@ -38,7 +37,7 @@ describe <%= controller_class_name %>Controller do
38
37
 
39
38
  before do
40
39
  allow(<%= class_name %>).to receive(:find).with(<%= file_name %>.to_param).and_return(<%= file_name %>)
41
- <%= class_name %>Policy.any_instance.stub(:show?).and_return(true)
40
+ allow_any_instance_of(<%= class_name %>Policy).to receive(:show?).and_return(true)
42
41
  end
43
42
 
44
43
  describe 'response' do
@@ -63,7 +62,7 @@ describe <%= controller_class_name %>Controller do
63
62
 
64
63
  before do
65
64
  allow(<%= class_name %>).to receive(:new).and_return(<%= file_name %>)
66
- <%= class_name %>Policy.any_instance.stub(:new?).and_return(true)
65
+ allow_any_instance_of(<%= class_name %>Policy).to receive(:new?).and_return(true)
67
66
  end
68
67
 
69
68
  describe 'response' do
@@ -88,7 +87,7 @@ describe <%= controller_class_name %>Controller do
88
87
 
89
88
  before do
90
89
  allow(<%= class_name %>).to receive(:find).with(<%= file_name %>.to_param).and_return(<%= file_name %>)
91
- <%= class_name %>Policy.any_instance.stub(:edit?).and_return(true)
90
+ allow_any_instance_of(<%= class_name %>Policy).to receive(:edit?).and_return(true)
92
91
  end
93
92
 
94
93
  describe 'response' do
@@ -110,7 +109,7 @@ describe <%= controller_class_name %>Controller do
110
109
 
111
110
  describe 'POST create' do
112
111
  before do
113
- <%= class_name %>Policy.any_instance.stub(:create?).and_return(true)
112
+ allow_any_instance_of(<%= class_name %>Policy).to receive(:create?).and_return(true)
114
113
  end
115
114
 
116
115
  describe 'with valid params' do
@@ -158,26 +157,28 @@ describe <%= controller_class_name %>Controller do
158
157
 
159
158
  before do
160
159
  allow(<%= class_name %>).to receive(:find).with(<%= file_name %>.to_param).and_return(<%= file_name %>)
161
- <%= class_name %>Policy.any_instance.stub(:update?).and_return(true)
160
+ allow_any_instance_of(<%= class_name %>Policy).to receive(:update?).and_return(true)
162
161
  end
163
162
 
164
163
  describe 'with valid params' do
164
+ let(:attributes) { attributes_for(:<%= file_name %>) }
165
+
165
166
  before do
166
167
  allow(<%= file_name %>).to receive(:update).and_return(true)
167
168
  end
168
169
 
169
170
  it 'updates the requested <%= ns_file_name %>' do
170
- expect(<%= file_name %>).to receive(:update).with(attributes_for(:<%= file_name %>).stringify_keys)
171
- put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
171
+ expect(<%= file_name %>).to receive(:update).with(attributes.stringify_keys)
172
+ put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes
172
173
  end
173
174
 
174
175
  it 'assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>' do
175
- put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
176
+ put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes
176
177
  expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
177
178
  end
178
179
 
179
180
  it 'redirects to the <%= ns_file_name %>' do
180
- put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
181
+ put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes
181
182
  expect(response).to redirect_to(<%= file_name %>)
182
183
  end
183
184
  end
@@ -207,7 +208,7 @@ describe <%= controller_class_name %>Controller do
207
208
  allow(<%= class_name %>).to receive(:find).with(<%= file_name %>.to_param).and_return(<%= file_name %>)
208
209
  allow(<%= file_name %>).to receive(:destroy).and_return(true)
209
210
  allow(<%= file_name %>).to receive(:persisted?).and_return(false)
210
- <%= class_name %>Policy.any_instance.stub(:destroy?).and_return(true)
211
+ allow(<%= class_name %>Policy).to receive(:destroy?).and_return(true)
211
212
  end
212
213
 
213
214
  it 'destroys the requested <%= ns_file_name %>' do
@@ -1,7 +1,5 @@
1
- require 'spec_helper'
2
-
3
1
  <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- describe "<%= ns_table_name %>/edit" do
2
+ RSpec.describe "<%= ns_table_name %>/edit", type: :view do
5
3
  let(:<%= ns_file_name %>) { build_stubbed :<%= ns_file_name %> }
6
4
 
7
5
  before do
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe "<%= ns_table_name %>/index" do
1
+ RSpec.describe "<%= ns_table_name %>/index", type: :view do
4
2
  let(:<%= table_name %>) { build_stubbed_list :<%= ns_file_name %>, 3 }
5
3
 
6
4
  before do
@@ -1,7 +1,5 @@
1
- require 'spec_helper'
2
-
3
1
  <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- describe "<%= ns_table_name %>/new" do
2
+ RSpec.describe "<%= ns_table_name %>/new", type: :view do
5
3
  let(:<%= ns_file_name %>) { build :<%= ns_file_name %> }
6
4
 
7
5
  before do
@@ -1,7 +1,5 @@
1
- require 'spec_helper'
2
-
3
1
  <% module_namespacing do -%>
4
- describe <%= controller_class_name %>Controller do
2
+ RSpec.describe <%= controller_class_name %>Controller, type: :view do
5
3
  describe 'routing' do
6
4
  <% unless options[:singleton] -%>
7
5
  it { expect(get: '/<%= ns_table_name %>').to route_to('<%= ns_table_name %>#index') }
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe "<%= ns_table_name %>/show" do
1
+ RSpec.describe "<%= ns_table_name %>/show", type: :view do
4
2
  let(:<%= ns_file_name %>) { build_stubbed :<%= ns_file_name %> }
5
3
 
6
4
  before do