bikeindex/bike_index

View on GitHub
Guardfile_parallel

Summary

Maintainability
Test Coverage
directories %w[app spec config]

group :red_green_refactor, halt_on_fail: true do
  rspec_options = {
    cmd: "bin/parallel_rspec --test-options='-f documentation -o /dev/null -f progress",
    cmd_additional_args: "--require rails_helper --no-profile --order defined'",
    run_all: {
      cmd: "bin/parallel_rspec --quiet --test-options='-f documentation -o /dev/null -f progress",
      cmd_additional_args: "'"
    },
    failed_mode: :focus,
    all_after_pass: false
  }

  guard :rspec, rspec_options do
    watch(%r{^spec/.+_spec\.rb$})

    watch(%r{^app/integrations/(.+)\.rb$}) { |m| "spec/integrations/#{m[1]}_spec.rb" }
    watch(%r{^config/initializers/(.+)\.rb$}) { |m| "spec/initializers/#{m[1]}_spec.rb" }

    watch(%r{^spec/(spec|rails)_helper\.rb$}) { "spec" }
    watch("config/routes.rb") { "spec/routing" }

    # App files with typical parallel structure
    watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
    watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }

    # Special cases for controller and request specs
    watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "spec/requests/#{m[1]}_request_spec.rb" }
    watch(%r{^app/controllers/api/(.+)\.rb$}) { |m| "spec/requests/api/#{m[1]}_spec.rb" }

    # Base classes
    # watch("app/controllers/application_controller.rb") { "spec/controllers" }
    # watch("app/controllers/api/base.rb") { "spec/controllers/api" }
    # watch("app/controllers/admin/base_controller.rb") { "spec/controllers/admin" }
    # watch("app/decorators/application_decorator.rb") { "spec/decorators" }
    # watch("app/decorators/application_helper.rb") { "spec/helpers" }
  end

  guard :rubocop, all_on_start: false do
    watch(%r{^app/(.+)\.rb$})
    watch(%r{^spec/(.+)\.rb$})
    watch(%r{^config/(.+)\.rb$})
    watch(%r{^db/(.+)\.rb$})
    watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
  end
end