summaryrefslogtreecommitdiff
path: root/Guardfile
blob: 28fe7a66a4a6f51e576a4001eec30641b0fa208d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

require_relative 'spec/support/integration_specs'

run_all = lambda do |*|
  Compat::UI.info('Running all integration tests', reset: true)
  run_all_integration_specs(logger: ->(msg) { Compat::UI.info(msg) })
end

guard 'rspec', all_on_start: false, cmd: 'bundle exec rspec', run_all: { cmd: 'bundle exec rspec --exclude-pattern "spec/integration/**/*_spec.rb"' } do
  watch(%r{^spec(?!/integration)/.+_spec\.rb})
  watch(%r{^lib/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
  watch('spec/spec_helper.rb') { 'spec' }
end

guard :yield, run_all: run_all do
  watch(%r{^lib/(.+)\.rb}) { run_all.call }
  watch(%r{^spec/integration/(?<integration>.*)/.+_spec\.rb}) do |file, integration|
    Compat::UI.info(%(Running "#{integration}" integration test), reset: true)
    system(integration_command(integration, 'bundle --quiet'))
    system(integration_command(integration, "bundle exec rspec #{file}"))
  end
end