appmap 0.38.1 → 0.39.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -1
- data/.travis.yml +0 -7
- data/CHANGELOG.md +4 -0
- data/README.md +10 -4
- data/lib/appmap/rails/request_handler.rb +12 -3
- data/lib/appmap/version.rb +2 -2
- data/spec/abstract_controller_base_spec.rb +116 -86
- data/spec/fixtures/rails5_users_app/app/controllers/users_controller.rb +8 -0
- data/spec/fixtures/rails5_users_app/config/routes.rb +1 -1
- data/spec/fixtures/rails5_users_app/spec/controllers/users_controller_spec.rb +11 -0
- data/spec/fixtures/rails6_users_app/app/controllers/users_controller.rb +8 -0
- data/spec/fixtures/rails6_users_app/config/routes.rb +1 -1
- data/spec/fixtures/rails6_users_app/spec/controllers/users_controller_spec.rb +11 -0
- data/spec/rails_spec_helper.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f48fa55666d8310e8a24c268a7b72c1748c22fe0aa9b884000b1e83a703dbac
|
4
|
+
data.tar.gz: 5d82f1809e549bc71659048a9dce037eafe6e261c63c09d127bbd6b1f43d5b3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5077fd340fac2478af5361e518c777b8ef76ffeb358aee18f6f507a6314b687ea02a40721b32fe0d2886d279e76ed3d249f9ebfd7b850fb05a1d5d2168b62c6c
|
7
|
+
data.tar.gz: 97b2c5306bd7b07d9f853b883d1ece37f6160683ae0eec5c5d6afe9e6909311468fb2def4e2f70c439ad18a56f9262e77569c7385b2d34dca28e02119302b57d
|
data/.rubocop.yml
CHANGED
@@ -4,6 +4,9 @@ AllCops:
|
|
4
4
|
Layout/CaseIndentation:
|
5
5
|
EnforcedStyle: end
|
6
6
|
|
7
|
+
Layout/FirstArgumentIndentation:
|
8
|
+
EnforcedStyle: consistent
|
9
|
+
|
7
10
|
Layout/SpaceInsideArrayLiteralBrackets:
|
8
11
|
Enabled: false
|
9
12
|
|
@@ -17,13 +20,14 @@ Layout/LineLength:
|
|
17
20
|
Metrics/BlockLength:
|
18
21
|
ExcludedMethods:
|
19
22
|
- it
|
23
|
+
- context
|
20
24
|
|
21
25
|
Style/MultilineBlockChain:
|
22
26
|
Enabled: false
|
23
27
|
|
24
28
|
Style/NumericPredicate:
|
25
29
|
Enabled: false
|
26
|
-
|
30
|
+
|
27
31
|
Style/AndOr:
|
28
32
|
Enabled: false
|
29
33
|
|
data/.travis.yml
CHANGED
@@ -28,13 +28,6 @@ jobs:
|
|
28
28
|
script:
|
29
29
|
- bundle exec rake build:base:2.6
|
30
30
|
|
31
|
-
- stage: fixtures
|
32
|
-
script:
|
33
|
-
- bundle exec rake build:fixtures:2.5:all
|
34
|
-
- stage: fixtures
|
35
|
-
script:
|
36
|
-
- bundle exec rake build:fixtures:2.6:all
|
37
|
-
|
38
31
|
- stage: spec
|
39
32
|
script:
|
40
33
|
- bundle exec rake spec:2.5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -171,16 +171,22 @@ Note that `test_helper.rb` in a Rails project typically loads the application's
|
|
171
171
|
require_relative '../config/environment'
|
172
172
|
```
|
173
173
|
|
174
|
-
and `appmap/
|
174
|
+
and `appmap/minitest` must be required before this:
|
175
175
|
|
176
176
|
```ruby
|
177
|
-
require 'appmap/
|
177
|
+
require 'appmap/minitest'
|
178
178
|
require_relative '../config/environment'
|
179
179
|
```
|
180
180
|
|
181
|
-
2) Run
|
181
|
+
2) Run your tests as you normally would with the environment variable `APPMAP=true`. For example:
|
182
182
|
|
183
|
-
```
|
183
|
+
```
|
184
|
+
$ APPMAP=true bundle exec rake
|
185
|
+
```
|
186
|
+
|
187
|
+
or
|
188
|
+
|
189
|
+
```
|
184
190
|
$ APPMAP=true bundle exec -Ilib -Itest test/*
|
185
191
|
```
|
186
192
|
|
@@ -7,12 +7,13 @@ module AppMap
|
|
7
7
|
module Rails
|
8
8
|
module RequestHandler
|
9
9
|
class HTTPServerRequest < AppMap::Event::MethodEvent
|
10
|
-
attr_accessor :request_method, :path_info, :params
|
10
|
+
attr_accessor :normalized_path_info, :request_method, :path_info, :params
|
11
11
|
|
12
12
|
def initialize(request)
|
13
13
|
super AppMap::Event.next_id_counter, :call, Thread.current.object_id
|
14
14
|
|
15
15
|
@request_method = request.request_method
|
16
|
+
@normalized_path_info = normalized_path request
|
16
17
|
@path_info = request.path_info.split('?')[0]
|
17
18
|
# ActionDispatch::Http::ParameterFilter is deprecated
|
18
19
|
parameter_filter_cls = \
|
@@ -28,8 +29,9 @@ module AppMap
|
|
28
29
|
super.tap do |h|
|
29
30
|
h[:http_server_request] = {
|
30
31
|
request_method: request_method,
|
31
|
-
path_info: path_info
|
32
|
-
|
32
|
+
path_info: path_info,
|
33
|
+
normalized_path_info: normalized_path_info
|
34
|
+
}.compact
|
33
35
|
|
34
36
|
h[:message] = params.keys.map do |key|
|
35
37
|
val = params[key]
|
@@ -42,6 +44,13 @@ module AppMap
|
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def normalized_path(request)
|
51
|
+
route = ::Rails.application.routes.router.enum_for(:recognize, request).first
|
52
|
+
route.first.path.spec.to_s if route
|
53
|
+
end
|
45
54
|
end
|
46
55
|
|
47
56
|
class HTTPServerResponse < AppMap::Event::MethodReturnIgnoreValue
|
data/lib/appmap/version.rb
CHANGED
@@ -1,120 +1,150 @@
|
|
1
1
|
require 'rails_spec_helper'
|
2
2
|
|
3
3
|
describe 'AbstractControllerBase' do
|
4
|
-
|
5
|
-
|
4
|
+
%w[5 6].each do |rails_major_version| # rubocop:disable Metrics/BlockLength
|
5
|
+
context "in Rails #{rails_major_version}" do
|
6
|
+
include_context 'Rails app pg database', "spec/fixtures/rails#{rails_major_version}_users_app"
|
6
7
|
def run_spec(spec_name)
|
7
|
-
|
8
|
+
FileUtils.rm_rf tmpdir
|
9
|
+
FileUtils.mkdir_p tmpdir
|
10
|
+
cmd = <<~CMD.gsub "\n", ' '
|
11
|
+
docker-compose run --rm -e APPMAP=true
|
12
|
+
-v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec #{spec_name}
|
13
|
+
CMD
|
8
14
|
run_cmd cmd, chdir: fixture_dir
|
9
15
|
end
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
FileUtils.mkdir_p tmpdir
|
14
|
-
run_spec spec_name
|
17
|
+
def tmpdir
|
18
|
+
'tmp/spec/AbstractControllerBase'
|
15
19
|
end
|
16
20
|
|
17
|
-
let(:
|
21
|
+
let(:appmap) { JSON.parse File.read File.join tmpdir, 'appmap/rspec', appmap_json_file }
|
22
|
+
let(:events) { appmap['events'] }
|
18
23
|
|
19
24
|
describe 'testing with rspec' do
|
20
|
-
let(:spec_name) { 'spec/controllers/users_controller_api_spec.rb:8' }
|
21
|
-
let(:appmap_json_file) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }
|
22
|
-
|
23
25
|
describe 'creating a user' do
|
26
|
+
before(:all) { run_spec 'spec/controllers/users_controller_api_spec.rb:8' }
|
27
|
+
let(:appmap_json_file) do
|
28
|
+
'Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json'
|
29
|
+
end
|
30
|
+
|
24
31
|
it 'inventory file is printed' do
|
25
32
|
expect(File).to exist(File.join(tmpdir, 'appmap/rspec/Inventory.appmap.json'))
|
26
33
|
end
|
27
34
|
|
28
35
|
it 'message fields are recorded in the appmap' do
|
29
|
-
expect(
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
SERVER_RESPONSE
|
36
|
+
expect(events).to include(
|
37
|
+
hash_including(
|
38
|
+
'http_server_request' => hash_including(
|
39
|
+
'request_method' => 'POST',
|
40
|
+
'path_info' => '/api/users'
|
41
|
+
),
|
42
|
+
'message' => include(
|
43
|
+
hash_including(
|
44
|
+
'name' => 'login',
|
45
|
+
'class' => 'String',
|
46
|
+
'value' => 'alice',
|
47
|
+
'object_id' => Integer
|
48
|
+
),
|
49
|
+
hash_including(
|
50
|
+
'name' => 'password',
|
51
|
+
'class' => 'String',
|
52
|
+
'value' => '[FILTERED]',
|
53
|
+
'object_id' => Integer
|
54
|
+
)
|
55
|
+
)
|
56
|
+
),
|
57
|
+
hash_including(
|
58
|
+
'http_server_response' => {
|
59
|
+
'status' => 201,
|
60
|
+
'mime_type' => 'application/json; charset=utf-8'
|
61
|
+
}
|
62
|
+
)
|
63
|
+
)
|
58
64
|
end
|
59
65
|
|
60
66
|
it 'properly captures method parameters in the appmap' do
|
61
|
-
expect(
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
receiver:
|
79
|
-
CREATE_CALL
|
67
|
+
expect(events).to include hash_including(
|
68
|
+
'event' => 'call',
|
69
|
+
'thread_id' => Integer,
|
70
|
+
'defined_class' => 'Api::UsersController',
|
71
|
+
'method_id' => 'build_user',
|
72
|
+
'path' => 'app/controllers/api/users_controller.rb',
|
73
|
+
'lineno' => 23,
|
74
|
+
'static' => false,
|
75
|
+
'parameters' => include(
|
76
|
+
'name' => 'params',
|
77
|
+
'class' => 'ActiveSupport::HashWithIndifferentAccess',
|
78
|
+
'object_id' => Integer,
|
79
|
+
'value' => '{"login"=>"alice"}',
|
80
|
+
'kind' => 'req'
|
81
|
+
),
|
82
|
+
'receiver' => anything
|
83
|
+
)
|
80
84
|
end
|
81
85
|
|
82
86
|
it 'returns a minimal event' do
|
83
|
-
expect(
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
+
expect(events).to include hash_including(
|
88
|
+
'event' => 'return',
|
89
|
+
'return_value' => Hash,
|
90
|
+
'id' => Integer,
|
91
|
+
'thread_id' => Integer,
|
92
|
+
'parent_id' => Integer,
|
93
|
+
'elapsed' => Numeric
|
94
|
+
)
|
87
95
|
end
|
88
96
|
end
|
89
97
|
|
90
|
-
describe '
|
91
|
-
|
92
|
-
let(:appmap_json_file)
|
93
|
-
|
94
|
-
|
95
|
-
appmap = JSON.parse(File.read(appmap_json_file)).to_yaml
|
98
|
+
describe 'showing a user' do
|
99
|
+
before(:all) { run_spec 'spec/controllers/users_controller_spec.rb:22' }
|
100
|
+
let(:appmap_json_file) do
|
101
|
+
'UsersController_GET_users_login_shows_the_user.appmap.json'
|
102
|
+
end
|
96
103
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
104
|
+
it 'records the normalized path info' do
|
105
|
+
expect(events).to include(
|
106
|
+
hash_including(
|
107
|
+
'http_server_request' => {
|
108
|
+
'request_method' => 'GET',
|
109
|
+
'path_info' => '/users/alice',
|
110
|
+
'normalized_path_info' => '/users/:id(.:format)'
|
111
|
+
}
|
112
|
+
)
|
113
|
+
)
|
114
|
+
end
|
115
|
+
end
|
106
116
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
117
|
+
describe 'listing users' do
|
118
|
+
before(:all) { run_spec 'spec/controllers/users_controller_spec.rb:11' }
|
119
|
+
let(:appmap_json_file) { 'UsersController_GET_users_lists_the_users.appmap.json' }
|
120
|
+
|
121
|
+
it 'records and labels view rendering' do
|
122
|
+
expect(events).to include hash_including(
|
123
|
+
'event' => 'call',
|
124
|
+
'thread_id' => Numeric,
|
125
|
+
'defined_class' => 'ActionView::Renderer',
|
126
|
+
'method_id' => 'render',
|
127
|
+
'path' => String,
|
128
|
+
'lineno' => Integer,
|
129
|
+
'static' => false
|
130
|
+
)
|
131
|
+
|
132
|
+
expect(appmap['classMap']).to include hash_including(
|
133
|
+
'name' => 'action_view',
|
134
|
+
'children' => include(hash_including(
|
135
|
+
'name' => 'ActionView',
|
136
|
+
'children' => include(hash_including(
|
137
|
+
'name' => 'Renderer',
|
138
|
+
'children' => include(hash_including(
|
139
|
+
'name' => 'render',
|
140
|
+
'labels' => ['view']
|
141
|
+
))
|
142
|
+
))
|
143
|
+
))
|
144
|
+
)
|
111
145
|
end
|
112
146
|
end
|
113
147
|
end
|
114
148
|
end
|
115
149
|
end
|
116
|
-
|
117
|
-
%w[5 6].each do |version|
|
118
|
-
it_behaves_like 'rails version', version
|
119
|
-
end
|
120
150
|
end
|
@@ -13,4 +13,15 @@ RSpec.describe UsersController, type: :controller do
|
|
13
13
|
expect(response).to be_ok
|
14
14
|
end
|
15
15
|
end
|
16
|
+
|
17
|
+
describe 'GET /users/:login', feature: 'Show a user' do
|
18
|
+
before do
|
19
|
+
User.create login: 'alice'
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'shows the user' do
|
23
|
+
get :show, params: { id: 'alice' }
|
24
|
+
expect(response).to be_ok
|
25
|
+
end
|
26
|
+
end
|
16
27
|
end
|
@@ -13,4 +13,15 @@ RSpec.describe UsersController, type: :controller do
|
|
13
13
|
expect(response).to be_ok
|
14
14
|
end
|
15
15
|
end
|
16
|
+
|
17
|
+
describe 'GET /users/:login', feature: 'Show a user' do
|
18
|
+
before do
|
19
|
+
User.create login: 'alice'
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'shows the user' do
|
23
|
+
get :show, params: { id: 'alice' }
|
24
|
+
expect(response).to be_ok
|
25
|
+
end
|
26
|
+
end
|
16
27
|
end
|
data/spec/rails_spec_helper.rb
CHANGED
@@ -30,7 +30,7 @@ def run_cmd(*cmd, &failed)
|
|
30
30
|
end
|
31
31
|
|
32
32
|
shared_context 'Rails app pg database' do |fixture_dir|
|
33
|
-
|
33
|
+
define_method(:fixture_dir) { fixture_dir }
|
34
34
|
|
35
35
|
before(:all) do
|
36
36
|
print_pg_logs = lambda do
|
@@ -40,7 +40,7 @@ shared_context 'Rails app pg database' do |fixture_dir|
|
|
40
40
|
puts logs
|
41
41
|
end
|
42
42
|
|
43
|
-
Dir.chdir fixture_dir do
|
43
|
+
Dir.chdir fixture_dir do
|
44
44
|
run_cmd 'docker-compose down -v'
|
45
45
|
cmd = 'docker-compose up -d pg'
|
46
46
|
run_cmd cmd
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.39.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Gilpin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|