Skip to content

Commit

Permalink
KBP-173 #time 1h - add guardfile gem
Browse files Browse the repository at this point in the history
fadimezhan committed Dec 4, 2017
1 parent 0228f4c commit 06aa859
Showing 4 changed files with 62 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/cybele/app_builder.rb
Original file line number Diff line number Diff line change
@@ -87,6 +87,11 @@ def generate_rollbar
generate 'rollbar'
end

def generate_guard
bundle_command 'exec guard init'
inject_into_file('Guardfile', template_content('guardfile/guardfile_settings.rb.erb'))
end

def configure_bullet
configure_environment 'development', template_content('bullet/bullet_settings.rb.erb')
end
5 changes: 5 additions & 0 deletions lib/cybele/generators/app_generator.rb
Original file line number Diff line number Diff line change
@@ -170,6 +170,11 @@ def setup_rollbar
build :generate_rollbar
end

def setup_guard
say 'Generate guard', :green
build :generate_guard
end

def configure_locale_language
say 'Configure locale', :green
build :configure_locale_language
3 changes: 2 additions & 1 deletion templates/Gemfile.erb
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ group :development, :test do
gem 'pronto', '~> 0.9.5'
gem 'pronto-flay', '~> 0.9.0', require: false
gem 'pronto-rubocop', '~> 0.9.0', require: false
gem 'guard', '~> 2.14', '>= 2.14.1'
end

# 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'
gem 'devise', '~> 4.3'

# Audited is an ORM extension that logs all changes to your models
gem 'audited', '~> 4.5'
gem 'audited', '~> 4.5'
50 changes: 50 additions & 0 deletions templates/guardfile/guardfile_settings.rb.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

guard :rspec, cmd: 'bundle exec rspec' do
require 'guard/rspec/dsl'
dsl = Guard::RSpec::Dsl.new(self)

# Feel free to open issues for suggestions and improvements

# RSpec files
rspec = dsl.rspec
watch(rspec.spec_helper) { rspec.spec_dir }
watch(rspec.spec_support) { rspec.spec_dir }
watch(rspec.spec_files)

# Ruby files
ruby = dsl.ruby
dsl.watch_spec_files_for(ruby.lib_files)

# Rails files
rails = dsl.rails(view_extensions: %w(erb haml slim))
dsl.watch_spec_files_for(rails.app_files)
dsl.watch_spec_files_for(rails.views)

watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { 'spec/features' }
watch(%r{^app/models/(.+)\.rb$}) { 'spec/features' }
watch(rails.controllers) do |m|
[
rspec.spec.call("routing/#{m[1]}_routing"),
rspec.spec.call("controllers/#{m[1]}_controller"),
rspec.spec.call("acceptance/#{m[1]}")
]
end

# Rails config changes
watch(rails.spec_helper) { rspec.spec_dir }
watch(rails.routes) { 'spec' } #{ "#{rspec.spec_dir}/routing" }
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }

# Watch jobs
watch(%r{^app/jobs/(.+)_(job)\.rb$}) { 'spec/jobs' }

# Capybara features specs
watch(rails.view_dirs) { 'spec/features' } # { |m| rspec.spec.call("features/#{m[1]}") }
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }

# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
end
end

0 comments on commit 06aa859

Please sign in to comment.