Class: PolishGeeks::DevTools::Commands::Simplecov
- Defined in:
- lib/polish_geeks/dev_tools/commands/simplecov.rb
Overview
Command wrapper for Simple code coverage analysing It informs us if we didn’t reach a proper code coverage level
Constant Summary collapse
- NUMBER_REGEXP =
Regexp used to match float number from coverage
/(\d+[.]\d+)/
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#error_message ⇒ String
Message that should be printed when code coverage level is not met.
-
#execute ⇒ String
Executes this command.
-
#label ⇒ String
Default label for this command.
-
#to_f ⇒ Float
Code coverage level.
-
#valid? ⇒ Boolean
True if code coverage level is higher or equal to expected.
Methods inherited from Base
Instance Method Details
#error_message ⇒ String
Returns message that should be printed when code coverage level is not met.
37 38 39 40 |
# File 'lib/polish_geeks/dev_tools/commands/simplecov.rb', line 37 def 'SimpleCov coverage level needs to be ' \ "#{threshold}%#{threshold == limit ? '' : ' or more'}, was #{to_f}%" end |
#execute ⇒ String
Executes this command
22 23 24 |
# File 'lib/polish_geeks/dev_tools/commands/simplecov.rb', line 22 def execute @output = stored_output.rspec[*Validators::Simplecov::MATCH_REGEXP] end |
#label ⇒ String
Returns default label for this command.
32 33 34 |
# File 'lib/polish_geeks/dev_tools/commands/simplecov.rb', line 32 def label "SimpleCov covered #{to_f}%, required #{threshold}%" end |
#to_f ⇒ Float
Returns code coverage level.
16 17 18 |
# File 'lib/polish_geeks/dev_tools/commands/simplecov.rb', line 16 def to_f output[*NUMBER_REGEXP].to_f end |
#valid? ⇒ Boolean
Returns true if code coverage level is higher or equal to expected.
27 28 29 |
# File 'lib/polish_geeks/dev_tools/commands/simplecov.rb', line 27 def valid? to_f >= threshold end |