Class: Knapsack::Adapters::RSpecAdapter
- Inherits:
-
BaseAdapter
- Object
- BaseAdapter
- Knapsack::Adapters::RSpecAdapter
- Defined in:
- lib/knapsack/adapters/rspec_adapter.rb
Direct Known Subclasses
Constant Summary collapse
- TEST_DIR_PATTERN =
'spec/**{,/*/**}/*_spec.rb'
- REPORT_PATH =
'knapsack_rspec_report.json'
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from BaseAdapter
Class Method Details
.test_path(example) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/knapsack/adapters/rspec_adapter.rb', line 47 def self.test_path(example) example_group = example.[:example_group] if defined?(::Turnip) && Gem::Version.new(::Turnip::VERSION) < Gem::Version.new('2.0.0') unless example_group[:turnip] until example_group[:parent_example_group].nil? example_group = example_group[:parent_example_group] end end else until example_group[:parent_example_group].nil? example_group = example_group[:parent_example_group] end end example_group[:file_path] end |
Instance Method Details
#bind_report_generator ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/knapsack/adapters/rspec_adapter.rb', line 27 def bind_report_generator ::RSpec.configure do |config| config.after(:suite) do Knapsack.report.save Knapsack.logger.info(Presenter.report_details) end end end |
#bind_time_offset_warning ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/knapsack/adapters/rspec_adapter.rb', line 36 def bind_time_offset_warning ::RSpec.configure do |config| config.after(:suite) do Knapsack.logger.log( Presenter.time_offset_log_level, Presenter.time_offset_warning ) end end end |
#bind_time_tracker ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/knapsack/adapters/rspec_adapter.rb', line 7 def bind_time_tracker ::RSpec.configure do |config| config.prepend_before(:context) do Knapsack.tracker.start_timer end config.prepend_before(:each) do |example| Knapsack.tracker.test_path = RSpecAdapter.test_path(example) end config.append_after(:context) do Knapsack.tracker.stop_timer end config.after(:suite) do Knapsack.logger.info(Presenter.global_time) end end end |