Skip to content

Commit 06aa859

Browse files
author
fadimezhan
committed
KBP-173 #time 1h - add guardfile gem
1 parent 0228f4c commit 06aa859

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed

lib/cybele/app_builder.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ def generate_rollbar
8787
generate 'rollbar'
8888
end
8989

90+
def generate_guard
91+
bundle_command 'exec guard init'
92+
inject_into_file('Guardfile', template_content('guardfile/guardfile_settings.rb.erb'))
93+
end
94+
9095
def configure_bullet
9196
configure_environment 'development', template_content('bullet/bullet_settings.rb.erb')
9297
end

lib/cybele/generators/app_generator.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ def setup_rollbar
170170
build :generate_rollbar
171171
end
172172

173+
def setup_guard
174+
say 'Generate guard', :green
175+
build :generate_guard
176+
end
177+
173178
def configure_locale_language
174179
say 'Configure locale', :green
175180
build :configure_locale_language

templates/Gemfile.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ group :development, :test do
3535
gem 'pronto', '~> 0.9.5'
3636
gem 'pronto-flay', '~> 0.9.0', require: false
3737
gem 'pronto-rubocop', '~> 0.9.0', require: false
38+
gem 'guard', '~> 2.14', '>= 2.14.1'
3839
end
3940

4041
# A set of common locale data and translations to internationalize and/or localize your Rails applications.
@@ -44,4 +45,4 @@ gem 'rails-i18n', '~> 5.0', '>= 5.0.4'
4445
gem 'devise', '~> 4.3'
4546

4647
# Audited is an ORM extension that logs all changes to your models
47-
gem 'audited', '~> 4.5'
48+
gem 'audited', '~> 4.5'
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
guard :rspec, cmd: 'bundle exec rspec' do
3+
require 'guard/rspec/dsl'
4+
dsl = Guard::RSpec::Dsl.new(self)
5+
6+
# Feel free to open issues for suggestions and improvements
7+
8+
# RSpec files
9+
rspec = dsl.rspec
10+
watch(rspec.spec_helper) { rspec.spec_dir }
11+
watch(rspec.spec_support) { rspec.spec_dir }
12+
watch(rspec.spec_files)
13+
14+
# Ruby files
15+
ruby = dsl.ruby
16+
dsl.watch_spec_files_for(ruby.lib_files)
17+
18+
# Rails files
19+
rails = dsl.rails(view_extensions: %w(erb haml slim))
20+
dsl.watch_spec_files_for(rails.app_files)
21+
dsl.watch_spec_files_for(rails.views)
22+
23+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { 'spec/features' }
24+
watch(%r{^app/models/(.+)\.rb$}) { 'spec/features' }
25+
watch(rails.controllers) do |m|
26+
[
27+
rspec.spec.call("routing/#{m[1]}_routing"),
28+
rspec.spec.call("controllers/#{m[1]}_controller"),
29+
rspec.spec.call("acceptance/#{m[1]}")
30+
]
31+
end
32+
33+
# Rails config changes
34+
watch(rails.spec_helper) { rspec.spec_dir }
35+
watch(rails.routes) { 'spec' } #{ "#{rspec.spec_dir}/routing" }
36+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
37+
38+
# Watch jobs
39+
watch(%r{^app/jobs/(.+)_(job)\.rb$}) { 'spec/jobs' }
40+
41+
# Capybara features specs
42+
watch(rails.view_dirs) { 'spec/features' } # { |m| rspec.spec.call("features/#{m[1]}") }
43+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
44+
45+
# Turnip features and steps
46+
watch(%r{^spec/acceptance/(.+)\.feature$})
47+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
48+
Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
49+
end
50+
end

0 commit comments

Comments
 (0)