Class: Slightish::TestSuite
- Inherits:
-
Object
- Object
- Slightish::TestSuite
- Defined in:
- lib/slightish/test_suite.rb
Defined Under Namespace
Classes: ParseState
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#sandbox_template_dir ⇒ Object
readonly
Returns the value of attribute sandbox_template_dir.
-
#test_cases ⇒ Object
readonly
Returns the value of attribute test_cases.
Class Method Summary collapse
Instance Method Summary collapse
- #failed? ⇒ Boolean
- #failed_count ⇒ Object
- #failure_description ⇒ Object
-
#initialize(path, contents, sandbox_template_dir: nil) ⇒ TestSuite
constructor
A new instance of TestSuite.
- #passed? ⇒ Boolean
- #passed_count ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(path, contents, sandbox_template_dir: nil) ⇒ TestSuite
Returns a new instance of TestSuite.
12 13 14 15 16 17 18 |
# File 'lib/slightish/test_suite.rb', line 12 def initialize(path, contents, sandbox_template_dir: nil) @path = path @name = File.basename(path) @sandbox_template_dir = sandbox_template_dir parse(path, contents) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/slightish/test_suite.rb', line 5 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/slightish/test_suite.rb', line 5 def path @path end |
#sandbox_template_dir ⇒ Object (readonly)
Returns the value of attribute sandbox_template_dir.
6 7 8 |
# File 'lib/slightish/test_suite.rb', line 6 def sandbox_template_dir @sandbox_template_dir end |
#test_cases ⇒ Object (readonly)
Returns the value of attribute test_cases.
5 6 7 |
# File 'lib/slightish/test_suite.rb', line 5 def test_cases @test_cases end |
Class Method Details
.from_file(path, sandbox_template_dir: nil) ⇒ Object
8 9 10 |
# File 'lib/slightish/test_suite.rb', line 8 def self.from_file(path, sandbox_template_dir: nil) new(path, File.read(path), sandbox_template_dir: sandbox_template_dir) end |
Instance Method Details
#failed? ⇒ Boolean
44 45 46 |
# File 'lib/slightish/test_suite.rb', line 44 def failed? @test_cases.any?(&:failed?) end |
#failed_count ⇒ Object
52 53 54 |
# File 'lib/slightish/test_suite.rb', line 52 def failed_count @test_cases.count(&:failed?) end |
#failure_description ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/slightish/test_suite.rb', line 30 def failure_description res = '' @test_cases.select(&:failed?).each do |test| res += "❌ #{test.source_description}\n".bold res += test.failure_description + "\n\n" end res end |
#passed? ⇒ Boolean
40 41 42 |
# File 'lib/slightish/test_suite.rb', line 40 def passed? @test_cases.all?(&:passed?) end |
#passed_count ⇒ Object
48 49 50 |
# File 'lib/slightish/test_suite.rb', line 48 def passed_count @test_cases.count(&:passed?) end |