Class: TestProf::TPSProf::RSpecListener
- Inherits:
-
Object
- Object
- TestProf::TPSProf::RSpecListener
- Includes:
- Logging
- Defined in:
- lib/test_prof/tps_prof/rspec.rb
Overview
:nodoc:
Constant Summary collapse
- NOTIFICATIONS =
%i[ example_group_started example_group_finished example_started example_finished ].freeze
Constants included from Logging
Instance Attribute Summary collapse
-
#profiler ⇒ Object
readonly
Returns the value of attribute profiler.
-
#reporter ⇒ Object
readonly
Returns the value of attribute reporter.
Instance Method Summary collapse
- #example_finished(notification) ⇒ Object
- #example_group_finished(notification) ⇒ Object
- #example_group_started(notification) ⇒ Object
- #example_started(notification) ⇒ Object
-
#initialize ⇒ RSpecListener
constructor
A new instance of RSpecListener.
- #print ⇒ Object
Methods included from Logging
Constructor Details
#initialize ⇒ RSpecListener
Returns a new instance of RSpecListener.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/test_prof/tps_prof/rspec.rb', line 17 def initialize @profiler = Profiler.new(TPSProf.config.top_count, TPSProf.config) @reporter = TPSProf.config.reporter conf = TPSProf.config if conf.mode == :strict config_parts = [] if conf.custom_strict_handler config_parts << "custom handler" else config_parts << "max examples: #{conf.max_examples_count}" if conf.max_examples_count config_parts << "max group time: #{conf.max_group_time}" if conf.max_group_time config_parts << "min tps: #{conf.min_tps}" if conf.min_tps end log :info, "TPSProf strict enabled (#{config_parts.join(", ")})" else log :info, "TPSProf enabled (top-#{TPSProf.config.top_count})" end end |
Instance Attribute Details
#profiler ⇒ Object (readonly)
Returns the value of attribute profiler.
15 16 17 |
# File 'lib/test_prof/tps_prof/rspec.rb', line 15 def profiler @profiler end |
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
15 16 17 |
# File 'lib/test_prof/tps_prof/rspec.rb', line 15 def reporter @reporter end |
Instance Method Details
#example_finished(notification) ⇒ Object
59 60 61 62 63 |
# File 'lib/test_prof/tps_prof/rspec.rb', line 59 def example_finished(notification) return if notification.example.[:tps_prof] == :ignore profiler.example_finished notification.example end |
#example_group_finished(notification) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/test_prof/tps_prof/rspec.rb', line 46 def example_group_finished(notification) return unless notification.group.top_level? return if notification.group.[:tps_prof] == :ignore profiler.group_finished notification.group end |
#example_group_started(notification) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/test_prof/tps_prof/rspec.rb', line 39 def example_group_started(notification) return unless notification.group.top_level? return if notification.group.[:tps_prof] == :ignore profiler.group_started notification.group end |
#example_started(notification) ⇒ Object
53 54 55 56 57 |
# File 'lib/test_prof/tps_prof/rspec.rb', line 53 def example_started(notification) return if notification.example.[:tps_prof] == :ignore profiler.example_started notification.example end |
#print ⇒ Object
65 66 67 |
# File 'lib/test_prof/tps_prof/rspec.rb', line 65 def print reporter.print(profiler) end |