Sha256: 962dafcb59bdbebfc35cafe1a257fc33a71a413633acad0ece36884f847cd92e
Contents?: true
Size: 1.3 KB
Versions: 8
Compression:
Stored size: 1.3 KB
Contents
module Jasmine class Results attr_reader :suites attr_accessor :example_locations def initialize(result_hash, suite_hash, spec_files_full_paths) @suites = suite_hash @results = result_hash @spec_files_full_paths = spec_files_full_paths end def for_spec_id(id) @results[id] end def example_location_for(spec_description) @example_locations ||= example_locations @example_locations[spec_description] end def example_locations example_locations = {} example_name_parts = [] previous_indent_level = 0 @spec_files_full_paths.each do |filename| line_number = 1 File.open(filename, "r") do |file| file.readlines.each do |line| match = /^(\s*)(describe|it)\s*\(\s*["'](.*)["']\s*,\s*function/.match(line) if (match) indent_level = match[1].length / 2 example_name = match[3] example_name_parts[indent_level] = example_name full_example_name = example_name_parts.slice(0, indent_level + 1).join(" ") example_locations[full_example_name] = "#{filename}:#{line_number}: in `it'" end line_number += 1 end end end example_locations end end end
Version data entries
8 entries across 8 versions & 1 rubygems