Class: LearnLab::Test::Strategy
- Inherits:
-
Object
- Object
- LearnLab::Test::Strategy
- Defined in:
- lib/learn_lab/test/strategy.rb
Overview
Base class for all test tools. Extracted from the ‘learn-test` gem with some modifications (i.e. this doesn’t talk to Ironboard).
Direct Known Subclasses
LearnLab::Test::Strategies::Mocha, LearnLab::Test::Strategies::None, LearnLab::Test::Strategies::Rspec
Instance Attribute Summary collapse
-
#fs ⇒ Object
readonly
Returns the value of attribute fs.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#out ⇒ Object
readonly
Returns the value of attribute out.
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
Instance Method Summary collapse
- #check_dependencies ⇒ Object
- #cleanup ⇒ Object
-
#initialize(runner, out = $stdout) ⇒ Strategy
constructor
A new instance of Strategy.
-
#output ⇒ Object
rubocop:enable Metrics/MethodLength.
- #parser ⇒ Object
- #result_filename ⇒ Object
-
#results ⇒ Object
rubocop:disable Metrics/MethodLength.
- #run ⇒ Object
Constructor Details
permalink #initialize(runner, out = $stdout) ⇒ Strategy
Returns a new instance of Strategy.
11 12 13 14 15 16 |
# File 'lib/learn_lab/test/strategy.rb', line 11 def initialize(runner, out=$stdout) @runner = runner @options = runner. @out = out @fs = LearnLab.file_system end |
Instance Attribute Details
permalink #fs ⇒ Object (readonly)
Returns the value of attribute fs.
9 10 11 |
# File 'lib/learn_lab/test/strategy.rb', line 9 def fs @fs end |
permalink #options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/learn_lab/test/strategy.rb', line 9 def @options end |
permalink #out ⇒ Object (readonly)
Returns the value of attribute out.
9 10 11 |
# File 'lib/learn_lab/test/strategy.rb', line 9 def out @out end |
permalink #runner ⇒ Object (readonly)
Returns the value of attribute runner.
9 10 11 |
# File 'lib/learn_lab/test/strategy.rb', line 9 def runner @runner end |
Instance Method Details
permalink #check_dependencies ⇒ Object
[View source]
18 |
# File 'lib/learn_lab/test/strategy.rb', line 18 def check_dependencies; end |
permalink #cleanup ⇒ Object
[View source]
55 56 57 |
# File 'lib/learn_lab/test/strategy.rb', line 55 def cleanup fs.rm(result_file_path) if result_file? end |
permalink #output ⇒ Object
rubocop:enable Metrics/MethodLength
49 50 51 52 53 |
# File 'lib/learn_lab/test/strategy.rb', line 49 def output return unless result_file? fs.read_json_file(result_file_path) end |
permalink #parser ⇒ Object
26 27 28 |
# File 'lib/learn_lab/test/strategy.rb', line 26 def parser raise NotImplementedError.new('you must define a parser') end |
permalink #result_filename ⇒ Object
[View source]
59 60 61 |
# File 'lib/learn_lab/test/strategy.rb', line 59 def result_filename '.results.json' end |
permalink #results ⇒ Object
rubocop:disable Metrics/MethodLength
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/learn_lab/test/strategy.rb', line 31 def results { repo_name: runner.repo, build: { test_suite: [{ framework: parser.framework, formatted_output: output, duration: parser.duration }] }, example_count: parser.example_count, passing_count: parser.passing_count, pending_count: parser.pending_count, failure_count: parser.failure_count } end |
permalink #run ⇒ Object
20 21 22 23 24 |
# File 'lib/learn_lab/test/strategy.rb', line 20 def run raise NotImplementedError.new( 'you must implement how this strategy runs its tests' ) end |