From 6c76454986ce15eb1d327d3efe139e127155b713 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 4 Nov 2016 22:58:54 +0000 Subject: [PATCH 1/3] ignore /crowbar_framework/vendor/bundle/ If we do "bundle install --deployment" then gems get installed into vendor/bundle/ which we don't want interfering with git. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1ef423c94f..6eb67e918a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ Gemfile.lock .bundle/config /vendor/ +/crowbar_framework/vendor/bundle/ From 8a46f2776d8012f9b5899cd110593cd72af215ed Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 4 Nov 2016 23:02:03 +0000 Subject: [PATCH 2/3] Make some gems development-only We want the :development group to contain gems which are needed for interactive development but not for automated testing. This will allow us to exclude them from CI runs, to speed up the runs, and also work around that the listen gem isn't supported on old Rubies any more. --- .travis.yml | 2 +- crowbar_framework/Gemfile | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1e7611e7fe..75d874024a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ gemfile: crowbar_framework/Gemfile install: - cd crowbar_framework - - bin/bundle install + - bin/bundle install --without development - bin/rake db:create db:migrate script: diff --git a/crowbar_framework/Gemfile b/crowbar_framework/Gemfile index 272fcadb21..059748dafd 100644 --- a/crowbar_framework/Gemfile +++ b/crowbar_framework/Gemfile @@ -59,15 +59,15 @@ gem "activeresource", "~> 4.0.0", require: "active_resource" unless ENV["PACKAGING"] && ENV["PACKAGING"] == "yes" - group :development, :test do - gem "brakeman", "~> 2.6.3" - gem "rspec-rails", "~> 3.3.0" + group :development do gem "byebug", "~> 8.2.2" gem "derailed_benchmarks", "~> 1.3.0" gem "stackprof", "~> 0.2.8" end group :test do + gem "rspec-rails", "~> 3.3.0" + gem "brakeman", "~> 2.6.3" gem "database_cleaner", "~> 1.4.1" gem "sinatra", "~> 1.4.5" gem "webmock", "~> 1.19.0" From 02f2c92805c311f2af2d8e60910811595126500f Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 4 Nov 2016 23:02:18 +0000 Subject: [PATCH 3/3] add guard environment Guard is indispensable for TDD red/green coding. https://github.com/guard/guard#readme --- crowbar_framework/Gemfile | 2 ++ crowbar_framework/Guardfile | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 crowbar_framework/Guardfile diff --git a/crowbar_framework/Gemfile b/crowbar_framework/Gemfile index 059748dafd..9fcd5d898b 100644 --- a/crowbar_framework/Gemfile +++ b/crowbar_framework/Gemfile @@ -63,6 +63,8 @@ unless ENV["PACKAGING"] && ENV["PACKAGING"] == "yes" gem "byebug", "~> 8.2.2" gem "derailed_benchmarks", "~> 1.3.0" gem "stackprof", "~> 0.2.8" + gem "guard-rspec" + gem "guard-bundler" end group :test do diff --git a/crowbar_framework/Guardfile b/crowbar_framework/Guardfile new file mode 100644 index 0000000000..b129f994be --- /dev/null +++ b/crowbar_framework/Guardfile @@ -0,0 +1,50 @@ +#!/usr/bin/ruby +# +# More info at https://github.com/guard/guard#readme + +guard_opts = { + cmd: "bundle exec rspec --fail-fast", + all_on_start: true, + all_after_pass: true, + failed_mode: :focus +} + +DEBUG = false + +def reload(target) + puts "-> #{target}" if DEBUG + target +end + +def all_specs; reload "all_specs"; "spec" end +def library_specs; reload "library_specs"; "spec/libraries" end +def provider_specs; reload "provider_specs"; "spec/providers" end + +group :rspec do + guard :rspec, guard_opts do + watch('app/controllers/application_controller.rb') { + "spec/controllers" + } + watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } + watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } + watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| + [ + "spec/routing/#{m[1]}_routing_spec.rb", + "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", + "spec/acceptance/#{m[1]}_spec.rb" + ] + } + watch(%r{^Gemfile$}) { all_specs } + watch(%r{^Gemfile.lock$}) { all_specs } + watch(%r{^spec/spec_helper\.rb$}) { all_specs } + watch(%r{^spec/helpers/.+\.rb$}) { all_specs } + watch(%r{^spec/.+_spec\.rb$}) + end +end + +group :bundler do + guard :bundler do + watch("Gemfile") + end +end