Class: AppMap::RSpec::Recording
Instance Attribute Summary collapse
-
#example ⇒ Object
Returns the value of attribute example.
Instance Method Summary collapse
- #finish(failure, 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 |
# File 'lib/appmap/rspec.rb', line 77 def initialize(example) super webdriver_port = lambda do next 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 @trace = AppMap.tracing.trace @webdriver_port = webdriver_port.call 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(failure, exception) ⇒ Object
100 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 142 143 144 145 146 147 148 |
# File 'lib/appmap/rspec.rb', line 100 def finish(failure, exception) failed = true if failure || exception warn "Finishing recording of #{failed ? "failed " : ""} example #{example}" if AppMap::RSpec::LOG warn "Exception: #{exception}" if exception && AppMap::RSpec::LOG if failed failure_exception = failure || exception warn "Failure exception: #{failure_exception}" if AppMap::RSpec::LOG test_failure = Util.extract_test_failure(failure_exception) end 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", test_failure: test_failure, exception: exception, events: events end |
#source_location ⇒ Object
94 95 96 97 98 |
# File 'lib/appmap/rspec.rb', line 94 def source_location result = example.location_rerun_argument.split(":")[0] result = result[2..-1] if result.index("./") == 0 result end |