Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guard support #767

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Gemfile.lock

.bundle/config
/vendor/
/crowbar_framework/vendor/bundle/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 5 additions & 3 deletions crowbar_framework/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,17 @@ 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"
gem "guard-rspec"
gem "guard-bundler"
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"
Expand Down
50 changes: 50 additions & 0 deletions crowbar_framework/Guardfile
Original file line number Diff line number Diff line change
@@ -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"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we mention the application_controller here explicitely?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because if the application_controller changes, all controllers need to be retested.

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