1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
Feature: watch directories
In order to receive only relevant changes
As a user
I want to specify which directories Guard should monitor
Background: Guard is installed through bundler
Given Guard is bundled using source
@spawn
Scenario: Watch current directory by default
Given my Guardfile contains:
"""
require 'guard/plugin'
module ::Guard
class Myplugin < Plugin
def run_on_additions(files)
$stdout.puts "Files added: #{files.inspect}"
$stdout.flush
end
end
end
guard(:myplugin) { watch(/foo/) }
"""
Given I start `bundle exec guard -n f`
And I create a file "foo"
And I wait for Guard to become idle
And I stop guard
Then the output should match /Files added: \["foo"\]/
@spawn
Scenario: Watch only given directory
Given my Guardfile contains:
"""
$stdout.sync = true
require 'guard/plugin'
module ::Guard
class Myplugin < Plugin
def run_on_additions(files)
$stdout.puts "Files added: #{files.inspect}"
$stdout.flush
end
end
end
guard(:myplugin) { watch(/.*/) }
"""
Given a directory named "not_watched"
And a directory named "watched"
And I start `bundle exec guard -n f -w watched`
And I create a file "watched/foo"
And I create a file "not_watch/foo"
And I wait for Guard to become idle
And I stop guard
Then the output should match /Files added: \["watched.foo"\]/
@spawn
Scenario: Watch directories provided in Guardfile
Given my Guardfile contains:
"""
$stdout.sync = true
$stderr.sync = true
require 'guard/plugin'
directories ['watched']
module ::Guard
class Myplugin < Plugin
def run_on_additions(files)
$stdout.puts "Files added: #{files.inspect}"
$stdout.flush
end
end
end
guard(:myplugin) { watch(/.*/) }
"""
Given a directory named "not_watched"
And a directory named "watched"
And I start `bundle exec guard -n f`
And I create a file "watched/foo"
And I create a file "not_watch/foo"
And I wait for Guard to become idle
And I stop guard
Then the output should match /Files added: \["watched.foo"\]/
|