diff --git a/spec/diver_down/definition/method_id_spec.rb b/spec/diver_down/definition/method_id_spec.rb index 3a173b0..955a3e2 100644 --- a/spec/diver_down/definition/method_id_spec.rb +++ b/spec/diver_down/definition/method_id_spec.rb @@ -62,8 +62,8 @@ ), ].shuffle - expect(array.sort.map(&:name)).to eq(%w[a b b c]) - expect(array.sort.map(&:context)).to eq(%w[class class instance class]) + expect(array.sort.map(&:name)).to eq(%w[a b c b]) + expect(array.sort.map(&:context)).to eq(%w[class class class instance]) end end diff --git a/spec/diver_down/trace/tracer_spec.rb b/spec/diver_down/trace/tracer_spec.rb index 0953bee..625cd47 100644 --- a/spec/diver_down/trace/tracer_spec.rb +++ b/spec/diver_down/trace/tracer_spec.rb @@ -378,15 +378,15 @@ def fill_default(hash) source_name: 'AntipollutionModule::B', method_ids: [ { - name: 'call_c', - context: 'instance', + name: 'new', + context: 'class', paths: [ match(/tracer_instance\.rb:\d+/), ], }, { - name: 'new', - context: 'class', + name: 'call_c', + context: 'instance', paths: [ match(/tracer_instance\.rb:\d+/), ], @@ -402,15 +402,15 @@ def fill_default(hash) source_name: 'AntipollutionModule::C', method_ids: [ { - name: 'call_d', - context: 'instance', + name: 'new', + context: 'class', paths: [ match(/tracer_instance\.rb:\d+/), ], }, { - name: 'new', - context: 'class', + name: 'call_d', + context: 'instance', paths: [ match(/tracer_instance\.rb:\d+/), ], @@ -462,15 +462,15 @@ def fill_default(hash) source_name: 'AntipollutionModule::B', method_ids: [ { - name: 'call_c', - context: 'instance', + name: 'new', + context: 'class', paths: [ match(/tracer_subclass\.rb:\d+/), ], }, { - name: 'new', - context: 'class', + name: 'call_c', + context: 'instance', paths: [ match(/tracer_subclass\.rb:\d+/), ], @@ -486,15 +486,15 @@ def fill_default(hash) source_name: 'AntipollutionModule::C', method_ids: [ { - name: 'call_d', - context: 'instance', + name: 'new', + context: 'class', paths: [ match(/tracer_subclass\.rb:\d+/), ], }, { - name: 'new', - context: 'class', + name: 'call_d', + context: 'instance', paths: [ match(/tracer_subclass\.rb:\d+/), ], diff --git a/spec/diver_down/web/definition_to_dot_spec.rb b/spec/diver_down/web/definition_to_dot_spec.rb index 10d59f8..d92cf38 100644 --- a/spec/diver_down/web/definition_to_dot_spec.rb +++ b/spec/diver_down/web/definition_to_dot_spec.rb @@ -75,8 +75,8 @@ def build_definition(title: 'title', sources: []) expect(instance.to_s).to eq(<<~DOT) strict digraph "title" { "a.rb" [label="a.rb" id="graph_1"] - "a.rb" -> "b.rb" - "b.rb" [label="b.rb" id="graph_2"] + "a.rb" -> "b.rb" [id="graph_2"] + "b.rb" [label="b.rb" id="graph_3"] } DOT @@ -88,6 +88,11 @@ def build_definition(title: 'title', sources: []) source_name: 'a.rb', }, { id: 'graph_2', + type: 'dependency', + source_name: 'b.rb', + method_ids: [], + }, { + id: 'graph_3', type: 'source', source_name: 'b.rb', }, @@ -118,8 +123,8 @@ def build_definition(title: 'title', sources: []) expect(instance.to_s).to eq(<<~DOT) strict digraph "title" { subgraph "cluster_A" { - label="A" subgraph "cluster_B" { - label="B" "a.rb" [label="a.rb" id="graph_1"] + label="A" id="graph_1" subgraph "cluster_B" { + label="B" id="graph_2" "a.rb" [label="a.rb" id="graph_3"] } } } @@ -129,6 +134,14 @@ def build_definition(title: 'title', sources: []) [ { id: 'graph_1', + type: 'module', + module_name: 'A', + }, { + id: 'graph_2', + type: 'module', + module_name: 'B', + }, { + id: 'graph_3', type: 'source', source_name: 'a.rb', }, @@ -178,14 +191,14 @@ def build_definition(title: 'title', sources: []) strict digraph "title" { compound=true subgraph "cluster_A" { - label="A" "a.rb" [label="a.rb" id="graph_1"] + label="A" id="graph_1" "a.rb" [label="a.rb" id="graph_2"] } - "a.rb" -> "b.rb" [ltail="cluster_A" lhead="cluster_B" minlen="3"] + "a.rb" -> "b.rb" [id="graph_3" ltail="cluster_A" lhead="cluster_B" minlen="3"] subgraph "cluster_B" { - label="B" "b.rb" [label="b.rb" id="graph_2"] + label="B" id="graph_5" "b.rb" [label="b.rb" id="graph_6"] } subgraph "cluster_B" { - label="B" "c.rb" [label="c.rb" id="graph_3"] + label="B" id="graph_7" "c.rb" [label="c.rb" id="graph_8"] } } DOT @@ -194,14 +207,36 @@ def build_definition(title: 'title', sources: []) [ { id: 'graph_1', + type: 'module', + module_name: 'A', + }, { + id: 'graph_2', type: 'source', source_name: 'a.rb', }, { - id: 'graph_2', + id: 'graph_3', + type: 'dependency', + source_name: 'b.rb', + method_ids: [], + }, { + id: 'graph_4', + type: 'dependency', + source_name: 'c.rb', + method_ids: [], + }, { + id: 'graph_5', + type: 'module', + module_name: 'B', + }, { + id: 'graph_6', type: 'source', source_name: 'b.rb', }, { - id: 'graph_3', + id: 'graph_7', + type: 'module', + module_name: 'B', + }, { + id: 'graph_8', type: 'source', source_name: 'c.rb', },