Skip to content

Instantly share code, notes, and snippets.

@RobinDaugherty
Created February 21, 2020 18:06
Show Gist options
  • Select an option

  • Save RobinDaugherty/ad5862d12c6eae587c321dd89bde827d to your computer and use it in GitHub Desktop.

Select an option

Save RobinDaugherty/ad5862d12c6eae587c321dd89bde827d to your computer and use it in GitHub Desktop.

Revisions

  1. RobinDaugherty created this gist Feb 21, 2020.
    50 changes: 50 additions & 0 deletions Guardfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    # frozen_string_literal: true

    # notification :terminal_notifier

    ignore %r{^(tmp|log|run|bin)/}

    # guard 'migrate', test_prepare: true do
    # watch(%r{^db/migrate/(\d+).+\.rb})
    # watch('db/seeds.rb')
    # end

    # Runs rubocop only after the tests have passed.
    # https://github.com/yujinakayama/guard-rubocop#advanced-tips
    group :red_green_refactor, halt_on_fail: true do
    test_options = {
    spring: 'bin/rails test',
    failed_mode: :keep,
    all_on_start: false,
    }

    guard :minitest, test_options do
    watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
    watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
    watch(%r{^app/controllers/(.+)_controller\.rb$}) do |m|
    "test/integration/#{m[1]}_test.rb"
    end
    watch(%r{^app/views/(.+)_mailer/.+}) do |m|
    "test/mailers/#{m[1]}_mailer_test.rb"
    end
    watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
    watch(%r{^test/.+_test\.rb$})
    watch(%r{^test/test_helper\.rb$}) { 'test' }
    end

    rubocop_options = {
    cli: %w[-D --format fuubar],
    all_on_start: false,
    keep_failed: false,
    }

    guard :rubocop, rubocop_options do
    watch('Guardfile')
    watch('config.ru')
    watch('Rakefile')
    watch(%r{.+\.rb$})
    watch(%r{.+\.rake$})
    # Rerun rubocop on everything in the folder or below a .rubocop.yml file
    watch(%r{(?:.+/)?rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
    end
    end