Module: Karst::Spec::Observer
- Defined in:
- lib/karst/spec/observer.rb
Overview
Turns real RSpec execution into Karst's route/scenario catalog.
Karst never parses spec source, route-helper arguments, or FactoryBot calls to build this catalog. It observes the same runtime facts the request-evidence engine already relies on -- ActiveSupport::Notifications for controller/render events, and Warden's public hooks for the authenticated principal -- while an example actually runs, and records only what those events say. An example that never issues an HTTP request produces no observation at all.
Explicitly out of scope here: provisioning scenario state, database cloning or isolation, browser/session switching, source analysis, and any UI. This module only builds and writes the catalog artifact. rubocop:disable Metrics/ModuleLength
Class Attribute Summary collapse
-
.output_path ⇒ Object
readonly
Returns the value of attribute output_path.
-
.reporter ⇒ Object
readonly
Returns the value of attribute reporter.
Class Method Summary collapse
-
.install!(output:) ⇒ Object
rubocop:disable Metrics/MethodLength.
-
.wrap_example(example) ⇒ Object
The one seam RSpec's
aroundhook calls into: start tracking, run the example, then convert whatever was tracked into an immutable ExampleObservation and hand it to the Reporter.
Class Attribute Details
.output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
52 53 54 |
# File 'lib/karst/spec/observer.rb', line 52 def output_path @output_path end |
.reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
52 53 54 |
# File 'lib/karst/spec/observer.rb', line 52 def reporter @reporter end |
Class Method Details
.install!(output:) ⇒ Object
rubocop:disable Metrics/MethodLength
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/karst/spec/observer.rb', line 55 def install!(output:) @install_mutex ||= Mutex.new @install_mutex.synchronize do return @reporter if @installed raise "Karst::Spec::Observer requires RSpec to already be loaded" unless defined?(RSpec) @output_path = output @reporter = Reporter.new subscribe_notifications subscribe_warden configure_rspec @installed = true @reporter end end |
.wrap_example(example) ⇒ Object
The one seam RSpec's around hook calls into: start tracking,
run the example, then convert whatever was tracked into an
immutable ExampleObservation and hand it to the Reporter.
76 77 78 79 80 81 82 |
# File 'lib/karst/spec/observer.rb', line 76 def wrap_example(example) karst_explicit, karst_name = (example) start_example! yield ensure finish_and_record!(example, karst_explicit: karst_explicit, karst_name: karst_name) end |