appmap 0.35.0 → 0.37.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +1 -1
  3. data/.gitignore +2 -1
  4. data/.rubocop.yml +10 -0
  5. data/CHANGELOG.md +22 -0
  6. data/README.md +11 -8
  7. data/Rakefile +3 -2
  8. data/appmap.gemspec +2 -1
  9. data/appmap.yml +1 -7
  10. data/lib/appmap.rb +2 -2
  11. data/lib/appmap/class_map.rb +20 -6
  12. data/lib/appmap/config.rb +53 -23
  13. data/lib/appmap/event.rb +21 -6
  14. data/lib/appmap/hook.rb +1 -1
  15. data/lib/appmap/rails/request_handler.rb +8 -1
  16. data/lib/appmap/railtie.rb +1 -1
  17. data/lib/appmap/rspec.rb +1 -1
  18. data/lib/appmap/version.rb +2 -2
  19. data/spec/abstract_controller4_base_spec.rb +27 -28
  20. data/spec/abstract_controller_base_spec.rb +43 -39
  21. data/spec/class_map_spec.rb +36 -0
  22. data/spec/fixtures/hook/exception_method.rb +44 -0
  23. data/spec/fixtures/hook/instance_method.rb +4 -0
  24. data/spec/fixtures/{rails_users_app → rails5_users_app}/.dockerignore +0 -0
  25. data/spec/fixtures/{rails_users_app → rails5_users_app}/.gitignore +0 -0
  26. data/spec/fixtures/{rails_users_app → rails5_users_app}/.rspec +0 -0
  27. data/{.ruby-version → spec/fixtures/rails5_users_app/.ruby-version} +0 -0
  28. data/spec/fixtures/{rails_users_app → rails5_users_app}/Dockerfile +0 -0
  29. data/spec/fixtures/{rails_users_app → rails5_users_app}/Dockerfile.pg +0 -0
  30. data/spec/fixtures/rails5_users_app/Gemfile +51 -0
  31. data/spec/fixtures/{rails_users_app → rails5_users_app}/Rakefile +0 -0
  32. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/api/users_controller.rb +0 -0
  33. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/application_controller.rb +0 -0
  34. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/concerns/.keep +0 -0
  35. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/health_controller.rb +0 -0
  36. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/users_controller.rb +0 -0
  37. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/models/activerecord/user.rb +0 -0
  38. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/models/concerns/.keep +0 -0
  39. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/models/sequel/user.rb +0 -0
  40. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/views/layouts/application.html.haml +0 -0
  41. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/views/users/index.html.haml +0 -0
  42. data/spec/fixtures/{rails_users_app → rails5_users_app}/appmap.yml +1 -1
  43. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/appmap +0 -0
  44. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/byebug +0 -0
  45. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/gli +0 -0
  46. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/htmldiff +0 -0
  47. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/ldiff +0 -0
  48. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/nokogiri +0 -0
  49. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rackup +0 -0
  50. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rails +0 -0
  51. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rake +0 -0
  52. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rspec +0 -0
  53. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/ruby-parse +0 -0
  54. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/ruby-rewrite +0 -0
  55. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/sequel +0 -0
  56. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/setup +0 -0
  57. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/sprockets +0 -0
  58. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/thor +0 -0
  59. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/update +0 -0
  60. data/spec/fixtures/{rails_users_app → rails5_users_app}/config.ru +0 -0
  61. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/application.rb +0 -0
  62. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/boot.rb +0 -0
  63. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/credentials.yml.enc +0 -0
  64. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/database.yml +0 -0
  65. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environment.rb +0 -0
  66. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environments/development.rb +0 -0
  67. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environments/production.rb +0 -0
  68. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environments/test.rb +0 -0
  69. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/application_controller_renderer.rb +0 -0
  70. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/backtrace_silencers.rb +0 -0
  71. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/cors.rb +0 -0
  72. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/filter_parameter_logging.rb +0 -0
  73. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/inflections.rb +0 -0
  74. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/mime_types.rb +0 -0
  75. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/record_button.rb +0 -0
  76. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/wrap_parameters.rb +0 -0
  77. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/locales/en.yml +0 -0
  78. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/routes.rb +0 -0
  79. data/spec/fixtures/{rails_users_app → rails5_users_app}/create_app +0 -0
  80. data/spec/fixtures/{rails_users_app → rails5_users_app}/db/migrate/20190728211408_create_users.rb +0 -0
  81. data/spec/fixtures/{rails_users_app → rails5_users_app}/db/schema.rb +0 -0
  82. data/spec/fixtures/{rails_users_app → rails5_users_app}/docker-compose.yml +0 -0
  83. data/spec/fixtures/{rails_users_app → rails5_users_app}/features/api_users.feature +0 -0
  84. data/spec/fixtures/{rails_users_app → rails5_users_app}/features/support/env.rb +0 -0
  85. data/spec/fixtures/{rails_users_app → rails5_users_app}/features/support/hooks.rb +0 -0
  86. data/spec/fixtures/{rails_users_app → rails5_users_app}/features/support/steps.rb +0 -0
  87. data/spec/fixtures/{rails_users_app → rails5_users_app}/lib/tasks/.keep +0 -0
  88. data/spec/fixtures/{rails_users_app → rails5_users_app}/log/.keep +0 -0
  89. data/spec/fixtures/{rails_users_app → rails5_users_app}/public/robots.txt +0 -0
  90. data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/controllers/users_controller_api_spec.rb +0 -0
  91. data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/models/user_spec.rb +0 -0
  92. data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/rails_helper.rb +0 -0
  93. data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/spec_helper.rb +0 -0
  94. data/spec/fixtures/{rails_users_app → rails5_users_app}/users_app/.gitignore +0 -0
  95. data/spec/fixtures/rails6_users_app/.dockerignore +1 -0
  96. data/spec/fixtures/rails6_users_app/.gitignore +39 -0
  97. data/spec/fixtures/rails6_users_app/.rspec +1 -0
  98. data/spec/fixtures/{rails_users_app → rails6_users_app}/.ruby-version +0 -0
  99. data/spec/fixtures/rails6_users_app/Dockerfile +29 -0
  100. data/spec/fixtures/rails6_users_app/Dockerfile.pg +3 -0
  101. data/spec/fixtures/{rails_users_app → rails6_users_app}/Gemfile +0 -0
  102. data/spec/fixtures/rails6_users_app/Rakefile +6 -0
  103. data/spec/fixtures/rails6_users_app/app/controllers/api/users_controller.rb +27 -0
  104. data/spec/fixtures/rails6_users_app/app/controllers/application_controller.rb +2 -0
  105. data/spec/fixtures/rails6_users_app/app/controllers/concerns/.keep +0 -0
  106. data/spec/fixtures/rails6_users_app/app/controllers/health_controller.rb +5 -0
  107. data/spec/fixtures/rails6_users_app/app/controllers/users_controller.rb +5 -0
  108. data/spec/fixtures/rails6_users_app/app/models/activerecord/user.rb +18 -0
  109. data/spec/fixtures/rails6_users_app/app/models/concerns/.keep +0 -0
  110. data/spec/fixtures/rails6_users_app/app/models/sequel/user.rb +25 -0
  111. data/spec/fixtures/rails6_users_app/app/views/layouts/application.html.haml +7 -0
  112. data/spec/fixtures/rails6_users_app/app/views/users/index.html.haml +7 -0
  113. data/spec/fixtures/rails6_users_app/appmap.yml +3 -0
  114. data/spec/fixtures/rails6_users_app/bin/appmap +29 -0
  115. data/spec/fixtures/rails6_users_app/bin/byebug +29 -0
  116. data/spec/fixtures/rails6_users_app/bin/gli +29 -0
  117. data/spec/fixtures/rails6_users_app/bin/htmldiff +29 -0
  118. data/spec/fixtures/rails6_users_app/bin/ldiff +29 -0
  119. data/spec/fixtures/rails6_users_app/bin/nokogiri +29 -0
  120. data/spec/fixtures/rails6_users_app/bin/rackup +29 -0
  121. data/spec/fixtures/rails6_users_app/bin/rails +4 -0
  122. data/spec/fixtures/rails6_users_app/bin/rake +29 -0
  123. data/spec/fixtures/rails6_users_app/bin/rspec +29 -0
  124. data/spec/fixtures/rails6_users_app/bin/ruby-parse +29 -0
  125. data/spec/fixtures/rails6_users_app/bin/ruby-rewrite +29 -0
  126. data/spec/fixtures/rails6_users_app/bin/sequel +29 -0
  127. data/spec/fixtures/rails6_users_app/bin/setup +25 -0
  128. data/spec/fixtures/rails6_users_app/bin/sprockets +29 -0
  129. data/spec/fixtures/rails6_users_app/bin/thor +29 -0
  130. data/spec/fixtures/rails6_users_app/bin/update +25 -0
  131. data/spec/fixtures/rails6_users_app/config.ru +5 -0
  132. data/spec/fixtures/rails6_users_app/config/application.rb +51 -0
  133. data/spec/fixtures/rails6_users_app/config/boot.rb +3 -0
  134. data/spec/fixtures/rails6_users_app/config/credentials.yml.enc +1 -0
  135. data/spec/fixtures/rails6_users_app/config/database.yml +18 -0
  136. data/spec/fixtures/rails6_users_app/config/environment.rb +5 -0
  137. data/spec/fixtures/rails6_users_app/config/environments/development.rb +40 -0
  138. data/spec/fixtures/rails6_users_app/config/environments/production.rb +68 -0
  139. data/spec/fixtures/rails6_users_app/config/environments/test.rb +36 -0
  140. data/spec/fixtures/rails6_users_app/config/initializers/application_controller_renderer.rb +8 -0
  141. data/spec/fixtures/rails6_users_app/config/initializers/backtrace_silencers.rb +7 -0
  142. data/spec/fixtures/rails6_users_app/config/initializers/cors.rb +16 -0
  143. data/spec/fixtures/rails6_users_app/config/initializers/filter_parameter_logging.rb +4 -0
  144. data/spec/fixtures/rails6_users_app/config/initializers/inflections.rb +16 -0
  145. data/spec/fixtures/rails6_users_app/config/initializers/mime_types.rb +4 -0
  146. data/spec/fixtures/rails6_users_app/config/initializers/record_button.rb +3 -0
  147. data/spec/fixtures/rails6_users_app/config/initializers/wrap_parameters.rb +9 -0
  148. data/spec/fixtures/rails6_users_app/config/locales/en.yml +33 -0
  149. data/spec/fixtures/rails6_users_app/config/routes.rb +11 -0
  150. data/spec/fixtures/rails6_users_app/create_app +27 -0
  151. data/spec/fixtures/rails6_users_app/db/migrate/20190728211408_create_users.rb +9 -0
  152. data/spec/fixtures/rails6_users_app/db/schema.rb +23 -0
  153. data/spec/fixtures/rails6_users_app/docker-compose.yml +28 -0
  154. data/spec/fixtures/rails6_users_app/features/api_users.feature +13 -0
  155. data/spec/fixtures/rails6_users_app/features/support/env.rb +4 -0
  156. data/spec/fixtures/rails6_users_app/features/support/hooks.rb +11 -0
  157. data/spec/fixtures/rails6_users_app/features/support/steps.rb +18 -0
  158. data/spec/fixtures/rails6_users_app/lib/tasks/.keep +0 -0
  159. data/spec/fixtures/rails6_users_app/log/.keep +0 -0
  160. data/spec/fixtures/rails6_users_app/public/robots.txt +1 -0
  161. data/spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb +29 -0
  162. data/spec/fixtures/rails6_users_app/spec/models/user_spec.rb +39 -0
  163. data/spec/fixtures/rails6_users_app/spec/rails_helper.rb +66 -0
  164. data/spec/fixtures/rails6_users_app/spec/spec_helper.rb +96 -0
  165. data/spec/fixtures/rails6_users_app/users_app/.gitignore +20 -0
  166. data/spec/hook_spec.rb +196 -11
  167. data/spec/rails_spec_helper.rb +5 -5
  168. data/spec/railtie_spec.rb +31 -32
  169. data/spec/record_sql_rails4_pg_spec.rb +47 -48
  170. data/spec/record_sql_rails_pg_spec.rb +62 -63
  171. data/spec/remote_recording_spec.rb +90 -89
  172. data/spec/rspec_feature_metadata_spec.rb +17 -18
  173. data/test/cli_test.rb +0 -10
  174. data/test/expectations/openssl_test_key_sign1.json +55 -0
  175. data/test/expectations/openssl_test_key_sign2.json +58 -0
  176. data/test/fixtures/gem_test/Gemfile +6 -0
  177. data/test/fixtures/gem_test/appmap.yml +3 -0
  178. data/test/fixtures/gem_test/test/to_param_test.rb +14 -0
  179. data/test/gem_test.rb +34 -0
  180. data/test/minitest_test.rb +2 -2
  181. data/test/openssl_test.rb +10 -165
  182. metadata +171 -80
@@ -3,30 +3,29 @@
3
3
  require 'rails_spec_helper'
4
4
 
5
5
  describe 'RSpec feature and feature group metadata' do
6
- before(:all) { @fixture_dir = 'spec/fixtures/rails_users_app' }
7
- include_examples 'Rails app pg database'
8
-
9
- around(:each) do |example|
10
- FileUtils.rm_rf tmpdir
11
- FileUtils.mkdir_p tmpdir
12
- cmd = "docker-compose run --rm -e APPMAP=true -v #{File.absolute_path(tmpdir).shellescape}:/app/tmp app ./bin/rspec spec/models/user_spec.rb"
13
- run_cmd cmd, chdir: @fixture_dir
6
+ include_examples 'Rails app pg database', 'spec/fixtures/rails5_users_app' do
7
+ around(:each) do |example|
8
+ FileUtils.rm_rf tmpdir
9
+ FileUtils.mkdir_p tmpdir
10
+ cmd = "docker-compose run --rm -e APPMAP=true -v #{File.absolute_path(tmpdir).shellescape}:/app/tmp app ./bin/rspec spec/models/user_spec.rb"
11
+ run_cmd cmd, chdir: fixture_dir
14
12
 
15
- example.run
16
- end
13
+ example.run
14
+ end
17
15
 
18
- let(:tmpdir) { 'tmp/spec/RSpec feature and feature group metadata' }
19
- let(:appmap_json) { File.join(tmpdir, %(appmap/rspec/User_creation_creates_charles.appmap.json)) }
16
+ let(:tmpdir) { 'tmp/spec/RSpec feature and feature group metadata' }
17
+ let(:appmap_json) { File.join(tmpdir, %(appmap/rspec/User_creation_creates_charles.appmap.json)) }
20
18
 
21
- describe do
22
- it 'are recorded in the appmap' do
23
- expect(File).to exist(appmap_json)
24
- appmap = JSON.parse(File.read(appmap_json)).to_yaml
19
+ describe do
20
+ it 'are recorded in the appmap' do
21
+ expect(File).to exist(appmap_json)
22
+ appmap = JSON.parse(File.read(appmap_json)).to_yaml
25
23
 
26
- expect(appmap).to include(<<-METADATA.strip)
24
+ expect(appmap).to include(<<-METADATA.strip)
27
25
  feature: Create a user
28
26
  feature_group: User
29
- METADATA
27
+ METADATA
28
+ end
30
29
  end
31
30
  end
32
31
  end
@@ -56,12 +56,10 @@ class CLITest < Minitest::Test
56
56
  Class frequency:
57
57
  ----------------
58
58
  1 Main
59
- 1 IO
60
59
 
61
60
  Method frequency:
62
61
  ----------------
63
62
  1 Main.say_hello
64
- 1 IO#write
65
63
  OUTPUT
66
64
  end
67
65
 
@@ -82,20 +80,12 @@ class CLITest < Minitest::Test
82
80
  {
83
81
  "name": "Main",
84
82
  "count": 1
85
- },
86
- {
87
- "name": "IO",
88
- "count": 1
89
83
  }
90
84
  ],
91
85
  "method_frequency": [
92
86
  {
93
87
  "name": "Main.say_hello",
94
88
  "count": 1
95
- },
96
- {
97
- "name": "IO#write",
98
- "count": 1
99
89
  }
100
90
  ]
101
91
  }
@@ -0,0 +1,55 @@
1
+ [
2
+ {
3
+ "name": "lib",
4
+ "type": "package",
5
+ "children": [
6
+ {
7
+ "name": "Example",
8
+ "type": "class",
9
+ "children": [
10
+ {
11
+ "name": "sign",
12
+ "type": "function",
13
+ "location": "lib/openssl_key_sign.rb:10",
14
+ "static": true,
15
+ "source": " def Example.sign\n key = OpenSSL::PKey::RSA.new 2048\n\n document = 'the document'\n\n digest = OpenSSL::Digest::SHA256.new\n key.sign digest, document\n end\n"
16
+ }
17
+ ]
18
+ }
19
+ ]
20
+ },
21
+ {
22
+ "name": "openssl",
23
+ "type": "package",
24
+ "children": [
25
+ {
26
+ "name": "OpenSSL",
27
+ "type": "class",
28
+ "children": [
29
+ {
30
+ "name": "PKey",
31
+ "type": "class",
32
+ "children": [
33
+ {
34
+ "name": "PKey",
35
+ "type": "class",
36
+ "children": [
37
+ {
38
+ "name": "sign",
39
+ "type": "function",
40
+ "location": "OpenSSL::PKey::PKey#sign",
41
+ "static": false,
42
+ "labels": [
43
+ "security",
44
+ "crypto"
45
+ ]
46
+ }
47
+ ]
48
+ }
49
+ ]
50
+ }
51
+ ]
52
+ }
53
+ ]
54
+ }
55
+ ]
@@ -0,0 +1,58 @@
1
+ [
2
+ {
3
+ "id": 1,
4
+ "event": "call",
5
+ "defined_class": "Example",
6
+ "method_id": "sign",
7
+ "path": "lib/openssl_key_sign.rb",
8
+ "lineno": 10,
9
+ "static": true,
10
+ "parameters": [
11
+
12
+ ],
13
+ "receiver": {
14
+ "class": "Module"
15
+ }
16
+ },
17
+ {
18
+ "id": 2,
19
+ "event": "call",
20
+ "defined_class": "OpenSSL::PKey::PKey",
21
+ "method_id": "sign",
22
+ "path": "OpenSSL::PKey::PKey#sign",
23
+ "static": false,
24
+ "parameters": [
25
+ {
26
+ "name": "arg",
27
+ "class": "OpenSSL::Digest::SHA256",
28
+ "value": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
29
+ "kind": "req"
30
+ },
31
+ {
32
+ "name": "arg",
33
+ "class": "String",
34
+ "value": "the document",
35
+ "kind": "req"
36
+ }
37
+ ],
38
+ "receiver": {
39
+ "class": "OpenSSL::PKey::RSA"
40
+ }
41
+ },
42
+ {
43
+ "id": 3,
44
+ "event": "return",
45
+ "parent_id": 2,
46
+ "return_value": {
47
+ "class": "String"
48
+ }
49
+ },
50
+ {
51
+ "id": 4,
52
+ "event": "return",
53
+ "parent_id": 1,
54
+ "return_value": {
55
+ "class": "String"
56
+ }
57
+ }
58
+ ]
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'appmap', git: 'applandinc/appmap-ruby', branch: `git rev-parse --abbrev-ref HEAD`.strip
4
+ gem 'activesupport'
5
+ gem 'byebug'
6
+ gem 'minitest'
@@ -0,0 +1,3 @@
1
+ name: gem_test
2
+ packages:
3
+ - gem: activesupport
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'appmap/minitest'
5
+ require 'minitest/autorun'
6
+ require 'active_support'
7
+ require 'active_support/core_ext'
8
+
9
+ class ToParamTest < ::Minitest::Test
10
+ def test_to_param
11
+ # record use of a core extension
12
+ assert_equal 'my+id', 'my+id'.to_param
13
+ end
14
+ end
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'test_helper'
5
+ require 'English'
6
+
7
+ class MinitestTest < Minitest::Test
8
+ def perform_gem_test(test_name)
9
+ Bundler.with_clean_env do
10
+ Dir.chdir 'test/fixtures/gem_test' do
11
+ FileUtils.rm_rf 'tmp'
12
+ system 'bundle config --local local.appmap ../../..'
13
+ system 'bundle'
14
+ system({ 'APPMAP' => 'true' }, %(bundle exec ruby -Ilib -Itest test/#{test_name}_test.rb))
15
+
16
+ yield
17
+ end
18
+ end
19
+ end
20
+
21
+ def test_record_gem
22
+ perform_gem_test 'to_param' do
23
+ appmap_file = 'tmp/appmap/minitest/To_param_to_param.appmap.json'
24
+ appmap = JSON.parse(File.read(appmap_file))
25
+ events = appmap['events']
26
+ assert_equal 2, events.size
27
+ assert_equal 'call', events.first['event']
28
+ assert_equal 'to_param', events.first['method_id']
29
+ assert_equal "#{Gem.loaded_specs['activesupport'].gem_dir}/lib/active_support/core_ext/object/to_query.rb", events.first['path']
30
+ assert_equal 'return', events.second['event']
31
+ assert_equal 1, events.second['parent_id']
32
+ end
33
+ end
34
+ end
@@ -5,7 +5,7 @@ require 'test_helper'
5
5
  require 'English'
6
6
 
7
7
  class MinitestTest < Minitest::Test
8
- def perform_test(test_name)
8
+ def perform_minitest_test(test_name)
9
9
  Bundler.with_clean_env do
10
10
  Dir.chdir 'test/fixtures/minitest_recorder' do
11
11
  FileUtils.rm_rf 'tmp'
@@ -19,7 +19,7 @@ class MinitestTest < Minitest::Test
19
19
  end
20
20
 
21
21
  def test_hello
22
- perform_test 'hello' do
22
+ perform_minitest_test 'hello' do
23
23
  appmap_file = 'tmp/appmap/minitest/Hello_hello.appmap.json'
24
24
 
25
25
  assert File.file?(appmap_file), 'appmap output file does not exist'
@@ -11,13 +11,17 @@ class OpenSSLTest < Minitest::Test
11
11
  FileUtils.rm_rf 'tmp'
12
12
  system 'bundle config --local local.appmap ../../..'
13
13
  system 'bundle'
14
- system({ 'APPMAP' => 'true', 'DEBUG' => 'true' }, %(bundle exec ruby lib/openssl_#{test_name}.rb))
14
+ system({ 'APPMAP' => 'true' }, %(bundle exec ruby lib/openssl_#{test_name}.rb))
15
15
 
16
16
  yield
17
17
  end
18
18
  end
19
19
  end
20
20
 
21
+ def expectation(name)
22
+ File.read File.join __dir__, 'expectations', name
23
+ end
24
+
21
25
  def test_key_sign
22
26
  perform_test 'key_sign' do
23
27
  appmap_file = 'appmap.json'
@@ -26,83 +30,7 @@ class OpenSSLTest < Minitest::Test
26
30
  appmap = JSON.parse(File.read(appmap_file))
27
31
  assert_equal AppMap::APPMAP_FORMAT_VERSION, appmap['version']
28
32
  assert_equal [ { 'recorder' => 'lib/openssl_key_sign.rb' } ], appmap['metadata']
29
- assert_equal JSON.parse(<<~JSON), appmap['classMap']
30
- [
31
- {
32
- "name": "lib",
33
- "type": "package",
34
- "children": [
35
- {
36
- "name": "Example",
37
- "type": "class",
38
- "children": [
39
- {
40
- "name": "sign",
41
- "type": "function",
42
- "location": "lib/openssl_key_sign.rb:10",
43
- "static": true
44
- }
45
- ]
46
- }
47
- ]
48
- },
49
- {
50
- "name": "openssl",
51
- "type": "package",
52
- "children": [
53
- {
54
- "name": "OpenSSL",
55
- "type": "class",
56
- "children": [
57
- {
58
- "name": "PKey",
59
- "type": "class",
60
- "children": [
61
- {
62
- "name": "PKey",
63
- "type": "class",
64
- "children": [
65
- {
66
- "name": "sign",
67
- "type": "function",
68
- "location": "OpenSSL::PKey::PKey#sign",
69
- "static": false,
70
- "labels": [
71
- "security",
72
- "crypto"
73
- ]
74
- }
75
- ]
76
- }
77
- ]
78
- }
79
- ]
80
- }
81
- ]
82
- },
83
- {
84
- "name": "io",
85
- "type": "package",
86
- "children": [
87
- {
88
- "name": "IO",
89
- "type": "class",
90
- "children": [
91
- {
92
- "name": "write",
93
- "type": "function",
94
- "location": "IO#write",
95
- "static": false,
96
- "labels": [
97
- "io"
98
- ]
99
- }
100
- ]
101
- }
102
- ]
103
- }
104
- ]
105
- JSON
33
+ assert_equal JSON.parse(expectation('openssl_test_key_sign1.json')), appmap['classMap']
106
34
  sanitized_events = appmap['events'].map(&:deep_symbolize_keys).map(&AppMap::Util.method(:sanitize_event)).map do |event|
107
35
  delete_value = ->(obj) { (obj || {}).delete(:value) }
108
36
  delete_value.call(event[:receiver])
@@ -110,93 +38,10 @@ class OpenSSLTest < Minitest::Test
110
38
  event
111
39
  end
112
40
 
113
- diff = Diffy::Diff.new(<<~JSON.strip, JSON.pretty_generate(sanitized_events).strip)
114
- [
115
- {
116
- "id": 1,
117
- "event": "call",
118
- "defined_class": "Example",
119
- "method_id": "sign",
120
- "path": "lib/openssl_key_sign.rb",
121
- "lineno": 10,
122
- "static": true,
123
- "parameters": [
124
-
125
- ],
126
- "receiver": {
127
- "class": "Module"
128
- }
129
- },
130
- {
131
- "id": 2,
132
- "event": "call",
133
- "defined_class": "OpenSSL::PKey::PKey",
134
- "method_id": "sign",
135
- "path": "OpenSSL::PKey::PKey#sign",
136
- "static": false,
137
- "parameters": [
138
- {
139
- "name": "arg",
140
- "class": "OpenSSL::Digest::SHA256",
141
- "value": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
142
- "kind": "req"
143
- },
144
- {
145
- "name": "arg",
146
- "class": "String",
147
- "value": "the document",
148
- "kind": "req"
149
- }
150
- ],
151
- "receiver": {
152
- "class": "OpenSSL::PKey::RSA"
153
- }
154
- },
155
- {
156
- "id": 3,
157
- "event": "return",
158
- "parent_id": 2,
159
- "return_value": {
160
- "class": "String"
161
- }
162
- },
163
- {
164
- "id": 4,
165
- "event": "return",
166
- "parent_id": 1,
167
- "return_value": {
168
- "class": "String"
169
- }
170
- },
171
- {
172
- "id": 5,
173
- "event": "call",
174
- "defined_class": "IO",
175
- "method_id": "write",
176
- "path": "IO#write",
177
- "static": false,
178
- "parameters": [
179
- {
180
- "name": "arg",
181
- "class": "String",
182
- "value": "Computed signature",
183
- "kind": "rest"
184
- }
185
- ],
186
- "receiver": {
187
- "class": "IO"
188
- }
189
- },
190
- {
191
- "id": 6,
192
- "event": "return",
193
- "parent_id": 5,
194
- "return_value": {
195
- "class": "Integer"
196
- }
197
- }
198
- ]
199
- JSON
41
+ diff = Diffy::Diff.new(
42
+ expectation('openssl_test_key_sign2.json').strip,
43
+ JSON.pretty_generate(sanitized_events).strip
44
+ )
200
45
  assert_equal '', diff.to_s
201
46
  end
202
47
  end