Class: Guard::Bdd

Inherits:
Guard
  • Object
show all
Defined in:
lib/guard/bdd.rb,
lib/guard/bdd/state_machine.rb

Defined Under Namespace

Classes: StateMachine

Constant Summary collapse

VERSION =
'0.0.1'

Instance Method Summary collapse

Constructor Details

#initialize(watchers = [], options = {}) ⇒ Bdd

Initialize a Guard.

Parameters:

  • watchers (Array<Guard::Watcher>) (defaults to: [])

    the Guard file watchers

  • options (Hash) (defaults to: {})

    the custom Guard options



12
13
14
15
16
17
18
19
20
21
# File 'lib/guard/bdd.rb', line 12

def initialize(watchers = [], options = {})
  super
  options = {
    :acceptance_paths  => ['spec/acceptance'],
    :feature_paths     => ['features'],
    :integration_paths => ['spec/integration'],
    :unit_paths        => ['spec/unit']
  }.merge(options)
  @state_machine = StateMachine.new(options)
end

Instance Method Details

#run_allObject

Called when just ‘enter` is pressed This method should be principally used for long action like running all specs/tests/…

Raises:

  • (:task_has_failed)

    when run_all has failed



34
35
36
# File 'lib/guard/bdd.rb', line 34

def run_all
  @state_machine.run_all
end

#run_on_change(paths) ⇒ Object

Called on file(s) modifications that the Guard watches.

Parameters:

  • paths (Array<String>)

    the changes files or paths

Raises:

  • (:task_has_failed)

    when run_on_change has failed



41
42
43
44
# File 'lib/guard/bdd.rb', line 41

def run_on_change(paths)
  @state_machine.changed_paths = paths
  @state_machine.run_on_change
end

#run_on_deletion(paths) ⇒ Object

Called on file(s) deletions that the Guard watches.

Parameters:

  • paths (Array<String>)

    the deleted files or paths

Raises:

  • (:task_has_failed)

    when run_on_change has failed



49
50
51
# File 'lib/guard/bdd.rb', line 49

def run_on_deletion(paths)
  @state_machine.remove(paths)
end

#startObject

Call once when Guard starts. Please override initialize method to init stuff.

Raises:

  • (:task_has_failed)

    when start has failed



26
27
28
# File 'lib/guard/bdd.rb', line 26

def start
  @state_machine.startup
end