Sha256: f949fe3d30ace835142a9bda1d1e7a92f24763e19b432b657fcbae2cd99e8a35

Contents?: true

Size: 1.02 KB

Versions: 12

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe 'AppMap::ClassMap' do
  describe '.build_from_methods' do
    it 'includes source code if available' do
      map = AppMap.class_map([scoped_method(method(:test_method))])
      function = dig_map(map, 5)[0]
      expect(function[:source]).to include 'test method body'
      expect(function[:comment]).to include 'test method comment'
    end

    it 'can omit source code even if available' do
      map = AppMap.class_map([scoped_method((method :test_method))], include_source: false)
      function = dig_map(map, 5)[0]
      expect(function).to_not include(:source)
      expect(function).to_not include(:comment)
    end

    # test method comment
    def test_method
      'test method body'
    end

    def scoped_method(method)
      AppMap::Trace::ScopedMethod.new AppMap::Config::Package.new, method.receiver.class.name, method, false
    end

    def dig_map(map, depth)
      return map if depth == 0

      dig_map map[0][:children], depth - 1
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
appmap-0.43.0 spec/class_map_spec.rb
appmap-0.42.1 spec/class_map_spec.rb
appmap-0.42.0 spec/class_map_spec.rb
appmap-0.41.2 spec/class_map_spec.rb
appmap-0.41.1 spec/class_map_spec.rb
appmap-0.41.0 spec/class_map_spec.rb
appmap-0.40.0 spec/class_map_spec.rb
appmap-0.39.1 spec/class_map_spec.rb
appmap-0.39.0 spec/class_map_spec.rb
appmap-0.38.1 spec/class_map_spec.rb
appmap-0.37.2 spec/class_map_spec.rb
appmap-0.37.0 spec/class_map_spec.rb