appmap 0.42.1 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.releaserc.yml +11 -0
- data/.travis.yml +33 -2
- data/CHANGELOG.md +44 -0
- data/README.md +74 -16
- data/README_CI.md +29 -0
- data/Rakefile +4 -2
- data/appmap.gemspec +5 -3
- data/lib/appmap.rb +3 -7
- data/lib/appmap/class_map.rb +11 -22
- data/lib/appmap/command/record.rb +1 -1
- data/lib/appmap/config.rb +180 -67
- data/lib/appmap/cucumber.rb +1 -1
- data/lib/appmap/event.rb +46 -27
- data/lib/appmap/handler/function.rb +19 -0
- data/lib/appmap/handler/net_http.rb +107 -0
- data/lib/appmap/handler/rails/request_handler.rb +124 -0
- data/lib/appmap/handler/rails/sql_handler.rb +152 -0
- data/lib/appmap/handler/rails/template.rb +149 -0
- data/lib/appmap/hook.rb +111 -70
- data/lib/appmap/hook/method.rb +6 -8
- data/lib/appmap/middleware/remote_recording.rb +1 -1
- data/lib/appmap/minitest.rb +22 -20
- data/lib/appmap/railtie.rb +5 -5
- data/lib/appmap/record.rb +1 -1
- data/lib/appmap/rspec.rb +22 -21
- data/lib/appmap/trace.rb +47 -6
- data/lib/appmap/util.rb +47 -2
- data/lib/appmap/version.rb +2 -2
- data/package-lock.json +3 -3
- data/release.sh +17 -0
- data/spec/abstract_controller_base_spec.rb +140 -34
- data/spec/class_map_spec.rb +5 -13
- data/spec/config_spec.rb +33 -1
- data/spec/fixtures/hook/custom_instance_method.rb +11 -0
- data/spec/fixtures/hook/method_named_call.rb +11 -0
- data/spec/fixtures/rails5_users_app/Gemfile +7 -3
- data/spec/fixtures/rails5_users_app/app/controllers/api/users_controller.rb +2 -0
- data/spec/fixtures/rails5_users_app/app/controllers/users_controller.rb +9 -1
- data/spec/fixtures/rails5_users_app/config/application.rb +2 -0
- data/spec/fixtures/rails5_users_app/create_app +8 -2
- data/spec/fixtures/rails5_users_app/spec/controllers/users_controller_api_spec.rb +13 -0
- data/spec/fixtures/rails5_users_app/spec/controllers/users_controller_spec.rb +2 -2
- data/spec/fixtures/rails5_users_app/spec/rails_helper.rb +3 -9
- data/spec/fixtures/rails6_users_app/Gemfile +5 -4
- data/spec/fixtures/rails6_users_app/app/controllers/api/users_controller.rb +1 -0
- data/spec/fixtures/rails6_users_app/app/controllers/users_controller.rb +9 -1
- data/spec/fixtures/rails6_users_app/config/application.rb +2 -0
- data/spec/fixtures/rails6_users_app/create_app +8 -2
- data/spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb +13 -0
- data/spec/fixtures/rails6_users_app/spec/controllers/users_controller_spec.rb +2 -2
- data/spec/fixtures/rails6_users_app/spec/rails_helper.rb +3 -9
- data/spec/hook_spec.rb +143 -22
- data/spec/record_net_http_spec.rb +160 -0
- data/spec/record_sql_rails_pg_spec.rb +1 -1
- data/spec/spec_helper.rb +16 -0
- data/test/expectations/openssl_test_key_sign1.json +2 -4
- data/test/gem_test.rb +1 -1
- data/test/rspec_test.rb +0 -13
- metadata +20 -14
- data/exe/appmap +0 -154
- data/lib/appmap/rails/request_handler.rb +0 -109
- data/lib/appmap/rails/sql_handler.rb +0 -150
- data/test/cli_test.rb +0 -116
data/spec/config_spec.rb
CHANGED
@@ -17,10 +17,42 @@ describe AppMap::Config, docker: false do
|
|
17
17
|
path: 'path-2',
|
18
18
|
exclude: [ 'exclude-1' ]
|
19
19
|
}
|
20
|
+
],
|
21
|
+
functions: [
|
22
|
+
{
|
23
|
+
package: 'pkg',
|
24
|
+
class: 'cls',
|
25
|
+
function: 'fn',
|
26
|
+
label: 'lbl'
|
27
|
+
}
|
20
28
|
]
|
21
29
|
}.deep_stringify_keys!
|
22
30
|
config = AppMap::Config.load(config_data)
|
23
31
|
|
24
|
-
|
32
|
+
config_expectation = {
|
33
|
+
exclude: [],
|
34
|
+
name: 'test',
|
35
|
+
packages: [
|
36
|
+
{
|
37
|
+
path: 'path-1',
|
38
|
+
handler_class: 'AppMap::Handler::Function'
|
39
|
+
},
|
40
|
+
{
|
41
|
+
path: 'path-2',
|
42
|
+
handler_class: 'AppMap::Handler::Function',
|
43
|
+
exclude: [ 'exclude-1' ]
|
44
|
+
}
|
45
|
+
],
|
46
|
+
functions: [
|
47
|
+
{
|
48
|
+
package: 'pkg',
|
49
|
+
class: 'cls',
|
50
|
+
functions: [ :fn ],
|
51
|
+
labels: ['lbl']
|
52
|
+
}
|
53
|
+
]
|
54
|
+
}.deep_stringify_keys!
|
55
|
+
|
56
|
+
expect(config.to_h.deep_stringify_keys!).to eq(config_expectation)
|
25
57
|
end
|
26
58
|
end
|
@@ -39,12 +39,16 @@ group :development, :test do
|
|
39
39
|
gem 'appmap', appmap_options
|
40
40
|
gem 'cucumber-rails', require: false
|
41
41
|
gem 'rspec-rails'
|
42
|
-
# Required for Sequel, since without ActiveRecord, the Rails transactional fixture support
|
43
|
-
# isn't activated.
|
44
|
-
gem 'database_cleaner'
|
45
42
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
46
43
|
gem 'pry-byebug'
|
47
44
|
end
|
48
45
|
|
46
|
+
group :test do
|
47
|
+
# Require only one of these.
|
48
|
+
# 'database_cleaner' requries 'database_cleaner-active_record', so don't require it.
|
49
|
+
gem 'database_cleaner-active_record', require: false
|
50
|
+
gem 'database_cleaner-sequel', require: false
|
51
|
+
end
|
52
|
+
|
49
53
|
group :development do
|
50
54
|
end
|
@@ -4,7 +4,15 @@ class UsersController < ApplicationController
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def show
|
7
|
-
|
7
|
+
find_user = lambda do |id|
|
8
|
+
if User.respond_to?(:[])
|
9
|
+
User[login: id]
|
10
|
+
else
|
11
|
+
User.find_by_login!(id)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
if (@user = find_user.(params[:id]))
|
8
16
|
render plain: @user
|
9
17
|
else
|
10
18
|
render plain: 'Not found', status: 404
|
@@ -15,8 +15,10 @@ case orm_module
|
|
15
15
|
when 'sequel'
|
16
16
|
require 'sequel-rails'
|
17
17
|
require 'sequel_secure_password'
|
18
|
+
require 'database_cleaner-sequel' if Rails.env.test?
|
18
19
|
when 'activerecord'
|
19
20
|
require 'active_record/railtie'
|
21
|
+
require 'database_cleaner-active_record' if Rails.env.test?
|
20
22
|
end
|
21
23
|
|
22
24
|
require 'appmap/railtie' if defined?(AppMap)
|
@@ -16,11 +16,17 @@ if [[ $? != 0 ]]; then
|
|
16
16
|
exit 1
|
17
17
|
fi
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
# Required for migrations
|
20
|
+
export ORM_MODULE=sequel
|
21
21
|
|
22
|
+
set +e
|
23
|
+
psql -h pg -U postgres -c "drop database if exists app_development"
|
24
|
+
psql -h pg -U postgres -c "drop database if exists app_test"
|
22
25
|
set -e
|
23
26
|
|
27
|
+
psql -h pg -U postgres -c "create database app_development"
|
28
|
+
psql -h pg -U postgres -c "create database app_test"
|
29
|
+
|
24
30
|
RAILS_ENV=development ./bin/rake db:migrate
|
25
31
|
RAILS_ENV=test ./bin/rake db:migrate
|
26
32
|
|
@@ -8,6 +8,12 @@ RSpec.describe Api::UsersController, type: :controller do
|
|
8
8
|
post :create, params: { login: 'alice', password: 'foobar' }
|
9
9
|
expect(response.status).to eq(201)
|
10
10
|
end
|
11
|
+
describe 'with object-style parameters' do
|
12
|
+
it 'creates a user' do
|
13
|
+
post :create, params: { user: { login: 'alice', password: 'foobar' } }
|
14
|
+
expect(response.status).to eq(201)
|
15
|
+
end
|
16
|
+
end
|
11
17
|
end
|
12
18
|
describe 'with a missing parameter' do
|
13
19
|
it 'reports error 422' do
|
@@ -25,5 +31,12 @@ RSpec.describe Api::UsersController, type: :controller do
|
|
25
31
|
users = JSON.parse(response.body)
|
26
32
|
expect(users.map { |r| r['login'] }).to include('alice')
|
27
33
|
end
|
34
|
+
describe 'with a custom header' do
|
35
|
+
it 'lists the users' do
|
36
|
+
request.headers['X-Sandwich'] = 'turkey'
|
37
|
+
get :index, params: {}
|
38
|
+
expect(response.status).to eq(200)
|
39
|
+
end
|
40
|
+
end
|
28
41
|
end
|
29
42
|
end
|
@@ -4,7 +4,7 @@ require 'rack/test'
|
|
4
4
|
RSpec.describe UsersController, type: :controller do
|
5
5
|
render_views
|
6
6
|
|
7
|
-
describe 'GET /users'
|
7
|
+
describe 'GET /users' do
|
8
8
|
before do
|
9
9
|
User.create login: 'alice'
|
10
10
|
end
|
@@ -14,7 +14,7 @@ RSpec.describe UsersController, type: :controller do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
describe 'GET /users/:login'
|
17
|
+
describe 'GET /users/:login' do
|
18
18
|
before do
|
19
19
|
User.create login: 'alice'
|
20
20
|
end
|
@@ -45,7 +45,6 @@ RSpec.configure do |config|
|
|
45
45
|
# arbitrary gems may also be filtered via:
|
46
46
|
# config.filter_gems_from_backtrace("gem name")
|
47
47
|
|
48
|
-
|
49
48
|
DatabaseCleaner.allow_remote_database_url = true
|
50
49
|
|
51
50
|
config.before(:suite) do
|
@@ -54,13 +53,8 @@ RSpec.configure do |config|
|
|
54
53
|
end
|
55
54
|
|
56
55
|
config.around :each do |example|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
DatabaseCleaner.cleaning do
|
62
|
-
example.run
|
63
|
-
end
|
64
|
-
}.call
|
56
|
+
DatabaseCleaner.cleaning do
|
57
|
+
example.run
|
58
|
+
end
|
65
59
|
end
|
66
60
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
3
|
|
4
|
-
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
5
4
|
gem 'rails', '~> 6'
|
6
5
|
|
7
6
|
gem 'haml-rails'
|
@@ -40,12 +39,14 @@ group :development, :test do
|
|
40
39
|
gem 'appmap', appmap_options
|
41
40
|
gem 'cucumber-rails', require: false
|
42
41
|
gem 'rspec-rails'
|
43
|
-
# Required for Sequel, since without ActiveRecord, the Rails transactional fixture support
|
44
|
-
# isn't activated.
|
45
|
-
gem 'database_cleaner'
|
46
42
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
47
43
|
gem 'pry-byebug'
|
48
44
|
end
|
49
45
|
|
46
|
+
group :test do
|
47
|
+
gem 'database_cleaner-active_record', require: false
|
48
|
+
gem 'database_cleaner-sequel', require: false
|
49
|
+
end
|
50
|
+
|
50
51
|
group :development do
|
51
52
|
end
|
@@ -4,7 +4,15 @@ class UsersController < ApplicationController
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def show
|
7
|
-
|
7
|
+
find_user = lambda do |id|
|
8
|
+
if User.respond_to?(:[])
|
9
|
+
User[login: id]
|
10
|
+
else
|
11
|
+
User.find_by_login!(id)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
if (@user = find_user.(params[:id]))
|
8
16
|
render plain: @user
|
9
17
|
else
|
10
18
|
render plain: 'Not found', status: 404
|
@@ -15,8 +15,10 @@ case orm_module
|
|
15
15
|
when 'sequel'
|
16
16
|
require 'sequel-rails'
|
17
17
|
require 'sequel_secure_password'
|
18
|
+
require 'database_cleaner-sequel' if Rails.env.test?
|
18
19
|
when 'activerecord'
|
19
20
|
require 'active_record/railtie'
|
21
|
+
require 'database_cleaner-active_record' if Rails.env.test?
|
20
22
|
end
|
21
23
|
|
22
24
|
require 'appmap/railtie' if defined?(AppMap)
|
@@ -16,11 +16,17 @@ if [[ $? != 0 ]]; then
|
|
16
16
|
exit 1
|
17
17
|
fi
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
# Required for migrations
|
20
|
+
export ORM_MODULE=sequel
|
21
21
|
|
22
|
+
set +e
|
23
|
+
psql -h pg -U postgres -c "drop database if exists app_development"
|
24
|
+
psql -h pg -U postgres -c "drop database if exists app_test"
|
22
25
|
set -e
|
23
26
|
|
27
|
+
psql -h pg -U postgres -c "create database app_development"
|
28
|
+
psql -h pg -U postgres -c "create database app_test"
|
29
|
+
|
24
30
|
RAILS_ENV=development ./bin/rake db:migrate
|
25
31
|
RAILS_ENV=test ./bin/rake db:migrate
|
26
32
|
|
@@ -8,6 +8,12 @@ RSpec.describe Api::UsersController, type: :controller do
|
|
8
8
|
post :create, params: { login: 'alice', password: 'foobar' }
|
9
9
|
expect(response.status).to eq(201)
|
10
10
|
end
|
11
|
+
describe 'with object-style parameters' do
|
12
|
+
it 'creates a user' do
|
13
|
+
post :create, params: { user: { login: 'alice', password: 'foobar' } }
|
14
|
+
expect(response.status).to eq(201)
|
15
|
+
end
|
16
|
+
end
|
11
17
|
end
|
12
18
|
describe 'with a missing parameter' do
|
13
19
|
it 'reports error 422' do
|
@@ -25,5 +31,12 @@ RSpec.describe Api::UsersController, type: :controller do
|
|
25
31
|
users = JSON.parse(response.body)
|
26
32
|
expect(users.map { |r| r['login'] }).to include('alice')
|
27
33
|
end
|
34
|
+
describe 'with a custom header' do
|
35
|
+
it 'lists the users' do
|
36
|
+
request.headers['X-Sandwich'] = 'turkey'
|
37
|
+
get :index, params: {}
|
38
|
+
expect(response.status).to eq(200)
|
39
|
+
end
|
40
|
+
end
|
28
41
|
end
|
29
42
|
end
|
@@ -4,7 +4,7 @@ require 'rack/test'
|
|
4
4
|
RSpec.describe UsersController, type: :controller do
|
5
5
|
render_views
|
6
6
|
|
7
|
-
describe 'GET /users'
|
7
|
+
describe 'GET /users' do
|
8
8
|
before do
|
9
9
|
User.create login: 'alice'
|
10
10
|
end
|
@@ -14,7 +14,7 @@ RSpec.describe UsersController, type: :controller do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
describe 'GET /users/:login'
|
17
|
+
describe 'GET /users/:login' do
|
18
18
|
before do
|
19
19
|
User.create login: 'alice'
|
20
20
|
end
|
@@ -45,7 +45,6 @@ RSpec.configure do |config|
|
|
45
45
|
# arbitrary gems may also be filtered via:
|
46
46
|
# config.filter_gems_from_backtrace("gem name")
|
47
47
|
|
48
|
-
|
49
48
|
DatabaseCleaner.allow_remote_database_url = true
|
50
49
|
|
51
50
|
config.before(:suite) do
|
@@ -54,13 +53,8 @@ RSpec.configure do |config|
|
|
54
53
|
end
|
55
54
|
|
56
55
|
config.around :each do |example|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
DatabaseCleaner.cleaning do
|
62
|
-
example.run
|
63
|
-
end
|
64
|
-
}.call
|
56
|
+
DatabaseCleaner.cleaning do
|
57
|
+
example.run
|
58
|
+
end
|
65
59
|
end
|
66
60
|
end
|
data/spec/hook_spec.rb
CHANGED
@@ -16,14 +16,7 @@ end
|
|
16
16
|
Psych::Visitors::YAMLTree.prepend(ShowYamlNulls)
|
17
17
|
|
18
18
|
describe 'AppMap class Hooking', docker: false do
|
19
|
-
|
20
|
-
def collect_events(tracer)
|
21
|
-
[].tap do |events|
|
22
|
-
while tracer.event?
|
23
|
-
events << tracer.next_event.to_h
|
24
|
-
end
|
25
|
-
end.map(&AppMap::Util.method(:sanitize_event))
|
26
|
-
end
|
19
|
+
include_context 'collect events'
|
27
20
|
|
28
21
|
def invoke_test_file(file, setup: nil, &block)
|
29
22
|
AppMap.configuration = nil
|
@@ -64,11 +57,144 @@ describe 'AppMap class Hooking', docker: false do
|
|
64
57
|
it 'excludes named classes and methods' do
|
65
58
|
load 'spec/fixtures/hook/exclude.rb'
|
66
59
|
package = AppMap::Config::Package.build_from_path('spec/fixtures/hook/exclude.rb')
|
67
|
-
config = AppMap::Config.new('hook_spec', [ package ], %w[ExcludeTest])
|
60
|
+
config = AppMap::Config.new('hook_spec', [ package ], exclude: %w[ExcludeTest])
|
68
61
|
AppMap.configuration = config
|
69
62
|
|
70
|
-
expect(config.never_hook?(ExcludeTest.new.method(:instance_method))).to be_truthy
|
71
|
-
expect(config.never_hook?(ExcludeTest.method(:cls_method))).to be_truthy
|
63
|
+
expect(config.never_hook?(ExcludeTest, ExcludeTest.new.method(:instance_method))).to be_truthy
|
64
|
+
expect(config.never_hook?(ExcludeTest, ExcludeTest.method(:cls_method))).to be_truthy
|
65
|
+
end
|
66
|
+
|
67
|
+
it "handles an instance method named 'call' without issues" do
|
68
|
+
events_yaml = <<~YAML
|
69
|
+
---
|
70
|
+
- :id: 1
|
71
|
+
:event: :call
|
72
|
+
:defined_class: MethodNamedCall
|
73
|
+
:method_id: call
|
74
|
+
:path: spec/fixtures/hook/method_named_call.rb
|
75
|
+
:lineno: 8
|
76
|
+
:static: false
|
77
|
+
:parameters:
|
78
|
+
- :name: :a
|
79
|
+
:class: Integer
|
80
|
+
:value: '1'
|
81
|
+
:kind: :req
|
82
|
+
- :name: :b
|
83
|
+
:class: Integer
|
84
|
+
:value: '2'
|
85
|
+
:kind: :req
|
86
|
+
- :name: :c
|
87
|
+
:class: Integer
|
88
|
+
:value: '3'
|
89
|
+
:kind: :req
|
90
|
+
- :name: :d
|
91
|
+
:class: Integer
|
92
|
+
:value: '4'
|
93
|
+
:kind: :req
|
94
|
+
- :name: :e
|
95
|
+
:class: Integer
|
96
|
+
:value: '5'
|
97
|
+
:kind: :req
|
98
|
+
:receiver:
|
99
|
+
:class: MethodNamedCall
|
100
|
+
:value: MethodNamedCall
|
101
|
+
- :id: 2
|
102
|
+
:event: :return
|
103
|
+
:parent_id: 1
|
104
|
+
:return_value:
|
105
|
+
:class: String
|
106
|
+
:value: 1 2 3 4 5
|
107
|
+
YAML
|
108
|
+
|
109
|
+
_, tracer = test_hook_behavior 'spec/fixtures/hook/method_named_call.rb', events_yaml do
|
110
|
+
expect(MethodNamedCall.new.call(1, 2, 3, 4, 5)).to eq('1 2 3 4 5')
|
111
|
+
end
|
112
|
+
class_map = AppMap.class_map(tracer.event_methods)
|
113
|
+
expect(Diffy::Diff.new(<<~CLASSMAP, YAML.dump(class_map)).to_s).to eq('')
|
114
|
+
---
|
115
|
+
- :name: spec/fixtures/hook/method_named_call.rb
|
116
|
+
:type: package
|
117
|
+
:children:
|
118
|
+
- :name: MethodNamedCall
|
119
|
+
:type: class
|
120
|
+
:children:
|
121
|
+
- :name: call
|
122
|
+
:type: function
|
123
|
+
:location: spec/fixtures/hook/method_named_call.rb:8
|
124
|
+
:static: false
|
125
|
+
CLASSMAP
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'can custom hook and label a function' do
|
129
|
+
events_yaml = <<~YAML
|
130
|
+
---
|
131
|
+
- :id: 1
|
132
|
+
:event: :call
|
133
|
+
:defined_class: CustomInstanceMethod
|
134
|
+
:method_id: say_default
|
135
|
+
:path: spec/fixtures/hook/custom_instance_method.rb
|
136
|
+
:lineno: 8
|
137
|
+
:static: false
|
138
|
+
:parameters: []
|
139
|
+
:receiver:
|
140
|
+
:class: CustomInstanceMethod
|
141
|
+
:value: CustomInstance Method fixture
|
142
|
+
- :id: 2
|
143
|
+
:event: :return
|
144
|
+
:parent_id: 1
|
145
|
+
:return_value:
|
146
|
+
:class: String
|
147
|
+
:value: default
|
148
|
+
YAML
|
149
|
+
|
150
|
+
config = AppMap::Config.load({
|
151
|
+
functions: [
|
152
|
+
{
|
153
|
+
package: 'hook_spec',
|
154
|
+
class: 'CustomInstanceMethod',
|
155
|
+
functions: [ :say_default ],
|
156
|
+
labels: ['cowsay']
|
157
|
+
}
|
158
|
+
]
|
159
|
+
}.deep_stringify_keys)
|
160
|
+
|
161
|
+
load 'spec/fixtures/hook/custom_instance_method.rb'
|
162
|
+
hook_cls = CustomInstanceMethod
|
163
|
+
method = hook_cls.instance_method(:say_default)
|
164
|
+
|
165
|
+
require 'appmap/hook/method'
|
166
|
+
package = config.lookup_package(hook_cls, method)
|
167
|
+
expect(package).to be
|
168
|
+
hook_method = AppMap::Hook::Method.new(package, hook_cls, method)
|
169
|
+
hook_method.activate
|
170
|
+
|
171
|
+
tracer = AppMap.tracing.trace
|
172
|
+
AppMap::Event.reset_id_counter
|
173
|
+
begin
|
174
|
+
expect(CustomInstanceMethod.new.say_default).to eq('default')
|
175
|
+
ensure
|
176
|
+
AppMap.tracing.delete(tracer)
|
177
|
+
end
|
178
|
+
|
179
|
+
events = collect_events(tracer).to_yaml
|
180
|
+
|
181
|
+
expect(Diffy::Diff.new(events_yaml, events).to_s).to eq('')
|
182
|
+
class_map = AppMap.class_map(tracer.event_methods)
|
183
|
+
expect(Diffy::Diff.new(<<~CLASSMAP, YAML.dump(class_map)).to_s).to eq('')
|
184
|
+
---
|
185
|
+
- :name: hook_spec
|
186
|
+
:type: package
|
187
|
+
:children:
|
188
|
+
- :name: CustomInstanceMethod
|
189
|
+
:type: class
|
190
|
+
:children:
|
191
|
+
- :name: say_default
|
192
|
+
:type: function
|
193
|
+
:location: spec/fixtures/hook/custom_instance_method.rb:8
|
194
|
+
:static: false
|
195
|
+
:labels:
|
196
|
+
- cowsay
|
197
|
+
CLASSMAP
|
72
198
|
end
|
73
199
|
|
74
200
|
it 'parses labels from comments' do
|
@@ -91,9 +217,6 @@ describe 'AppMap class Hooking', docker: false do
|
|
91
217
|
:labels:
|
92
218
|
- has-fn-label
|
93
219
|
:comment: "# @label has-fn-label\\n"
|
94
|
-
:source: |2
|
95
|
-
def fn_with_label
|
96
|
-
end
|
97
220
|
YAML
|
98
221
|
end
|
99
222
|
|
@@ -127,8 +250,8 @@ describe 'AppMap class Hooking', docker: false do
|
|
127
250
|
_, tracer = invoke_test_file 'spec/fixtures/hook/instance_method.rb' do
|
128
251
|
InstanceMethod.new.say_default
|
129
252
|
end
|
130
|
-
expect(tracer.event_methods.to_a.map(&:
|
131
|
-
expect(tracer.event_methods.to_a.map(&:
|
253
|
+
expect(tracer.event_methods.to_a.map(&:class_name)).to eq([ 'InstanceMethod' ])
|
254
|
+
expect(tracer.event_methods.to_a.map(&:name)).to eq([ InstanceMethod.public_instance_method(:say_default).name ])
|
132
255
|
end
|
133
256
|
|
134
257
|
it 'builds a class map of invoked methods' do
|
@@ -148,10 +271,6 @@ describe 'AppMap class Hooking', docker: false do
|
|
148
271
|
:type: function
|
149
272
|
:location: spec/fixtures/hook/instance_method.rb:8
|
150
273
|
:static: false
|
151
|
-
:source: |2
|
152
|
-
def say_default
|
153
|
-
'default'
|
154
|
-
end
|
155
274
|
YAML
|
156
275
|
end
|
157
276
|
|
@@ -744,8 +863,11 @@ describe 'AppMap class Hooking', docker: false do
|
|
744
863
|
_, _, events = test_hook_behavior 'spec/fixtures/hook/compare.rb', nil do
|
745
864
|
expect(Compare.compare('string', 'string')).to be_truthy
|
746
865
|
end
|
866
|
+
|
747
867
|
secure_compare_event = YAML.load(events).find { |evt| evt[:defined_class] == 'ActiveSupport::SecurityUtils' }
|
868
|
+
expect(secure_compare_event).to be_truthy
|
748
869
|
secure_compare_event.delete(:lineno)
|
870
|
+
secure_compare_event.delete(:path)
|
749
871
|
|
750
872
|
expect(Diffy::Diff.new(<<~YAML, secure_compare_event.to_yaml).to_s).to eq('')
|
751
873
|
---
|
@@ -753,7 +875,6 @@ describe 'AppMap class Hooking', docker: false do
|
|
753
875
|
:event: :call
|
754
876
|
:defined_class: ActiveSupport::SecurityUtils
|
755
877
|
:method_id: secure_compare
|
756
|
-
:path: lib/active_support/security_utils.rb
|
757
878
|
:static: true
|
758
879
|
:parameters:
|
759
880
|
- :name: :a
|
@@ -837,7 +958,7 @@ describe 'AppMap class Hooking', docker: false do
|
|
837
958
|
entry = cm[1][:children][0][:children][0][:children][0]
|
838
959
|
# Sanity check, make sure we got the right one
|
839
960
|
expect(entry[:name]).to eq('secure_compare')
|
840
|
-
expect(entry[:labels]).to eq(%w[
|
961
|
+
expect(entry[:labels]).to eq(%w[crypto.secure_compare])
|
841
962
|
end
|
842
963
|
end
|
843
964
|
|