Class: PercentageFormatter::Output

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rspec_output) ⇒ Output

Returns a new instance of Output.



7
8
9
10
11
12
# File 'lib/percentage_formatter/output.rb', line 7

def initialize(rspec_output)
  self.rspec_output = rspec_output

  self.number_of_examples_executed = 0
  self.last_printed_percentage = -1
end

Instance Attribute Details

#last_printed_percentageObject

Returns the value of attribute last_printed_percentage.



5
6
7
# File 'lib/percentage_formatter/output.rb', line 5

def last_printed_percentage
  @last_printed_percentage
end

#number_of_examples_executedObject

Returns the value of attribute number_of_examples_executed.



5
6
7
# File 'lib/percentage_formatter/output.rb', line 5

def number_of_examples_executed
  @number_of_examples_executed
end

#rspec_outputObject

Returns the value of attribute rspec_output.



5
6
7
# File 'lib/percentage_formatter/output.rb', line 5

def rspec_output
  @rspec_output
end

Instance Method Details

#failure(notification) ⇒ Object



28
29
30
31
# File 'lib/percentage_formatter/output.rb', line 28

def failure(notification)
  instafail.example_failed(notification)
  rspec_output.puts
end

#incrementObject



22
23
24
25
26
# File 'lib/percentage_formatter/output.rb', line 22

def increment
  self.number_of_examples_executed += 1

  print_percentage_if_needed
end

#start(example_count) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/percentage_formatter/output.rb', line 14

def start(example_count)
  @example_count = example_count

  rspec_output.puts
  rspec_output.puts("Running ~ #{example_count} specs")
  rspec_output.puts
end