Class: AppMap::RSpec::Recording
- Inherits:
-
Struct
- Object
- Struct
- AppMap::RSpec::Recording
- Defined in:
- lib/appmap/rspec.rb
Instance Attribute Summary collapse
-
#example ⇒ Object
Returns the value of attribute example.
Instance Method Summary collapse
- #finish(exception) ⇒ Object
-
#initialize(example) ⇒ Recording
constructor
A new instance of Recording.
- #source_location ⇒ Object
Constructor Details
#initialize(example) ⇒ Recording
Returns a new instance of Recording.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/appmap/rspec.rb', line 77 def initialize(example) super webdriver_port = lambda do return unless defined?(page) && page&.driver # This is the ugliest thing ever but I don't want to lose it. # All the WebDriver calls are getting app-mapped and it's really unclear # what they are. page.driver.[:http_client].instance_variable_get('@server_url').port end warn "Starting recording of example #{example}@#{source_location}" if AppMap::RSpec::LOG GC.start @trace = AppMap.tracing.trace @webdriver_port = webdriver_port.() end |
Instance Attribute Details
#example ⇒ Object
Returns the value of attribute example
76 77 78 |
# File 'lib/appmap/rspec.rb', line 76 def example @example end |
Instance Method Details
#finish(exception) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/appmap/rspec.rb', line 101 def finish(exception) warn "Finishing recording of example #{example}" if AppMap::RSpec::LOG warn "Exception: #{exception}" if exception && AppMap::RSpec::LOG events = [] AppMap.tracing.delete @trace events << @trace.next_event.to_h while @trace.event? AppMap::RSpec.add_event_methods @trace.event_methods class_map = AppMap.class_map(@trace.event_methods) description = [] scope = ScopeExample.new(example) while scope description << scope.description scope = scope.parent end description.reject!(&:nil?) description.reject!(&Util.method(:blank?)) default_description = description.last description.reverse! normalize = lambda do |desc| desc.gsub('it should behave like', '') .gsub(/Controller$/, '') .gsub(/\s+/, ' ') .strip end full_description = normalize.call(description.join(' ')) AppMap::RSpec.save name: full_description, class_map: class_map, source_location: source_location, test_status: exception ? 'failed' : 'succeeded', exception: exception, events: events end |
#source_location ⇒ Object
95 96 97 98 99 |
# File 'lib/appmap/rspec.rb', line 95 def source_location result = example.location_rerun_argument.split(':')[0] result = result[2..-1] if result.index('./') == 0 result end |