Class: Guard::MochaNode::SpecState

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/mocha_node/spec_state.rb

Constant Summary collapse

STDIN =
0
STDOUT =
1
STDERR =
2
THREAD =
3
SUCCESS_CODE =
0
ERROR_CODE =
1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSpecState

Returns a new instance of SpecState.



14
15
16
# File 'lib/guard/mocha_node/spec_state.rb', line 14

def initialize
  clear!
end

Instance Attribute Details

#failing_pathsObject

Returns the value of attribute failing_paths.



12
13
14
# File 'lib/guard/mocha_node/spec_state.rb', line 12

def failing_paths
  @failing_paths
end

Instance Method Details

#clear!Object



44
45
46
47
48
# File 'lib/guard/mocha_node/spec_state.rb', line 44

def clear!
  @passed = true
  @fixed  = false
  @failing_paths = []
end

#fixed?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/guard/mocha_node/spec_state.rb', line 40

def fixed?
  @fixed
end

#passing?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/guard/mocha_node/spec_state.rb', line 36

def passing?
  @passed
end

#update(run_paths = [], options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/guard/mocha_node/spec_state.rb', line 18

def update(run_paths = [], options = {})
  @run_paths = run_paths
  @io = Runner.run(@run_paths, options)
  @stdout     = @io[STDOUT]
  @stderr     = @io[STDERR]
  # stream stdout immediately
  until @stdout.eof?
    line = @stdout.gets
    print line if !line.strip.empty?
  end
  @stderr.each { |line| print line }
  @exitstatus = @io[THREAD].value rescue ERROR_CODE
  close_io
  update_passed_and_fixed
  update_failing_paths
  passing?
end