Sha256: f61c6dd327a87b513f816a6d937508f5e42910c0533c4547bee29050cac135fc
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
require 'shoulda_runner/ast_builder' module ShouldaRunner class Parser def initialize(test_file_path) @source = File.read(test_file_path) end def select_test(linenumber) test_names[linenumber] end private def test_names @asts ||= build_asts hash = {} @asts.each do |ast| ast.each do |node| # TODO: Improve this to make sure we are only considering test ASTs if node.children.empty? && !node.content.nil? && node.content[:line_range] from = node.content[:line_range][:from] to = node.content[:line_range][:to] test_name = build_test_name(node) from.upto(to) do |line| hash[line] = test_name end end end end hash end def build_test_name(node) test_name_string = node.content[:name] parent = node.parent while parent != nil test_name_string = "#{parent.content[:name]}#{test_name_string}" parent = parent.parent end test_name_string end def build_asts ast_builder = AstBuilder.new(@source) ast_builder.parse @asts = ast_builder.asts end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shoulda_runner-0.2.3 | lib/shoulda_runner/parser.rb |