shoestrap 1.0.0.pre1 → 1.0.0.pre2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -2
- data/CHANGELOG.md +12 -1
- data/Guardfile +1 -0
- data/Rakefile +1 -1
- data/circle.yml +3 -0
- data/features/command_wrapper_helper.rb +94 -0
- data/features/custom_matcher.rb +23 -0
- data/features/features_helper.rb +76 -29
- data/features/postgres_helper.rb +69 -0
- data/features/shoestrap/commands/new_command_spec.rb +234 -0
- data/features/shoestrap/generators/{bdd_generator_feature.rb → bdd_generator_spec.rb} +7 -5
- data/features/shoestrap/generators/bootstrap_generator_spec.rb +21 -0
- data/features/shoestrap/generators/cms_generator_spec.rb +149 -0
- data/features/shoestrap/generators/{coffee_files_generator_feature.rb → coffee_files_generator_spec.rb} +0 -0
- data/features/shoestrap/generators/{foundation_generator_feature.rb → foundation_generator_spec.rb} +7 -0
- data/features/shoestrap/generators/kuhsaft_generator_spec.rb +57 -0
- data/features/shoestrap/generators/{smacss_files_generator_feature.rb → smacss_files_generator_spec.rb} +0 -0
- data/features/shoestrap/generators/view_files_generator_spec.rb +20 -0
- data/lib/generators/shoestrap/base_generator.rb +41 -0
- data/lib/generators/shoestrap/bdd_generator.rb +1 -5
- data/lib/generators/shoestrap/bootstrap_generator.rb +3 -0
- data/lib/generators/shoestrap/cms_generator.rb +59 -0
- data/lib/generators/shoestrap/coffee_files_generator.rb +1 -5
- data/lib/generators/shoestrap/foundation_generator.rb +5 -5
- data/lib/generators/shoestrap/kuhsaft_generator.rb +6 -5
- data/lib/generators/shoestrap/mailcatcher_generator.rb +12 -0
- data/lib/generators/shoestrap/simple_navigation_generator.rb +14 -0
- data/lib/generators/shoestrap/smacss_file_generator.rb +1 -5
- data/lib/generators/shoestrap/view_files_generator.rb +11 -0
- data/lib/shoestrap/application_generator.rb +14 -38
- data/lib/shoestrap/shell.rb +1 -0
- data/lib/shoestrap/version.rb +1 -1
- data/shoestrap.gemspec +12 -3
- data/spec/shoestrap/application_generator_spec.rb +37 -20
- data/spec/spec_helper.rb +1 -1
- data/templates/application_generator/_typekit.html.haml +4 -0
- data/templates/application_generator/application.html.haml +10 -10
- data/templates/application_generator/application_template.rb +19 -3
- data/templates/bdd_generator/active_record_spec_helper.rb +1 -1
- data/templates/cms_generator/base_controller.rb +2 -0
- data/templates/{coffee_generator → coffee_files_generator}/application.js.coffee +0 -0
- data/templates/simple_navigation_generator/navigation.rb +76 -0
- data/templates/{smacss_generator → smacss_files_generator}/application.css.sass +0 -0
- metadata +39 -21
- data/features/shoestrap/commands/new_command_feature.rb +0 -191
- data/features/shoestrap/generators/bootstrap_generator_feature.rb +0 -11
- data/features/shoestrap/generators/kuhsaft_generator_feature.rb +0 -38
@@ -6,12 +6,13 @@ describe 'application generated with shoestrap new <name>' do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
context '.rspec file' do
|
9
|
+
let(:rspec_file) { application_file('.rspec') }
|
9
10
|
it 'sets up rspec to use colored output' do
|
10
|
-
expect(
|
11
|
+
expect(rspec_file).to match /--color/
|
11
12
|
end
|
12
13
|
|
13
14
|
it 'sets up rspec to use the documentation format' do
|
14
|
-
expect(
|
15
|
+
expect(rspec_file).to match /--format d/
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
@@ -28,16 +29,17 @@ describe 'application generated with shoestrap new <name>' do
|
|
28
29
|
end
|
29
30
|
|
30
31
|
context 'Guardfile' do
|
32
|
+
let(:guardfile) { application_file('Guardfile') }
|
31
33
|
it 'has a Guardfile' do
|
32
|
-
expect(
|
34
|
+
expect(guardfile).not_to be_nil
|
33
35
|
end
|
34
36
|
|
35
37
|
it 'has the rspec config in it' do
|
36
|
-
expect(
|
38
|
+
expect(guardfile).to match /guard\ :rspec\ do/
|
37
39
|
end
|
38
40
|
|
39
41
|
it 'has the spring config in it' do
|
40
|
-
expect(
|
42
|
+
expect(guardfile).to match /guard\s+'spring'.+do\s*$/
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative '../../features_helper'
|
2
|
+
|
3
|
+
describe 'application generated with shoestrap new <name> --css=bootstrap' do
|
4
|
+
|
5
|
+
options = '--css=bootstrap'
|
6
|
+
|
7
|
+
before :all do
|
8
|
+
generate_test_app_with_shoestrap(options)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'has bootstrap-sass in the Gemfile' do
|
12
|
+
expect(application_file('Gemfile', options)).to match /gem "bootstrap-sass"/
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'runs the simple form installer with bootstrap as option' do
|
16
|
+
expect(application_file('config/initializers/simple_form.rb', options)).not_to be_nil
|
17
|
+
expect(application_file('config/initializers/simple_form_bootstrap.rb', options)).not_to be_nil
|
18
|
+
expect(application_file('config/locales/simple_form.en.yml', options)).not_to be_nil
|
19
|
+
expect(application_file('lib/templates/haml/scaffold/_form.html.haml', options)).not_to be_nil
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require_relative '../../features_helper'
|
2
|
+
|
3
|
+
describe 'rails generate shoestrap:cms' do
|
4
|
+
|
5
|
+
context 'without default cms' do
|
6
|
+
|
7
|
+
options = {kuhsaft: false}
|
8
|
+
let(:cars_controller) { application_file('app/controllers/cms/cars_controller.rb', options) }
|
9
|
+
let(:app_path){ application_path(options) }
|
10
|
+
|
11
|
+
before :all do
|
12
|
+
generate_test_app_with_shoestrap options
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'is available in the generated app' do
|
16
|
+
cli_output = rails 'generate', options
|
17
|
+
expect(cli_output).to match(/shoestrap:cms/)
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'generating a cms resource' do
|
21
|
+
let(:navigation_config_path) { File.join(app_path, 'config/navigation.rb') }
|
22
|
+
let(:navigation_config) { application_file('config/navigation.rb', options) }
|
23
|
+
let (:gemfile_content) { application_file('Gemfile', options) }
|
24
|
+
|
25
|
+
|
26
|
+
before :all do
|
27
|
+
rails 'generate shoestrap:cms car tires:integer model:string', options
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'for the first time' do
|
31
|
+
it 'sets up the cms routes namespace' do
|
32
|
+
expect(application_file('config/routes.rb', options)).to match(/namespace :cms do/)
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'with navigation' do
|
36
|
+
it 'sets up the cms navigation file' do
|
37
|
+
expect(File.exists? navigation_config_path).to be_true
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'contains no example entries' do
|
41
|
+
expect(navigation_config).not_to match(/^\s*primary\.item :key/)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'sets up controller inheritance for the cms backend' do
|
46
|
+
expect(application_file('app/controllers/shoestrap/base_controller.rb', options)).to match('InheritedResources::Base')
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
it 'generates a controller with CRUD actions' do
|
53
|
+
expect(cars_controller).to match(/Shoestrap..BaseController/)
|
54
|
+
expect(cars_controller).to match('respond_to :html')
|
55
|
+
expect(cars_controller).to match(/action.+all.+except.+show/)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'generates inherited CRUD views' do
|
59
|
+
views = Dir[File.join(app_path, 'app/views/cms/cars/*.html.haml')]
|
60
|
+
views.map!{|v| v.scan(/^.+app\/views\/cms\/cars\/(.*).html.haml/).flatten.first.to_sym }
|
61
|
+
|
62
|
+
expected_action_views = [:edit, :index, :new, :show]
|
63
|
+
expect(expected_action_views - views).to be_empty
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'generates a model' do
|
67
|
+
expect(application_file('app/models/car.rb', options)).not_to be_nil
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'generates a migration' do
|
71
|
+
expect(Dir.glob("#{app_path}/db/migrate/*create*cars*").size).to be 1
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'adds a resource route' do
|
75
|
+
expect(application_file('config/routes.rb', options)).to match(/resources :cars/)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'generates integration tests for the CRUD actions' do
|
79
|
+
request_spec = File.join(app_path, 'spec/requests/cms/cms_cars_spec.rb')
|
80
|
+
expect(File.exists? request_spec).to be_true
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'adds the generated resource to the cms navigation' do
|
84
|
+
expect(navigation_config).to match('cms_cars_path')
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
it 'does not generate routing specs' do
|
89
|
+
routing_spec = File.join(app_path, 'spec/routing/cars_routing_spec.rb')
|
90
|
+
expect(File.exists? routing_spec).to be_false
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'does not generate view specs' do
|
94
|
+
view_specs = File.join(app_path, 'spec/views/cars')
|
95
|
+
expect(File.exists? view_specs).to be_false
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'does not generate controller specs' do
|
99
|
+
controller_specs = File.join(app_path, 'spec/controllers/cars_controller_spec.rb')
|
100
|
+
expect(File.exists? controller_specs).to be_false
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'does not generate json views' do
|
104
|
+
expect(Dir.glob("#{app_path}/app/views/cars/*.jbuilder").size).to be 0
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should not contain the kuhsaft gem' do
|
108
|
+
expect(gemfile_content).not_to include_gem('kuhsaft')
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should not have the kuhsaft initializer' do
|
112
|
+
expect(File.exists?(File.join(app_path, 'config/initializers/kuhsaft.rb'))).to be_false
|
113
|
+
end
|
114
|
+
|
115
|
+
end # generating a cms resource
|
116
|
+
end # without default cms
|
117
|
+
|
118
|
+
context 'with kuhsaft' do
|
119
|
+
|
120
|
+
options = {kuhsaft: true}
|
121
|
+
let(:cars_controller) { application_file('app/controllers/cms/cars_controller.rb', options) }
|
122
|
+
let (:gemfile_content) { application_file('Gemfile', options) }
|
123
|
+
let(:app_path){ application_path(options) }
|
124
|
+
|
125
|
+
before :all do
|
126
|
+
generate_test_app_with_shoestrap options
|
127
|
+
end
|
128
|
+
|
129
|
+
context 'generating a cms resource' do
|
130
|
+
before :all do
|
131
|
+
rails 'generate shoestrap:cms car tires:integer model:string', options
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'generates a controller inheriting from kuhsaft AdminController' do
|
135
|
+
expect(cars_controller).to match('Kuhsaft::Cms::AdminController')
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'should contain the kuhsaft gem' do
|
139
|
+
expect(gemfile_content).to include_gem('kuhsaft')
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should have the kuhsaft initializer' do
|
143
|
+
expect(File.exists?(File.join(app_path, 'config/initializers/kuhsaft.rb'))).to be_true
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
end # with kuhsaft
|
149
|
+
end # rails generate shoestrap:cms
|
File without changes
|
data/features/shoestrap/generators/{foundation_generator_feature.rb → foundation_generator_spec.rb}
RENAMED
@@ -31,4 +31,11 @@ describe 'application generated with shoestrap new <name> --css=foundation' do
|
|
31
31
|
it 'has the foundation settings file' do
|
32
32
|
expect(application_file('app/assets/stylesheets/_settings.css.sass', options)).not_to be_nil
|
33
33
|
end
|
34
|
+
|
35
|
+
it 'runs the simple form installer with foundation as option' do
|
36
|
+
expect(application_file('config/initializers/simple_form.rb', options)).not_to be_nil
|
37
|
+
expect(application_file('config/initializers/simple_form_foundation.rb', options)).not_to be_nil
|
38
|
+
expect(application_file('config/locales/simple_form.en.yml', options)).not_to be_nil
|
39
|
+
expect(application_file('lib/templates/haml/scaffold/_form.html.haml', options)).not_to be_nil
|
40
|
+
end
|
34
41
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative '../../features_helper'
|
2
|
+
|
3
|
+
describe 'application generated with shoestrap new <name> --kuhsaft true' do
|
4
|
+
|
5
|
+
options = {kuhsaft: true}
|
6
|
+
|
7
|
+
let(:kuhsaft_migrations_count) { 14 }
|
8
|
+
let(:app_path){application_path(options)}
|
9
|
+
let(:migration_path) { File.join(app_path,'db/migrate/') }
|
10
|
+
let(:migrations_count) { Dir.glob(File.join(migration_path, '*kuhsaft*.rb')).size }
|
11
|
+
|
12
|
+
before :all do
|
13
|
+
generate_test_app_with_shoestrap(options)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'has the kuhsaft migrations installed' do
|
17
|
+
expect(migrations_count).to be kuhsaft_migrations_count
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'has db migrated with kuhsaft migrations' do
|
21
|
+
reload_application_gemfile(options)
|
22
|
+
migration_status = Dir.chdir(app_path) { rake 'db:migrate:status', options }
|
23
|
+
expect(migration_status.split("\n").select { |x| x.include? 'kuhsaft' }.size).to be kuhsaft_migrations_count
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'has the db with kuhsaft seeds' do
|
27
|
+
expect(Dir.chdir(app_path) { rails 'runner "puts Kuhsaft::BrickType.count"', options }.to_i).to be 11
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'has the kuhsaft assets installed' do
|
31
|
+
expect(application_file('app/assets/stylesheets/kuhsaft/cms/customizations.css.sass', options)).not_to be_nil
|
32
|
+
expect(application_file('app/assets/javascripts/kuhsaft/cms/customizations.js.coffee', options)).not_to be_nil
|
33
|
+
expect(application_file('app/assets/javascripts/kuhsaft/cms/ck-config.js.coffee', options)).not_to be_nil
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'has kuhsaft mounted as an engine on /' do
|
37
|
+
expect(application_file('config/routes.rb', options)).to match("mount Kuhsaft::Engine => '/'")
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'has the default image size initializer' do
|
41
|
+
expect(application_file('config/initializers/kuhsaft.rb', options)).not_to be_nil
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'generates a translation file for the available locales' do
|
45
|
+
translation_migrations = Dir[migration_path+'*add_*_translation.rb']
|
46
|
+
|
47
|
+
(I18n.available_locales - [:de, :en]).each do |locale|
|
48
|
+
matched_migration = translation_migrations.detect{|m| m.include?("add_#{locale}_translation.rb") }
|
49
|
+
expect(matched_migration).not_to be_nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'sets up the base views for the cms backend' do
|
54
|
+
pending 'which kind of base views do we want?'
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../../features_helper'
|
2
|
+
|
3
|
+
describe 'application generated with shoestrap new <name>' do
|
4
|
+
before :all do
|
5
|
+
generate_test_app_with_shoestrap
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:source_path) { File.join(File.dirname(__FILE__), '../../../templates/view_files_generator/') }
|
9
|
+
let(:app_path){ application_path }
|
10
|
+
|
11
|
+
it 'all view files copied' do
|
12
|
+
pending 'we still have to clarify which views are meaningful'
|
13
|
+
files = Dir[File.join(source_path, '**/**')].map{|p| p.gsub(/^.*view_files_generator\//,'') }
|
14
|
+
files.each do |file|
|
15
|
+
path = File.join(app_path, 'app/views', file)
|
16
|
+
expect(File.exists?(path)).to be_true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require_relative '../../shoestrap/shell'
|
3
|
+
|
4
|
+
module Shoestrap
|
5
|
+
class BaseGenerator < Rails::Generators::Base
|
6
|
+
def source_paths
|
7
|
+
[File.join(File.dirname(__FILE__), '../../../templates/', self.class.name.demodulize.underscore)]
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
def shoestrap_logger
|
12
|
+
self.class.shoestrap_logger
|
13
|
+
end
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def shoestrap_logger
|
17
|
+
return @shoestrap_logger if @shoestrap_logger.present?
|
18
|
+
if File.writable? '/tmp'
|
19
|
+
logfile = File.open("/tmp/shoestrap_#{(rails_root.split('/').last || '').gsub(/\W/,'_')}", 'a')
|
20
|
+
logfile.sync = true
|
21
|
+
@shoestrap_logger = Logger.new(logfile)
|
22
|
+
end
|
23
|
+
(@shoestrap_logger || Logger.new(STDOUT)).tap do |logger|
|
24
|
+
logger.level = Logger::DEBUG
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def rails_root
|
30
|
+
if defined?(Rails) && Rails.respond_to?(:root)
|
31
|
+
Rails.root.to_s
|
32
|
+
elsif defined?(RAILS_ROOT)
|
33
|
+
RAILS_ROOT
|
34
|
+
else
|
35
|
+
Dir.getwd
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -2,11 +2,7 @@ require 'rails/generators'
|
|
2
2
|
require_relative '../../shoestrap/shell'
|
3
3
|
|
4
4
|
module Shoestrap
|
5
|
-
class BddGenerator <
|
6
|
-
|
7
|
-
def source_paths
|
8
|
-
[File.join(File.dirname(__FILE__), '../../../templates/bdd_generator')]
|
9
|
-
end
|
5
|
+
class BddGenerator < BaseGenerator
|
10
6
|
|
11
7
|
def install_rspec
|
12
8
|
generate("rspec:install")
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require_relative '../../shoestrap/shell'
|
3
|
+
require_relative 'base_generator'
|
4
|
+
|
5
|
+
module Shoestrap
|
6
|
+
class CmsGenerator < BaseGenerator
|
7
|
+
def add_route
|
8
|
+
generate 'resource_route', resource_route_name
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_navigation_link
|
12
|
+
link_definition = "primary.item #{model_name.to_sym.inspect}, #{model_name.pluralize.inspect}, cms_#{model_name.pluralize}_path"
|
13
|
+
inject_into_file 'config/navigation.rb', link_definition, after: /navigation.items.+do.+primary/
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_model
|
17
|
+
generate 'model', model_name
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_controller
|
21
|
+
generate 'scaffold_controller', resource_route_name, scaffold_controller_options
|
22
|
+
|
23
|
+
controller_content = File.read(controller_path)
|
24
|
+
|
25
|
+
base_controller = kuhsaft_is_used? ? 'Kuhsaft::Cms::AdminController' : 'Shoestrap::BaseController'
|
26
|
+
controller_content.gsub!('ApplicationController', base_controller)
|
27
|
+
File.open(controller_path, 'w') { |file| file.puts controller_content }
|
28
|
+
|
29
|
+
inject_into_file controller_path, ' respond_to :html', after: /class Cms::.+Controller < #{base_controller}/
|
30
|
+
inject_into_file controller_path, ' actions :all, :except => [ :show ]', after: /class Cms::.+Controller < #{base_controller}/
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_shoestrap_basecontroller_if_kuhsaft_isnt_used
|
34
|
+
copy_file 'base_controller.rb', 'app/controllers/shoestrap/base_controller.rb'
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def kuhsaft_is_used?
|
40
|
+
!!defined?(Kuhsaft)
|
41
|
+
end
|
42
|
+
|
43
|
+
def controller_path
|
44
|
+
"app/controllers/#{resource_route_name.pluralize}_controller.rb"
|
45
|
+
end
|
46
|
+
|
47
|
+
def resource_route_name
|
48
|
+
"cms/#{model_name}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def model_name
|
52
|
+
ARGV.first
|
53
|
+
end
|
54
|
+
|
55
|
+
def scaffold_controller_options
|
56
|
+
"--no-routing-specs --no-view-specs --no-controller-specs --no-jbuilder"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -2,11 +2,7 @@ require 'rails/generators'
|
|
2
2
|
require_relative '../../shoestrap/shell'
|
3
3
|
|
4
4
|
module Shoestrap
|
5
|
-
class CoffeeFilesGenerator <
|
6
|
-
|
7
|
-
def source_paths
|
8
|
-
[File.join(File.dirname(__FILE__), '../../../templates/coffee_generator')]
|
9
|
-
end
|
5
|
+
class CoffeeFilesGenerator < BaseGenerator
|
10
6
|
|
11
7
|
def remove_application_js
|
12
8
|
remove_file 'app/assets/javascripts/application.js'
|