Class: BlinkSpec::BlinkSpecRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/blinkspec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBlinkSpecRunner

Returns a new instance of BlinkSpecRunner.



11
12
13
# File 'lib/blinkspec.rb', line 11

def initialize
  @spec_output_file = 'blinkspec.json'
end

Instance Attribute Details

#spec_output_fileObject

Returns the value of attribute spec_output_file.



9
10
11
# File 'lib/blinkspec.rb', line 9

def spec_output_file
  @spec_output_file
end

Instance Method Details

#run_specs(args) ⇒ Object

Run rspec and indicate progress with blink(1).

  • Args :

    • args -> rspec specific arguments that should be used separated by whitespace

  • Returns :

    • the number of successful, pending and failed results in that order



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/blinkspec.rb', line 21

def run_specs(args)
  begin
    # indicate that the specs are running
    blink("--glimmer --rgb=#{BlinkColor.running}")

    run_rspec_subprocess(args)
  rescue SystemExit, Interrupt
    # catch keyboard interrupt to remove generated file and cleanly exit
    blink("--blink 1 --rgb=#{BlinkColor.error}")
    return nil,nil,nil
  end

  # handle rspec execution errors
  exit_code = $?.exitstatus
  unless [0, 1].include? exit_code
    blink("--blink 1 --rgb=#{BlinkColor.error}")
    puts "Rspec could not be executed correctly. Exit Code: #{exit_code}"
    return nil,nil,nil
  end

  results
end