Skip to content

Commit

Permalink
Merged in feature/add_guardfile_to_project_folder (pull request #33)
Browse files Browse the repository at this point in the history
KBP-173 #time 1h - add guardfile gem

Approved-by: İsmail Akbudak <[email protected]>
  • Loading branch information
Fadime Özhan authored and Hamdi Bayhan committed Dec 8, 2017
2 parents 1c57749 + a32de32 commit 19a0b04
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/cybele/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ def generate_rollbar
generate 'rollbar'
end

def generate_guard
bundle_command 'exec guard init'
inject_into_file('Guardfile', "\n\n#{template_content('guardfile/guardfile_settings.rb.erb')}",
after: 'config/Guardfile" instead of "Guardfile"')
end

def configure_bullet
configure_environment 'development', template_content('bullet/bullet_settings.rb.erb')
end
Expand Down
5 changes: 5 additions & 0 deletions lib/cybele/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions spec/features/new_default_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,11 @@
it 'uses pronto' do
pronto_test
end

it 'uses guardfile' do
gemfile_file = content('Gemfile')
expect(gemfile_file).to match("gem 'guard'")

expect(File).to exist(file_project_path('Guardfile'))
end
end
7 changes: 7 additions & 0 deletions spec/features/new_not_default_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,11 @@
it 'uses pronto' do
pronto_test
end

it 'uses guardfile' do
gemfile_file = content('Gemfile')
expect(gemfile_file).to match("gem 'guard'")

expect(File).to exist(file_project_path('Guardfile'))
end
end
3 changes: 2 additions & 1 deletion templates/Gemfile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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'
49 changes: 49 additions & 0 deletions templates/guardfile/guardfile_settings.rb.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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 19a0b04

Please sign in to comment.