Class: Uspec::Harness
- Inherits:
-
Object
- Object
- Uspec::Harness
- Defined in:
- lib/uspec/harness.rb
Instance Attribute Summary collapse
-
#cli ⇒ Object
Returns the value of attribute cli.
-
#define ⇒ Object
Returns the value of attribute define.
Instance Method Summary collapse
- #file_eval(path, line) ⇒ Object
-
#initialize(cli) ⇒ Harness
constructor
A new instance of Harness.
- #inspect ⇒ Object
- #spec_eval(description, source, &block) ⇒ Object
- #stats ⇒ Object
Constructor Details
Instance Attribute Details
#cli ⇒ Object
Returns the value of attribute cli.
11 12 13 |
# File 'lib/uspec/harness.rb', line 11 def cli @cli end |
#define ⇒ Object
Returns the value of attribute define.
11 12 13 |
# File 'lib/uspec/harness.rb', line 11 def define @define end |
Instance Method Details
#file_eval(path, line) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/uspec/harness.rb', line 17 def file_eval path, line @path = path @line = line define.instance_eval(path.read, path.to_s) rescue Exception => error raise error if SystemExit === error result = Uspec::Errors.handle_file_error error, path, cli stats << result if result end |
#inspect ⇒ Object
62 63 64 65 66 |
# File 'lib/uspec/harness.rb', line 62 def inspect <<~MSG.chomp <#{self.class}##{self.object_id} @cli=#{@cli ? '<...>' : @cli} @define=#{@define ? '<...>' : @define}> MSG end |
#spec_eval(description, source, &block) ⇒ Object
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 |
# File 'lib/uspec/harness.rb', line 27 def spec_eval description, source, &block return if @line && !source.first.include?("#{@path}:#{@line}") ex = nil state = 0 print ' -- ', description if block then begin state = 1 spec = Uspec::Spec.new(self, description, &block) raw_result = spec.__uspec_block state = 2 rescue Exception => raw_result state = 3 ex = true end end result = Uspec::Result.new spec, raw_result, ex unless block then state = 4 result.pending! end print ': ', result.pretty, "\n" rescue => error result = Uspec::Errors.handle_internal_error error, cli ensure stats << result if result cli.handle_interrupt! result ? result.raw : raw_result return [state, error, result, raw_result] end |
#stats ⇒ Object
13 14 15 |
# File 'lib/uspec/harness.rb', line 13 def stats cli.stats end |