appmap 0.83.4 → 0.83.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (357) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +16 -0
  3. data/CHANGELOG.md +7 -0
  4. data/appmap.gemspec +1 -1
  5. data/lib/appmap/version.rb +1 -1
  6. metadata +3 -353
  7. data/spec/class_map_spec.rb +0 -28
  8. data/spec/config_spec.rb +0 -155
  9. data/spec/depends/api_spec.rb +0 -196
  10. data/spec/depends/spec_helper.rb +0 -18
  11. data/spec/display_string_spec.rb +0 -40
  12. data/spec/fixtures/config/incomplete_config.yml +0 -1
  13. data/spec/fixtures/config/invalid_config.yml +0 -2
  14. data/spec/fixtures/config/invalid_yaml_config.yml +0 -3
  15. data/spec/fixtures/config/maximal_config.yml +0 -14
  16. data/spec/fixtures/config/missing_path_or_gem.yml +0 -3
  17. data/spec/fixtures/config/valid_config.yml +0 -3
  18. data/spec/fixtures/database.yml +0 -11
  19. data/spec/fixtures/depends/.gitignore +0 -2
  20. data/spec/fixtures/depends/app/controllers/api/api_keys_controller.rb +0 -2
  21. data/spec/fixtures/depends/app/controllers/organizations_controller.rb +0 -2
  22. data/spec/fixtures/depends/app/models/api_key.rb +0 -2
  23. data/spec/fixtures/depends/app/models/configuration.rb +0 -2
  24. data/spec/fixtures/depends/app/models/show.rb +0 -2
  25. data/spec/fixtures/depends/app/models/user.rb +0 -2
  26. data/spec/fixtures/depends/spec/actual_rspec_test.rb +0 -7
  27. data/spec/fixtures/depends/spec/api_spec.rb +0 -2
  28. data/spec/fixtures/depends/spec/user_spec.rb +0 -2
  29. data/spec/fixtures/depends/test/actual_minitest_test.rb +0 -5
  30. data/spec/fixtures/hook/.gitignore +0 -2
  31. data/spec/fixtures/hook/app/controllers/api/api_keys_controller.rb +0 -1
  32. data/spec/fixtures/hook/app/controllers/organizations_controller.rb +0 -1
  33. data/spec/fixtures/hook/app/models/api_key.rb +0 -1
  34. data/spec/fixtures/hook/app/models/configuration.rb +0 -1
  35. data/spec/fixtures/hook/app/models/show.rb +0 -1
  36. data/spec/fixtures/hook/app/models/user.rb +0 -1
  37. data/spec/fixtures/hook/attr_accessor.rb +0 -5
  38. data/spec/fixtures/hook/compare.rb +0 -7
  39. data/spec/fixtures/hook/constructor.rb +0 -7
  40. data/spec/fixtures/hook/custom_instance_method.rb +0 -11
  41. data/spec/fixtures/hook/exception_method.rb +0 -61
  42. data/spec/fixtures/hook/exclude.rb +0 -15
  43. data/spec/fixtures/hook/instance_method.rb +0 -31
  44. data/spec/fixtures/hook/kwargs.rb +0 -11
  45. data/spec/fixtures/hook/labels.rb +0 -6
  46. data/spec/fixtures/hook/method_named_call.rb +0 -11
  47. data/spec/fixtures/hook/pkg_a/a.rb +0 -7
  48. data/spec/fixtures/hook/prepended_override.rb +0 -14
  49. data/spec/fixtures/hook/protected_method.rb +0 -29
  50. data/spec/fixtures/hook/report_parameters.rb +0 -8
  51. data/spec/fixtures/hook/singleton_method.rb +0 -63
  52. data/spec/fixtures/hook/spec/api_spec.rb +0 -1
  53. data/spec/fixtures/hook/spec/user_spec.rb +0 -1
  54. data/spec/fixtures/hook/sub_packages.rb +0 -7
  55. data/spec/fixtures/rack_users_app/.dockerignore +0 -2
  56. data/spec/fixtures/rack_users_app/.gitignore +0 -2
  57. data/spec/fixtures/rack_users_app/Gemfile +0 -10
  58. data/spec/fixtures/rack_users_app/appmap.yml +0 -3
  59. data/spec/fixtures/rack_users_app/config.ru +0 -2
  60. data/spec/fixtures/rack_users_app/lib/app.rb +0 -36
  61. data/spec/fixtures/rails5_users_app/.dockerignore +0 -1
  62. data/spec/fixtures/rails5_users_app/.gitignore +0 -39
  63. data/spec/fixtures/rails5_users_app/.rspec +0 -1
  64. data/spec/fixtures/rails5_users_app/.ruby-version +0 -1
  65. data/spec/fixtures/rails5_users_app/Gemfile +0 -54
  66. data/spec/fixtures/rails5_users_app/Rakefile +0 -6
  67. data/spec/fixtures/rails5_users_app/app/controllers/api/users_controller.rb +0 -29
  68. data/spec/fixtures/rails5_users_app/app/controllers/application_controller.rb +0 -2
  69. data/spec/fixtures/rails5_users_app/app/controllers/concerns/.keep +0 -0
  70. data/spec/fixtures/rails5_users_app/app/controllers/health_controller.rb +0 -5
  71. data/spec/fixtures/rails5_users_app/app/controllers/users_controller.rb +0 -21
  72. data/spec/fixtures/rails5_users_app/app/models/activerecord/user.rb +0 -18
  73. data/spec/fixtures/rails5_users_app/app/models/concerns/.keep +0 -0
  74. data/spec/fixtures/rails5_users_app/app/models/sequel/user.rb +0 -25
  75. data/spec/fixtures/rails5_users_app/app/views/layouts/application.html.haml +0 -7
  76. data/spec/fixtures/rails5_users_app/app/views/users/index.html.haml +0 -7
  77. data/spec/fixtures/rails5_users_app/appmap.yml +0 -11
  78. data/spec/fixtures/rails5_users_app/bin/appmap +0 -29
  79. data/spec/fixtures/rails5_users_app/bin/byebug +0 -29
  80. data/spec/fixtures/rails5_users_app/bin/gli +0 -29
  81. data/spec/fixtures/rails5_users_app/bin/htmldiff +0 -29
  82. data/spec/fixtures/rails5_users_app/bin/ldiff +0 -29
  83. data/spec/fixtures/rails5_users_app/bin/nokogiri +0 -29
  84. data/spec/fixtures/rails5_users_app/bin/rackup +0 -29
  85. data/spec/fixtures/rails5_users_app/bin/rails +0 -4
  86. data/spec/fixtures/rails5_users_app/bin/rake +0 -29
  87. data/spec/fixtures/rails5_users_app/bin/rspec +0 -29
  88. data/spec/fixtures/rails5_users_app/bin/ruby-parse +0 -29
  89. data/spec/fixtures/rails5_users_app/bin/ruby-rewrite +0 -29
  90. data/spec/fixtures/rails5_users_app/bin/sequel +0 -29
  91. data/spec/fixtures/rails5_users_app/bin/setup +0 -25
  92. data/spec/fixtures/rails5_users_app/bin/sprockets +0 -29
  93. data/spec/fixtures/rails5_users_app/bin/thor +0 -29
  94. data/spec/fixtures/rails5_users_app/bin/update +0 -25
  95. data/spec/fixtures/rails5_users_app/config/application.rb +0 -45
  96. data/spec/fixtures/rails5_users_app/config/boot.rb +0 -3
  97. data/spec/fixtures/rails5_users_app/config/credentials.yml.enc +0 -1
  98. data/spec/fixtures/rails5_users_app/config/database.yml +0 -1
  99. data/spec/fixtures/rails5_users_app/config/environment.rb +0 -5
  100. data/spec/fixtures/rails5_users_app/config/environments/development.rb +0 -40
  101. data/spec/fixtures/rails5_users_app/config/environments/production.rb +0 -68
  102. data/spec/fixtures/rails5_users_app/config/environments/test.rb +0 -39
  103. data/spec/fixtures/rails5_users_app/config/initializers/application_controller_renderer.rb +0 -8
  104. data/spec/fixtures/rails5_users_app/config/initializers/backtrace_silencers.rb +0 -7
  105. data/spec/fixtures/rails5_users_app/config/initializers/cors.rb +0 -16
  106. data/spec/fixtures/rails5_users_app/config/initializers/filter_parameter_logging.rb +0 -4
  107. data/spec/fixtures/rails5_users_app/config/initializers/inflections.rb +0 -16
  108. data/spec/fixtures/rails5_users_app/config/initializers/mime_types.rb +0 -4
  109. data/spec/fixtures/rails5_users_app/config/initializers/wrap_parameters.rb +0 -9
  110. data/spec/fixtures/rails5_users_app/config/locales/en.yml +0 -33
  111. data/spec/fixtures/rails5_users_app/config/routes.rb +0 -11
  112. data/spec/fixtures/rails5_users_app/config.ru +0 -5
  113. data/spec/fixtures/rails5_users_app/db/migrate/20190728211408_create_users.rb +0 -9
  114. data/spec/fixtures/rails5_users_app/db/schema.rb +0 -23
  115. data/spec/fixtures/rails5_users_app/features/api_users.feature +0 -13
  116. data/spec/fixtures/rails5_users_app/features/support/env.rb +0 -4
  117. data/spec/fixtures/rails5_users_app/features/support/hooks.rb +0 -11
  118. data/spec/fixtures/rails5_users_app/features/support/steps.rb +0 -18
  119. data/spec/fixtures/rails5_users_app/lib/tasks/.keep +0 -0
  120. data/spec/fixtures/rails5_users_app/log/.keep +0 -0
  121. data/spec/fixtures/rails5_users_app/public/robots.txt +0 -1
  122. data/spec/fixtures/rails5_users_app/spec/controllers/users_controller_api_spec.rb +0 -42
  123. data/spec/fixtures/rails5_users_app/spec/controllers/users_controller_spec.rb +0 -27
  124. data/spec/fixtures/rails5_users_app/spec/models/user_spec.rb +0 -29
  125. data/spec/fixtures/rails5_users_app/spec/rails_helper.rb +0 -57
  126. data/spec/fixtures/rails5_users_app/spec/spec_helper.rb +0 -96
  127. data/spec/fixtures/rails5_users_app/users_app/.gitignore +0 -20
  128. data/spec/fixtures/rails6_users_app/.dockerignore +0 -1
  129. data/spec/fixtures/rails6_users_app/.gitignore +0 -39
  130. data/spec/fixtures/rails6_users_app/.rspec +0 -1
  131. data/spec/fixtures/rails6_users_app/Gemfile +0 -28
  132. data/spec/fixtures/rails6_users_app/Rakefile +0 -6
  133. data/spec/fixtures/rails6_users_app/app/controllers/api/users_controller.rb +0 -28
  134. data/spec/fixtures/rails6_users_app/app/controllers/application_controller.rb +0 -2
  135. data/spec/fixtures/rails6_users_app/app/controllers/concerns/.keep +0 -0
  136. data/spec/fixtures/rails6_users_app/app/controllers/health_controller.rb +0 -5
  137. data/spec/fixtures/rails6_users_app/app/controllers/users_controller.rb +0 -21
  138. data/spec/fixtures/rails6_users_app/app/models/activerecord/user.rb +0 -18
  139. data/spec/fixtures/rails6_users_app/app/models/concerns/.keep +0 -0
  140. data/spec/fixtures/rails6_users_app/app/models/sequel/user.rb +0 -25
  141. data/spec/fixtures/rails6_users_app/app/views/layouts/application.html.haml +0 -7
  142. data/spec/fixtures/rails6_users_app/app/views/users/index.html.haml +0 -7
  143. data/spec/fixtures/rails6_users_app/appmap.yml +0 -14
  144. data/spec/fixtures/rails6_users_app/bin/appmap +0 -29
  145. data/spec/fixtures/rails6_users_app/bin/byebug +0 -29
  146. data/spec/fixtures/rails6_users_app/bin/gli +0 -29
  147. data/spec/fixtures/rails6_users_app/bin/htmldiff +0 -29
  148. data/spec/fixtures/rails6_users_app/bin/ldiff +0 -29
  149. data/spec/fixtures/rails6_users_app/bin/nokogiri +0 -29
  150. data/spec/fixtures/rails6_users_app/bin/rackup +0 -29
  151. data/spec/fixtures/rails6_users_app/bin/rails +0 -4
  152. data/spec/fixtures/rails6_users_app/bin/rake +0 -29
  153. data/spec/fixtures/rails6_users_app/bin/rspec +0 -29
  154. data/spec/fixtures/rails6_users_app/bin/ruby-parse +0 -29
  155. data/spec/fixtures/rails6_users_app/bin/ruby-rewrite +0 -29
  156. data/spec/fixtures/rails6_users_app/bin/sequel +0 -29
  157. data/spec/fixtures/rails6_users_app/bin/setup +0 -25
  158. data/spec/fixtures/rails6_users_app/bin/sprockets +0 -29
  159. data/spec/fixtures/rails6_users_app/bin/thor +0 -29
  160. data/spec/fixtures/rails6_users_app/bin/update +0 -25
  161. data/spec/fixtures/rails6_users_app/config/application.rb +0 -45
  162. data/spec/fixtures/rails6_users_app/config/boot.rb +0 -3
  163. data/spec/fixtures/rails6_users_app/config/credentials.yml.enc +0 -1
  164. data/spec/fixtures/rails6_users_app/config/database.yml +0 -1
  165. data/spec/fixtures/rails6_users_app/config/environment.rb +0 -5
  166. data/spec/fixtures/rails6_users_app/config/environments/development.rb +0 -40
  167. data/spec/fixtures/rails6_users_app/config/environments/production.rb +0 -68
  168. data/spec/fixtures/rails6_users_app/config/environments/test.rb +0 -39
  169. data/spec/fixtures/rails6_users_app/config/initializers/application_controller_renderer.rb +0 -8
  170. data/spec/fixtures/rails6_users_app/config/initializers/backtrace_silencers.rb +0 -7
  171. data/spec/fixtures/rails6_users_app/config/initializers/cors.rb +0 -16
  172. data/spec/fixtures/rails6_users_app/config/initializers/filter_parameter_logging.rb +0 -4
  173. data/spec/fixtures/rails6_users_app/config/initializers/inflections.rb +0 -16
  174. data/spec/fixtures/rails6_users_app/config/initializers/mime_types.rb +0 -4
  175. data/spec/fixtures/rails6_users_app/config/initializers/wrap_parameters.rb +0 -9
  176. data/spec/fixtures/rails6_users_app/config/locales/en.yml +0 -33
  177. data/spec/fixtures/rails6_users_app/config/routes.rb +0 -11
  178. data/spec/fixtures/rails6_users_app/config.ru +0 -5
  179. data/spec/fixtures/rails6_users_app/db/migrate/20190728211408_create_users.rb +0 -9
  180. data/spec/fixtures/rails6_users_app/db/schema.rb +0 -23
  181. data/spec/fixtures/rails6_users_app/features/api_users.feature +0 -13
  182. data/spec/fixtures/rails6_users_app/features/support/env.rb +0 -4
  183. data/spec/fixtures/rails6_users_app/features/support/hooks.rb +0 -11
  184. data/spec/fixtures/rails6_users_app/features/support/steps.rb +0 -18
  185. data/spec/fixtures/rails6_users_app/lib/tasks/.keep +0 -0
  186. data/spec/fixtures/rails6_users_app/lib/tasks/appmap.rake +0 -23
  187. data/spec/fixtures/rails6_users_app/log/.keep +0 -0
  188. data/spec/fixtures/rails6_users_app/package.json +0 -8
  189. data/spec/fixtures/rails6_users_app/public/robots.txt +0 -1
  190. data/spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb +0 -42
  191. data/spec/fixtures/rails6_users_app/spec/controllers/users_controller_spec.rb +0 -27
  192. data/spec/fixtures/rails6_users_app/spec/models/user_spec.rb +0 -29
  193. data/spec/fixtures/rails6_users_app/spec/rails_helper.rb +0 -57
  194. data/spec/fixtures/rails6_users_app/spec/spec_helper.rb +0 -96
  195. data/spec/fixtures/rails6_users_app/test/controllers/functional_calc_test.rb +0 -10
  196. data/spec/fixtures/rails6_users_app/test/integration/integration_calc_test.rb +0 -12
  197. data/spec/fixtures/rails6_users_app/users_app/.gitignore +0 -20
  198. data/spec/fixtures/rails6_users_app/yarn.lock +0 -2020
  199. data/spec/fixtures/rails7_users_app/.dockerignore +0 -1
  200. data/spec/fixtures/rails7_users_app/.gitattributes +0 -7
  201. data/spec/fixtures/rails7_users_app/.gitignore +0 -31
  202. data/spec/fixtures/rails7_users_app/.rspec +0 -1
  203. data/spec/fixtures/rails7_users_app/Gemfile +0 -75
  204. data/spec/fixtures/rails7_users_app/README.md +0 -24
  205. data/spec/fixtures/rails7_users_app/Rakefile +0 -6
  206. data/spec/fixtures/rails7_users_app/app/assets/config/manifest.js +0 -4
  207. data/spec/fixtures/rails7_users_app/app/assets/images/.keep +0 -0
  208. data/spec/fixtures/rails7_users_app/app/assets/stylesheets/application.css +0 -15
  209. data/spec/fixtures/rails7_users_app/app/channels/application_cable/channel.rb +0 -4
  210. data/spec/fixtures/rails7_users_app/app/channels/application_cable/connection.rb +0 -4
  211. data/spec/fixtures/rails7_users_app/app/controllers/application_controller.rb +0 -2
  212. data/spec/fixtures/rails7_users_app/app/controllers/concerns/.keep +0 -0
  213. data/spec/fixtures/rails7_users_app/app/helpers/application_helper.rb +0 -2
  214. data/spec/fixtures/rails7_users_app/app/javascript/application.js +0 -3
  215. data/spec/fixtures/rails7_users_app/app/javascript/controllers/application.js +0 -9
  216. data/spec/fixtures/rails7_users_app/app/javascript/controllers/hello_controller.js +0 -7
  217. data/spec/fixtures/rails7_users_app/app/javascript/controllers/index.js +0 -11
  218. data/spec/fixtures/rails7_users_app/app/jobs/application_job.rb +0 -7
  219. data/spec/fixtures/rails7_users_app/app/mailers/application_mailer.rb +0 -4
  220. data/spec/fixtures/rails7_users_app/app/models/application_record.rb +0 -3
  221. data/spec/fixtures/rails7_users_app/app/models/concerns/.keep +0 -0
  222. data/spec/fixtures/rails7_users_app/app/models/instance.rb +0 -7
  223. data/spec/fixtures/rails7_users_app/app/models/instructor.rb +0 -7
  224. data/spec/fixtures/rails7_users_app/app/views/layouts/application.html.erb +0 -16
  225. data/spec/fixtures/rails7_users_app/app/views/layouts/mailer.html.erb +0 -13
  226. data/spec/fixtures/rails7_users_app/app/views/layouts/mailer.text.erb +0 -1
  227. data/spec/fixtures/rails7_users_app/appmap.yml +0 -3
  228. data/spec/fixtures/rails7_users_app/bin/bundle +0 -114
  229. data/spec/fixtures/rails7_users_app/bin/importmap +0 -4
  230. data/spec/fixtures/rails7_users_app/bin/rails +0 -4
  231. data/spec/fixtures/rails7_users_app/bin/rake +0 -4
  232. data/spec/fixtures/rails7_users_app/bin/setup +0 -33
  233. data/spec/fixtures/rails7_users_app/config/application.rb +0 -22
  234. data/spec/fixtures/rails7_users_app/config/boot.rb +0 -4
  235. data/spec/fixtures/rails7_users_app/config/cable.yml +0 -10
  236. data/spec/fixtures/rails7_users_app/config/credentials.yml.enc +0 -1
  237. data/spec/fixtures/rails7_users_app/config/database.yml +0 -1
  238. data/spec/fixtures/rails7_users_app/config/environment.rb +0 -5
  239. data/spec/fixtures/rails7_users_app/config/environments/development.rb +0 -70
  240. data/spec/fixtures/rails7_users_app/config/environments/production.rb +0 -93
  241. data/spec/fixtures/rails7_users_app/config/environments/test.rb +0 -60
  242. data/spec/fixtures/rails7_users_app/config/importmap.rb +0 -7
  243. data/spec/fixtures/rails7_users_app/config/initializers/assets.rb +0 -12
  244. data/spec/fixtures/rails7_users_app/config/initializers/content_security_policy.rb +0 -26
  245. data/spec/fixtures/rails7_users_app/config/initializers/filter_parameter_logging.rb +0 -8
  246. data/spec/fixtures/rails7_users_app/config/initializers/inflections.rb +0 -16
  247. data/spec/fixtures/rails7_users_app/config/initializers/permissions_policy.rb +0 -11
  248. data/spec/fixtures/rails7_users_app/config/locales/en.yml +0 -33
  249. data/spec/fixtures/rails7_users_app/config/puma.rb +0 -43
  250. data/spec/fixtures/rails7_users_app/config/routes.rb +0 -6
  251. data/spec/fixtures/rails7_users_app/config/storage.yml +0 -34
  252. data/spec/fixtures/rails7_users_app/config.ru +0 -6
  253. data/spec/fixtures/rails7_users_app/db/migrate/20220328093141_create_instances.rb +0 -8
  254. data/spec/fixtures/rails7_users_app/db/migrate/20220328093154_create_instructors.rb +0 -8
  255. data/spec/fixtures/rails7_users_app/db/schema.rb +0 -27
  256. data/spec/fixtures/rails7_users_app/db/seeds.rb +0 -7
  257. data/spec/fixtures/rails7_users_app/lib/assets/.keep +0 -0
  258. data/spec/fixtures/rails7_users_app/lib/tasks/.keep +0 -0
  259. data/spec/fixtures/rails7_users_app/log/.keep +0 -0
  260. data/spec/fixtures/rails7_users_app/public/404.html +0 -67
  261. data/spec/fixtures/rails7_users_app/public/422.html +0 -67
  262. data/spec/fixtures/rails7_users_app/public/500.html +0 -66
  263. data/spec/fixtures/rails7_users_app/public/apple-touch-icon-precomposed.png +0 -0
  264. data/spec/fixtures/rails7_users_app/public/apple-touch-icon.png +0 -0
  265. data/spec/fixtures/rails7_users_app/public/favicon.ico +0 -0
  266. data/spec/fixtures/rails7_users_app/public/robots.txt +0 -1
  267. data/spec/fixtures/rails7_users_app/storage/.keep +0 -0
  268. data/spec/fixtures/rails7_users_app/test/application_system_test_case.rb +0 -5
  269. data/spec/fixtures/rails7_users_app/test/channels/application_cable/connection_test.rb +0 -11
  270. data/spec/fixtures/rails7_users_app/test/controllers/.keep +0 -0
  271. data/spec/fixtures/rails7_users_app/test/fixtures/files/.keep +0 -0
  272. data/spec/fixtures/rails7_users_app/test/fixtures/instances.yml +0 -11
  273. data/spec/fixtures/rails7_users_app/test/fixtures/instructors.yml +0 -11
  274. data/spec/fixtures/rails7_users_app/test/helpers/.keep +0 -0
  275. data/spec/fixtures/rails7_users_app/test/integration/.keep +0 -0
  276. data/spec/fixtures/rails7_users_app/test/mailers/.keep +0 -0
  277. data/spec/fixtures/rails7_users_app/test/models/.keep +0 -0
  278. data/spec/fixtures/rails7_users_app/test/models/instance_test.rb +0 -6
  279. data/spec/fixtures/rails7_users_app/test/models/instructor_test.rb +0 -7
  280. data/spec/fixtures/rails7_users_app/test/system/.keep +0 -0
  281. data/spec/fixtures/rails7_users_app/test/test_helper.rb +0 -13
  282. data/spec/handler/class_with_eval.rb +0 -13
  283. data/spec/handler/eval_spec.rb +0 -73
  284. data/spec/hook_spec.rb +0 -1216
  285. data/spec/open_spec.rb +0 -19
  286. data/spec/rails_recording_spec.rb +0 -281
  287. data/spec/rails_spec_helper.rb +0 -107
  288. data/spec/rails_test_spec.rb +0 -35
  289. data/spec/railtie_spec.rb +0 -25
  290. data/spec/record_net_http_spec.rb +0 -161
  291. data/spec/record_sql_rails_pg_spec.rb +0 -59
  292. data/spec/remote_recording_spec.rb +0 -108
  293. data/spec/service/config_analyzer_spec.rb +0 -102
  294. data/spec/service/integration_test_path_finder_spec.rb +0 -24
  295. data/spec/service/validator/violation_spec.rb +0 -68
  296. data/spec/spec_helper.rb +0 -37
  297. data/spec/swagger/swagger_spec.rb +0 -85
  298. data/spec/util_spec.rb +0 -38
  299. data/test/agent_setup_init_test.rb +0 -39
  300. data/test/agent_setup_status_test.rb +0 -84
  301. data/test/agent_setup_validate_test.rb +0 -102
  302. data/test/bundle_vendor_test.rb +0 -35
  303. data/test/cucumber_test.rb +0 -72
  304. data/test/expectations/openssl_test_key_sign1.json +0 -53
  305. data/test/expectations/openssl_test_key_sign2-3.1.json +0 -53
  306. data/test/expectations/openssl_test_key_sign2.json +0 -58
  307. data/test/fixtures/bundle_vendor_app/Gemfile +0 -8
  308. data/test/fixtures/bundle_vendor_app/appmap.yml +0 -4
  309. data/test/fixtures/bundle_vendor_app/cli.rb +0 -54
  310. data/test/fixtures/cli_record_test/appmap.yml +0 -3
  311. data/test/fixtures/cli_record_test/lib/cli_record_test/main.rb +0 -9
  312. data/test/fixtures/cucumber4_recorder/Gemfile +0 -5
  313. data/test/fixtures/cucumber4_recorder/appmap.yml +0 -3
  314. data/test/fixtures/cucumber4_recorder/features/say_hello.feature +0 -5
  315. data/test/fixtures/cucumber4_recorder/features/support/env.rb +0 -5
  316. data/test/fixtures/cucumber4_recorder/features/support/hooks.rb +0 -11
  317. data/test/fixtures/cucumber4_recorder/features/support/steps.rb +0 -9
  318. data/test/fixtures/cucumber4_recorder/lib/hello.rb +0 -7
  319. data/test/fixtures/cucumber_recorder/Gemfile +0 -5
  320. data/test/fixtures/cucumber_recorder/appmap.yml +0 -3
  321. data/test/fixtures/cucumber_recorder/features/say_hello.feature +0 -5
  322. data/test/fixtures/cucumber_recorder/features/support/env.rb +0 -5
  323. data/test/fixtures/cucumber_recorder/features/support/hooks.rb +0 -11
  324. data/test/fixtures/cucumber_recorder/features/support/steps.rb +0 -9
  325. data/test/fixtures/cucumber_recorder/lib/hello.rb +0 -7
  326. data/test/fixtures/gem_test/Gemfile +0 -7
  327. data/test/fixtures/gem_test/appmap.yml +0 -3
  328. data/test/fixtures/gem_test/test/parser_test.rb +0 -12
  329. data/test/fixtures/minitest_recorder/Gemfile +0 -5
  330. data/test/fixtures/minitest_recorder/appmap.yml +0 -3
  331. data/test/fixtures/minitest_recorder/lib/hello.rb +0 -5
  332. data/test/fixtures/minitest_recorder/test/hello_test.rb +0 -12
  333. data/test/fixtures/mocha_mock_app/Gemfile +0 -5
  334. data/test/fixtures/mocha_mock_app/appmap.yml +0 -5
  335. data/test/fixtures/mocha_mock_app/lib/sheep.rb +0 -5
  336. data/test/fixtures/mocha_mock_app/test/sheep_test.rb +0 -18
  337. data/test/fixtures/openssl_recorder/Gemfile +0 -3
  338. data/test/fixtures/openssl_recorder/appmap.yml +0 -3
  339. data/test/fixtures/openssl_recorder/lib/openssl_cert_sign.rb +0 -94
  340. data/test/fixtures/openssl_recorder/lib/openssl_encrypt.rb +0 -34
  341. data/test/fixtures/openssl_recorder/lib/openssl_key_sign.rb +0 -28
  342. data/test/fixtures/process_recorder/appmap.yml +0 -3
  343. data/test/fixtures/process_recorder/hello.rb +0 -9
  344. data/test/fixtures/rspec_recorder/Gemfile +0 -5
  345. data/test/fixtures/rspec_recorder/appmap.yml +0 -3
  346. data/test/fixtures/rspec_recorder/lib/hello.rb +0 -5
  347. data/test/fixtures/rspec_recorder/spec/decorated_hello_spec.rb +0 -21
  348. data/test/fixtures/rspec_recorder/spec/labeled_hello_spec.rb +0 -9
  349. data/test/fixtures/rspec_recorder/spec/plain_hello_spec.rb +0 -9
  350. data/test/gem_test.rb +0 -35
  351. data/test/inspect_cli_test.rb +0 -12
  352. data/test/minitest_test.rb +0 -37
  353. data/test/mock_compatibility_test.rb +0 -45
  354. data/test/openssl_test.rb +0 -54
  355. data/test/record_process_test.rb +0 -35
  356. data/test/rspec_test.rb +0 -63
  357. data/test/test_helper.rb +0 -8
data/spec/hook_spec.rb DELETED
@@ -1,1216 +0,0 @@
1
- # coding: utf-8
2
- # frozen_string_literal: true
3
-
4
- require 'rails_spec_helper'
5
- require 'appmap/hook'
6
- require 'appmap/event'
7
- require 'diffy'
8
-
9
- # Show nulls as the literal +null+, rather than just leaving the field
10
- # empty. This make some of the expected YAML below easier to
11
- # understand.
12
- module ShowYamlNulls
13
- def visit_NilClass(_o)
14
- @emitter.scalar('null', nil, 'tag:yaml.org,2002:null', true, false, Psych::Nodes::Scalar::ANY)
15
- end
16
- end
17
- Psych::Visitors::YAMLTree.prepend(ShowYamlNulls)
18
-
19
- describe 'AppMap class Hooking' do
20
- include_context 'collect events'
21
-
22
- def invoke_test_file(file, setup: nil, packages: nil)
23
- AppMap.configuration = nil
24
- packages ||= [ AppMap::Config::Package.build_from_path(file) ]
25
- config = AppMap::Config.new('hook_spec', packages: packages)
26
- AppMap.configuration = config
27
- tracer = nil
28
- AppMap::Hook.new(config).enable do
29
- setup_result = setup.call if setup
30
-
31
- tracer = AppMap.tracing.trace
32
- AppMap::Event.reset_id_counter
33
- begin
34
- load file
35
- yield setup_result
36
- ensure
37
- AppMap.tracing.delete(tracer)
38
- end
39
- end
40
-
41
- [ config, tracer ]
42
- end
43
-
44
- def test_hook_behavior(file, events_yaml, setup: nil, &block)
45
- config, tracer = invoke_test_file(file, setup: setup, &block)
46
-
47
- events = collect_events(tracer).to_yaml
48
-
49
- expect(Diffy::Diff.new(events_yaml, events).to_s).to eq('') if events_yaml
50
-
51
- [ config, tracer, events ]
52
- end
53
-
54
- after do
55
- AppMap.configuration = nil
56
- end
57
-
58
- it 'excludes named classes and methods' do
59
- load 'spec/fixtures/hook/exclude.rb'
60
- package = AppMap::Config::Package.build_from_path('spec/fixtures/hook/exclude.rb')
61
- config = AppMap::Config.new('hook_spec', packages: [ package ], exclude: %w[ExcludeTest])
62
- AppMap.configuration = config
63
-
64
- expect(config.never_hook?(ExcludeTest, ExcludeTest.new.method(:instance_method))).to be_truthy
65
- expect(config.never_hook?(ExcludeTest, ExcludeTest.method(:cls_method))).to be_truthy
66
- end
67
-
68
- it "an instance method named 'call' will be ignored" do
69
- events_yaml = <<~YAML
70
- --- []
71
- YAML
72
-
73
- _, tracer = test_hook_behavior 'spec/fixtures/hook/method_named_call.rb', events_yaml do
74
- expect(MethodNamedCall.new.call(1, 2, 3, 4, 5)).to eq('1 2 3 4 5')
75
- end
76
- end
77
-
78
- it 'can custom hook and label a function' do
79
- events_yaml = <<~YAML
80
- ---
81
- - :id: 1
82
- :event: :call
83
- :defined_class: CustomInstanceMethod
84
- :method_id: say_default
85
- :path: spec/fixtures/hook/custom_instance_method.rb
86
- :lineno: 8
87
- :static: false
88
- :parameters: []
89
- :receiver:
90
- :class: CustomInstanceMethod
91
- :value: CustomInstance Method fixture
92
- - :id: 2
93
- :event: :return
94
- :parent_id: 1
95
- :return_value:
96
- :class: String
97
- :value: default
98
- YAML
99
-
100
- config = AppMap::Config.load({
101
- functions: [
102
- {
103
- package: 'hook_spec',
104
- class: 'CustomInstanceMethod',
105
- functions: [ :say_default ],
106
- labels: ['cowsay']
107
- }
108
- ]
109
- }.deep_stringify_keys)
110
-
111
- load 'spec/fixtures/hook/custom_instance_method.rb'
112
- hook_cls = CustomInstanceMethod
113
- method = hook_cls.instance_method(:say_default)
114
-
115
- require 'appmap/hook/method'
116
- package = config.lookup_package(hook_cls, method)
117
- expect(package).to be
118
- hook_method = AppMap::Handler::Function.new(package, hook_cls, method)
119
- hook_method.activate
120
-
121
- tracer = AppMap.tracing.trace
122
- AppMap::Event.reset_id_counter
123
- begin
124
- expect(CustomInstanceMethod.new.say_default).to eq('default')
125
- ensure
126
- AppMap.tracing.delete(tracer)
127
- end
128
-
129
- events = collect_events(tracer).to_yaml
130
-
131
- expect(Diffy::Diff.new(events_yaml, events).to_s).to eq('')
132
- class_map = AppMap.class_map(tracer.event_methods)
133
- expect(Diffy::Diff.new(<<~CLASSMAP, YAML.dump(class_map)).to_s).to eq('')
134
- ---
135
- - :name: hook_spec
136
- :type: package
137
- :children:
138
- - :name: CustomInstanceMethod
139
- :type: class
140
- :children:
141
- - :name: say_default
142
- :type: function
143
- :location: spec/fixtures/hook/custom_instance_method.rb:8
144
- :static: false
145
- :labels:
146
- - cowsay
147
- CLASSMAP
148
- end
149
-
150
- it 'parses labels from comments' do
151
- _, tracer = invoke_test_file 'spec/fixtures/hook/labels.rb' do
152
- ClassWithLabel.new.fn_with_label
153
- end
154
- class_map = AppMap.class_map(tracer.event_methods).to_yaml
155
- expect(Diffy::Diff.new(<<~YAML, class_map).to_s).to eq('')
156
- ---
157
- - :name: spec/fixtures/hook
158
- :type: package
159
- :children:
160
- - :name: ClassWithLabel
161
- :type: class
162
- :children:
163
- - :name: fn_with_label
164
- :type: function
165
- :location: spec/fixtures/hook/labels.rb:4
166
- :static: false
167
- :labels:
168
- - has-fn-label
169
- :comment: "# @label has-fn-label\\n"
170
- YAML
171
- end
172
-
173
- it 'reports sub-folders as distinct packages' do
174
- _, tracer = invoke_test_file 'spec/fixtures/hook/sub_packages.rb',
175
- packages: [ AppMap::Config::Package.build_from_path('spec/fixtures/hook') ] do
176
- SubPackages.invoke_a
177
- end
178
- class_map = AppMap.class_map(tracer.event_methods).to_yaml
179
- expect(Diffy::Diff.new(<<~YAML, class_map).to_s).to eq('')
180
- ---
181
- - :name: spec/fixtures/hook
182
- :type: package
183
- :children:
184
- - :name: SubPackages
185
- :type: class
186
- :children:
187
- - :name: invoke_a
188
- :type: function
189
- :location: spec/fixtures/hook/sub_packages.rb:4
190
- :static: true
191
- - :name: pkg_a
192
- :type: package
193
- :children:
194
- - :name: PkgA
195
- :type: class
196
- :children:
197
- - :name: A
198
- :type: class
199
- :children:
200
- - :name: hello
201
- :type: function
202
- :location: spec/fixtures/hook/pkg_a/a.rb:3
203
- :static: true
204
- YAML
205
- end
206
-
207
- it 'hooks an instance method that takes no arguments' do
208
- events_yaml = <<~YAML
209
- ---
210
- - :id: 1
211
- :event: :call
212
- :defined_class: InstanceMethod
213
- :method_id: say_default
214
- :path: spec/fixtures/hook/instance_method.rb
215
- :lineno: 8
216
- :static: false
217
- :parameters: []
218
- :receiver:
219
- :class: InstanceMethod
220
- :value: Instance Method fixture
221
- - :id: 2
222
- :event: :return
223
- :parent_id: 1
224
- :return_value:
225
- :class: String
226
- :value: default
227
- YAML
228
- test_hook_behavior 'spec/fixtures/hook/instance_method.rb', events_yaml do
229
- expect(InstanceMethod.instance_method(:say_default).parameters).to eq([])
230
- expect(InstanceMethod.public_instance_method(:say_default).parameters).to eq([])
231
- expect(InstanceMethod.new.method(:say_default).parameters).to eq([])
232
- expect(InstanceMethod.new.public_method(:say_default).parameters).to eq([])
233
- expect { InstanceMethod.new.singleton_method(:say_default) }.to raise_error(NameError)
234
-
235
- expect(InstanceMethod.new.say_default).to eq('default')
236
- end
237
- end
238
-
239
- it 'collects the methods that are invoked' do
240
- _, tracer = invoke_test_file 'spec/fixtures/hook/instance_method.rb' do
241
- InstanceMethod.new.say_default
242
- end
243
- expect(tracer.event_methods.to_a.map(&:class_name)).to eq([ 'InstanceMethod' ])
244
- expect(tracer.event_methods.to_a.map(&:name)).to eq([ InstanceMethod.public_instance_method(:say_default).name ])
245
- end
246
-
247
- it 'builds a class map of invoked methods' do
248
- _, tracer = invoke_test_file 'spec/fixtures/hook/instance_method.rb' do
249
- InstanceMethod.new.say_default
250
- end
251
- class_map = AppMap.class_map(tracer.event_methods).to_yaml
252
- expect(Diffy::Diff.new(<<~YAML, class_map).to_s).to eq('')
253
- ---
254
- - :name: spec/fixtures/hook
255
- :type: package
256
- :children:
257
- - :name: InstanceMethod
258
- :type: class
259
- :children:
260
- - :name: say_default
261
- :type: function
262
- :location: spec/fixtures/hook/instance_method.rb:8
263
- :static: false
264
- YAML
265
- end
266
-
267
- it 'does not hook an attr_accessor' do
268
- events_yaml = <<~YAML
269
- --- []
270
- YAML
271
- test_hook_behavior 'spec/fixtures/hook/attr_accessor.rb', events_yaml do
272
- obj = AttrAccessor.new
273
- obj.value = 'foo'
274
- expect(obj.value).to eq('foo')
275
- end
276
- end
277
-
278
- it 'does not hook a constructor' do
279
- events_yaml = <<~YAML
280
- --- []
281
- YAML
282
- test_hook_behavior 'spec/fixtures/hook/constructor.rb', events_yaml do
283
- Constructor.new('foo')
284
- end
285
- end
286
-
287
- it 'records protected instance methods' do
288
- events_yaml = <<~YAML
289
- ---
290
- - :id: 1
291
- :event: :call
292
- :defined_class: ProtectedMethod
293
- :method_id: call_protected
294
- :path: spec/fixtures/hook/protected_method.rb
295
- :lineno: 4
296
- :static: false
297
- :parameters: []
298
- :receiver:
299
- :class: ProtectedMethod
300
- :value: Protected Method fixture
301
- - :id: 2
302
- :event: :call
303
- :defined_class: ProtectedMethod
304
- :method_id: protected_method
305
- :path: spec/fixtures/hook/protected_method.rb
306
- :lineno: 26
307
- :static: false
308
- :parameters: []
309
- :receiver:
310
- :class: ProtectedMethod
311
- :value: Protected Method fixture
312
- - :id: 3
313
- :event: :return
314
- :parent_id: 2
315
- :return_value:
316
- :class: String
317
- :value: protected
318
- - :id: 4
319
- :event: :return
320
- :parent_id: 1
321
- :return_value:
322
- :class: String
323
- :value: protected
324
- YAML
325
- parameters = []
326
- test_hook_behavior 'spec/fixtures/hook/protected_method.rb', events_yaml do
327
- expect(ProtectedMethod.singleton_method(:call_protected).parameters).to eq(parameters)
328
- expect(ProtectedMethod.instance_method(:call_protected).parameters).to eq(parameters)
329
- expect(ProtectedMethod.public_instance_method(:call_protected).parameters).to eq(parameters)
330
- expect(ProtectedMethod.new.method(:call_protected).parameters).to eq(parameters)
331
- expect(ProtectedMethod.new.public_method(:call_protected).parameters).to eq(parameters)
332
- expect { ProtectedMethod.new.singleton_method(:call_protected) }.to raise_error(NameError)
333
-
334
- expect(ProtectedMethod.singleton_method(:protected_method).parameters).to eq(parameters)
335
- expect(ProtectedMethod.instance_method(:protected_method).parameters).to eq(parameters)
336
- expect(ProtectedMethod.public_instance_method(:protected_method).parameters).to eq(parameters)
337
- expect(ProtectedMethod.new.method(:protected_method).parameters).to eq(parameters)
338
- expect(ProtectedMethod.new.public_method(:protected_method).parameters).to eq(parameters)
339
- expect { ProtectedMethod.new.singleton_method(:protected_method) }.to raise_error(NameError)
340
-
341
- expect(ProtectedMethod.new.call_protected).to eq('protected')
342
- end
343
- end
344
-
345
- it 'records protected singleton (static) methods' do
346
- events_yaml = <<~YAML
347
- ---
348
- - :id: 1
349
- :event: :call
350
- :defined_class: ProtectedMethod
351
- :method_id: call_protected
352
- :path: spec/fixtures/hook/protected_method.rb
353
- :lineno: 13
354
- :static: true
355
- :parameters: []
356
- :receiver:
357
- :class: Class
358
- :value: ProtectedMethod
359
- - :id: 2
360
- :event: :call
361
- :defined_class: ProtectedMethod
362
- :method_id: protected_method
363
- :path: spec/fixtures/hook/protected_method.rb
364
- :lineno: 19
365
- :static: true
366
- :parameters: []
367
- :receiver:
368
- :class: Class
369
- :value: ProtectedMethod
370
- - :id: 3
371
- :event: :return
372
- :parent_id: 2
373
- :return_value:
374
- :class: String
375
- :value: self.protected
376
- - :id: 4
377
- :event: :return
378
- :parent_id: 1
379
- :return_value:
380
- :class: String
381
- :value: self.protected
382
- YAML
383
- parameters = []
384
- test_hook_behavior 'spec/fixtures/hook/protected_method.rb', events_yaml do
385
- expect(ProtectedMethod.call_protected).to eq('self.protected')
386
- end
387
- end
388
-
389
- it 'hooks an instance method that takes an argument' do
390
- events_yaml = <<~YAML
391
- ---
392
- - :id: 1
393
- :event: :call
394
- :defined_class: InstanceMethod
395
- :method_id: say_echo
396
- :path: spec/fixtures/hook/instance_method.rb
397
- :lineno: 12
398
- :static: false
399
- :parameters:
400
- - :name: :arg
401
- :class: String
402
- :value: echo
403
- :kind: :req
404
- :receiver:
405
- :class: InstanceMethod
406
- :value: Instance Method fixture
407
- - :id: 2
408
- :event: :return
409
- :parent_id: 1
410
- :return_value:
411
- :class: String
412
- :value: echo
413
- YAML
414
- test_hook_behavior 'spec/fixtures/hook/instance_method.rb', events_yaml do
415
- expect(InstanceMethod.new.say_echo('echo')).to eq('echo')
416
- end
417
- end
418
-
419
- it 'hooks an instance method that takes a keyword argument' do
420
- events_yaml = <<~YAML
421
- ---
422
- - :id: 1
423
- :event: :call
424
- :defined_class: InstanceMethod
425
- :method_id: say_kw
426
- :path: spec/fixtures/hook/instance_method.rb
427
- :lineno: 16
428
- :static: false
429
- :parameters:
430
- - :name: :kw
431
- :class: String
432
- :value: kw
433
- :kind: :key
434
- :receiver:
435
- :class: InstanceMethod
436
- :value: Instance Method fixture
437
- - :id: 2
438
- :event: :return
439
- :parent_id: 1
440
- :return_value:
441
- :class: String
442
- :value: kw
443
- YAML
444
- test_hook_behavior 'spec/fixtures/hook/instance_method.rb', events_yaml do
445
- expect(InstanceMethod.new.say_kw(kw: 'kw')).to eq('kw')
446
- end
447
- end
448
-
449
- it 'hooks an instance method that takes a default keyword argument' do
450
- events_yaml = <<~YAML
451
- ---
452
- - :id: 1
453
- :event: :call
454
- :defined_class: InstanceMethod
455
- :method_id: say_kw
456
- :path: spec/fixtures/hook/instance_method.rb
457
- :lineno: 16
458
- :static: false
459
- :parameters:
460
- - :name: :kw
461
- :class: NilClass
462
- :value: null
463
- :kind: :key
464
- :receiver:
465
- :class: InstanceMethod
466
- :value: Instance Method fixture
467
- - :id: 2
468
- :event: :return
469
- :parent_id: 1
470
- :return_value:
471
- :class: String
472
- :value: kw
473
- YAML
474
- test_hook_behavior 'spec/fixtures/hook/instance_method.rb', events_yaml do
475
- expect(InstanceMethod.new.say_kw).to eq('kw')
476
- end
477
- end
478
-
479
- it 'hooks an instance method that takes keyword arguments' do
480
- events_yaml = <<~YAML
481
- ---
482
- - :id: 1
483
- :event: :call
484
- :defined_class: InstanceMethod
485
- :method_id: say_kws
486
- :path: spec/fixtures/hook/instance_method.rb
487
- :lineno: 20
488
- :static: false
489
- :parameters:
490
- - :name: :args
491
- :class: Array
492
- :value: "[4, 5]"
493
- :kind: :rest
494
- :size: 2
495
- - :name: :kw1
496
- :class: String
497
- :value: one
498
- :kind: :keyreq
499
- - :name: :kw2
500
- :class: Integer
501
- :value: '2'
502
- :kind: :key
503
- - :name: :kws
504
- :class: Hash
505
- :value: "{:kw3=>:three}"
506
- :kind: :keyrest
507
- :size: 1
508
- :receiver:
509
- :class: InstanceMethod
510
- :value: Instance Method fixture
511
- - :id: 2
512
- :event: :return
513
- :parent_id: 1
514
- :return_value:
515
- :class: String
516
- :value: one2{:kw3=>:three}45
517
- YAML
518
- test_hook_behavior 'spec/fixtures/hook/instance_method.rb', events_yaml do
519
- expect(InstanceMethod.new.say_kws(4, 5, kw1: 'one', kw2: 2, kw3: :three)).to eq('one2{:kw3=>:three}45')
520
- end
521
- end
522
-
523
- it 'hooks an instance method that takes a block argument' do
524
- events_yaml = <<~YAML
525
- ---
526
- - :id: 1
527
- :event: :call
528
- :defined_class: InstanceMethod
529
- :method_id: say_block
530
- :path: spec/fixtures/hook/instance_method.rb
531
- :lineno: 24
532
- :static: false
533
- :parameters:
534
- - :name: :block
535
- :class: NilClass
536
- :value: null
537
- :kind: :block
538
- :receiver:
539
- :class: InstanceMethod
540
- :value: Instance Method fixture
541
- - :id: 2
542
- :event: :return
543
- :parent_id: 1
544
- :return_value:
545
- :class: String
546
- :value: albert
547
- YAML
548
- test_hook_behavior 'spec/fixtures/hook/instance_method.rb', events_yaml do
549
- expect(InstanceMethod.new.say_block { 'albert' }).to eq('albert')
550
- end
551
- end
552
-
553
- it 'hooks a singleton method' do
554
- events_yaml = <<~YAML
555
- ---
556
- - :id: 1
557
- :event: :call
558
- :defined_class: SingletonMethod
559
- :method_id: say_default
560
- :path: spec/fixtures/hook/singleton_method.rb
561
- :lineno: 5
562
- :static: true
563
- :parameters: []
564
- :receiver:
565
- :class: Class
566
- :value: SingletonMethod
567
- - :id: 2
568
- :event: :return
569
- :parent_id: 1
570
- :return_value:
571
- :class: String
572
- :value: default
573
- YAML
574
- test_hook_behavior 'spec/fixtures/hook/singleton_method.rb', events_yaml do
575
- expect(SingletonMethod.say_default).to eq('default')
576
- end
577
- end
578
-
579
- it 'hooks a class method with explicit class name scope' do
580
- events_yaml = <<~YAML
581
- ---
582
- - :id: 1
583
- :event: :call
584
- :defined_class: SingletonMethod
585
- :method_id: say_class_defined
586
- :path: spec/fixtures/hook/singleton_method.rb
587
- :lineno: 10
588
- :static: true
589
- :parameters: []
590
- :receiver:
591
- :class: Class
592
- :value: SingletonMethod
593
- - :id: 2
594
- :event: :return
595
- :parent_id: 1
596
- :return_value:
597
- :class: String
598
- :value: defined with explicit class scope
599
- YAML
600
- test_hook_behavior 'spec/fixtures/hook/singleton_method.rb', events_yaml do
601
- expect(SingletonMethod.say_class_defined).to eq('defined with explicit class scope')
602
- end
603
- end
604
-
605
- it "hooks a class method with 'self' as the class name scope" do
606
- events_yaml = <<~YAML
607
- ---
608
- - :id: 1
609
- :event: :call
610
- :defined_class: SingletonMethod
611
- :method_id: say_self_defined
612
- :path: spec/fixtures/hook/singleton_method.rb
613
- :lineno: 14
614
- :static: true
615
- :parameters: []
616
- :receiver:
617
- :class: Class
618
- :value: SingletonMethod
619
- - :id: 2
620
- :event: :return
621
- :parent_id: 1
622
- :return_value:
623
- :class: String
624
- :value: defined with self class scope
625
- YAML
626
- test_hook_behavior 'spec/fixtures/hook/singleton_method.rb', events_yaml do
627
- expect(SingletonMethod.say_self_defined).to eq('defined with self class scope')
628
- end
629
- end
630
-
631
- it 'hooks an included method' do
632
- events_yaml = <<~YAML
633
- ---
634
- - :id: 1
635
- :event: :call
636
- :defined_class: SingletonMethod
637
- :method_id: added_method
638
- :path: spec/fixtures/hook/singleton_method.rb
639
- :lineno: 21
640
- :static: false
641
- :parameters: []
642
- :receiver:
643
- :class: SingletonMethod
644
- :value: Singleton Method fixture
645
- - :id: 2
646
- :event: :call
647
- :defined_class: SingletonMethod::AddMethod
648
- :method_id: _added_method
649
- :path: spec/fixtures/hook/singleton_method.rb
650
- :lineno: 27
651
- :static: false
652
- :parameters: []
653
- :receiver:
654
- :class: SingletonMethod
655
- :value: Singleton Method fixture
656
- - :id: 3
657
- :event: :return
658
- :parent_id: 2
659
- :return_value:
660
- :class: String
661
- :value: defined by including a module
662
- - :id: 4
663
- :event: :return
664
- :parent_id: 1
665
- :return_value:
666
- :class: String
667
- :value: defined by including a module
668
- YAML
669
-
670
- load 'spec/fixtures/hook/singleton_method.rb'
671
- setup = -> { SingletonMethod.new.do_include }
672
- test_hook_behavior 'spec/fixtures/hook/singleton_method.rb', events_yaml, setup: setup do |s|
673
- expect(s.added_method).to eq('defined by including a module')
674
- end
675
- end
676
-
677
- it "doesn't hook a singleton method defined for an instance" do
678
- # Ideally, Ruby would fire a TracePoint event when a singleton
679
- # class gets created by defining a method on an instance. It
680
- # currently doesn't, though, so there's no way for us to hook such
681
- # a method.
682
- #
683
- # This example will fail if Ruby's behavior changes at some point
684
- # in the future.
685
- events_yaml = <<~YAML
686
- --- []
687
- YAML
688
-
689
- load 'spec/fixtures/hook/singleton_method.rb'
690
- setup = -> { SingletonMethod.new_with_instance_method }
691
- test_hook_behavior 'spec/fixtures/hook/singleton_method.rb', events_yaml, setup: setup do |s|
692
- # Make sure we're testing the right thing
693
- say_instance_defined = s.method(:say_instance_defined)
694
- expect(say_instance_defined.owner.to_s).to start_with('#<Class:#<SingletonMethod:')
695
-
696
- # Verify the native extension works as expected
697
- expect(AppMap::Hook.singleton_method_owner_name(say_instance_defined)).to eq('SingletonMethod')
698
-
699
- expect(s.say_instance_defined).to eq('defined for an instance')
700
- end
701
- end
702
-
703
- it 'hooks a singleton method on an embedded struct' do
704
- events_yaml = <<~YAML
705
- ---
706
- - :id: 1
707
- :event: :call
708
- :defined_class: SingletonMethod::STRUCT_TEST
709
- :method_id: say_struct_singleton
710
- :path: spec/fixtures/hook/singleton_method.rb
711
- :lineno: 52
712
- :static: true
713
- :parameters: []
714
- :receiver:
715
- :class: Class
716
- :value: SingletonMethod::STRUCT_TEST
717
- - :id: 2
718
- :event: :return
719
- :parent_id: 1
720
- :return_value:
721
- :class: String
722
- :value: singleton for a struct
723
- YAML
724
-
725
- test_hook_behavior 'spec/fixtures/hook/singleton_method.rb', events_yaml do
726
- expect(SingletonMethod::STRUCT_TEST.say_struct_singleton).to eq('singleton for a struct')
727
- end
728
- end
729
-
730
- it 'reports exceptions' do
731
- events_yaml = <<~YAML
732
- ---
733
- - :id: 1
734
- :event: :call
735
- :defined_class: ExceptionMethod
736
- :method_id: raise_exception
737
- :path: spec/fixtures/hook/exception_method.rb
738
- :lineno: 8
739
- :static: false
740
- :parameters: []
741
- :receiver:
742
- :class: ExceptionMethod
743
- :value: Exception Method fixture
744
- - :id: 2
745
- :event: :return
746
- :parent_id: 1
747
- :exceptions:
748
- - :class: RuntimeError
749
- :message: Exception occurred in raise_exception
750
- :path: spec/fixtures/hook/exception_method.rb
751
- :lineno: 9
752
- YAML
753
- test_hook_behavior 'spec/fixtures/hook/exception_method.rb', events_yaml do
754
- begin
755
- ExceptionMethod.new.raise_exception
756
- rescue
757
- # don't let the exception fail the test
758
- end
759
- end
760
- end
761
-
762
- it 'sanitizes exception messages' do
763
- events_yaml = <<~YAML
764
- ---
765
- - :id: 1
766
- :event: :call
767
- :defined_class: ExceptionMethod
768
- :method_id: raise_illegal_utf8_message
769
- :path: spec/fixtures/hook/exception_method.rb
770
- :lineno: 58
771
- :static: false
772
- :parameters: []
773
- :receiver:
774
- :class: ExceptionMethod
775
- :value: Exception Method fixture
776
- - :id: 2
777
- :event: :return
778
- :parent_id: 1
779
- :exceptions:
780
- - :class: RuntimeError
781
- :message: '809: unexpected token at ''x__=_v_ƶ_2_]__qdI_eǫ4_h΅__z_____D__J2_E______1__ā'''
782
- :path: spec/fixtures/hook/exception_method.rb
783
- :lineno: 59
784
- YAML
785
- test_hook_behavior 'spec/fixtures/hook/exception_method.rb', events_yaml do
786
- begin
787
- ExceptionMethod.new.raise_illegal_utf8_message
788
- rescue
789
- # don't let the exception fail the test
790
- end
791
- end
792
- end
793
-
794
- context 'string conversions works for the receiver when' do
795
- it 'is missing #to_s' do
796
- events_yaml = <<~YAML
797
- ---
798
- - :id: 1
799
- :event: :call
800
- :defined_class: NoToSMethod
801
- :method_id: say_hello
802
- :path: spec/fixtures/hook/exception_method.rb
803
- :lineno: 32
804
- :static: false
805
- :parameters: []
806
- :receiver:
807
- :class: Class
808
- :value: NoToSMethod
809
- - :id: 2
810
- :event: :return
811
- :parent_id: 1
812
- :return_value:
813
- :class: String
814
- :value: hello
815
- YAML
816
-
817
- test_hook_behavior 'spec/fixtures/hook/exception_method.rb', events_yaml do
818
- inst = NoToSMethod.new
819
- # sanity check
820
- expect(inst).not_to respond_to(:to_s)
821
- inst.say_hello
822
- end
823
- end
824
-
825
- it 'it is missing #to_s and it raises an exception in #inspect' do
826
- events_yaml = <<~YAML
827
- ---
828
- - :id: 1
829
- :event: :call
830
- :defined_class: InspectRaises
831
- :method_id: say_hello
832
- :path: spec/fixtures/hook/exception_method.rb
833
- :lineno: 42
834
- :static: false
835
- :parameters: []
836
- :receiver:
837
- :class: Class
838
- :value: "*Error inspecting variable*"
839
- - :id: 2
840
- :event: :return
841
- :parent_id: 1
842
- :return_value:
843
- :class: String
844
- :value: hello
845
- YAML
846
-
847
- test_hook_behavior 'spec/fixtures/hook/exception_method.rb', events_yaml do
848
- inst = InspectRaises.new
849
- # sanity check
850
- expect(inst).not_to respond_to(:to_s)
851
- inst.say_hello
852
- end
853
- end
854
-
855
- it 'it raises an exception in #to_s' do
856
- events_yaml = <<~YAML
857
- ---
858
- - :id: 1
859
- :event: :call
860
- :defined_class: ToSRaises
861
- :method_id: say_hello
862
- :path: spec/fixtures/hook/exception_method.rb
863
- :lineno: 52
864
- :static: false
865
- :parameters: []
866
- :receiver:
867
- :class: ToSRaises
868
- :value: "*Error inspecting variable*"
869
- - :id: 2
870
- :event: :return
871
- :parent_id: 1
872
- :return_value:
873
- :class: String
874
- :value: hello
875
- YAML
876
-
877
- test_hook_behavior 'spec/fixtures/hook/exception_method.rb', events_yaml do
878
- ToSRaises.new.say_hello
879
- end
880
- end
881
- end
882
-
883
- it 're-raises exceptions' do
884
- RSpec::Expectations.configuration.on_potential_false_positives = :nothing
885
-
886
- invoke_test_file 'spec/fixtures/hook/exception_method.rb' do
887
- expect { ExceptionMethod.new.raise_exception }.to raise_exception
888
- end
889
- end
890
-
891
- context 'ActiveSupport::SecurityUtils.secure_compare' do
892
- it 'is hooked' do
893
- events_yaml = <<~YAML
894
- ---
895
- - :id: 1
896
- :event: :call
897
- :defined_class: Compare
898
- :method_id: compare
899
- :path: spec/fixtures/hook/compare.rb
900
- :lineno: 4
901
- :static: true
902
- :parameters:
903
- - :name: :s1
904
- :class: String
905
- :value: string
906
- :kind: :req
907
- - :name: :s2
908
- :class: String
909
- :value: string
910
- :kind: :req
911
- :receiver:
912
- :class: Class
913
- :value: Compare
914
- - :id: 2
915
- :event: :call
916
- :defined_class: ActiveSupport::SecurityUtils
917
- :method_id: secure_compare
918
- :path: lib/active_support/security_utils.rb
919
- :lineno: 26
920
- :static: true
921
- :parameters:
922
- - :name: :a
923
- :class: String
924
- :value: string
925
- :kind: :req
926
- - :name: :b
927
- :class: String
928
- :value: string
929
- :kind: :req
930
- :receiver:
931
- :class: Module
932
- :value: ActiveSupport::SecurityUtils
933
- - :id: 3
934
- :event: :call
935
- :defined_class: Digest::Instance
936
- :method_id: digest
937
- :path: Digest::Instance#digest
938
- :static: false
939
- :parameters:
940
- - :name: arg
941
- :class: Array
942
- :value: '["string"]'
943
- :kind: :rest
944
- :receiver:
945
- :class: Digest::SHA256
946
- :value: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
947
- - :id: 4
948
- :event: :return
949
- :parent_id: 3
950
- :return_value:
951
- :class: String
952
- :value: "G2__)__qc____X____3_].\\x02y__.___/_"
953
- - :id: 5
954
- :event: :call
955
- :defined_class: Digest::Instance
956
- :method_id: digest
957
- :path: Digest::Instance#digest
958
- :static: false
959
- :parameters:
960
- - :name: arg
961
- :class: Array
962
- :value: '["string"]'
963
- :kind: :rest
964
- :receiver:
965
- :class: Digest::SHA256
966
- :value: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
967
- - :id: 6
968
- :event: :return
969
- :parent_id: 5
970
- :return_value:
971
- :class: String
972
- :value: "G2__)__qc____X____3_].\\x02y__.___/_"
973
- - :id: 7
974
- :event: :return
975
- :parent_id: 2
976
- :return_value:
977
- :class: TrueClass
978
- :value: 'true'
979
- - :id: 8
980
- :event: :return
981
- :parent_id: 1
982
- :return_value:
983
- :class: TrueClass
984
- :value: 'true'
985
- YAML
986
-
987
- _, _, events = test_hook_behavior 'spec/fixtures/hook/compare.rb', nil do
988
- expect(Compare.compare('string', 'string')).to be_truthy
989
- end
990
-
991
- secure_compare_event = YAML.load(events).find { |evt| evt[:defined_class] == 'ActiveSupport::SecurityUtils' }
992
- expect(secure_compare_event).to be_truthy
993
- secure_compare_event.delete(:lineno)
994
- secure_compare_event.delete(:path)
995
-
996
- expect(Diffy::Diff.new(<<~YAML, secure_compare_event.to_yaml).to_s).to eq('')
997
- ---
998
- :id: 2
999
- :event: :call
1000
- :defined_class: ActiveSupport::SecurityUtils
1001
- :method_id: secure_compare
1002
- :static: true
1003
- :parameters:
1004
- - :name: :a
1005
- :class: String
1006
- :value: string
1007
- :kind: :req
1008
- - :name: :b
1009
- :class: String
1010
- :value: string
1011
- :kind: :req
1012
- :receiver:
1013
- :class: Module
1014
- :value: ActiveSupport::SecurityUtils
1015
- YAML
1016
- end
1017
-
1018
- it 'gets labeled in the classmap' do
1019
- classmap_yaml = <<~YAML
1020
- ---
1021
- - :name: spec/fixtures/hook/compare.rb
1022
- :type: package
1023
- :children:
1024
- - :name: Compare
1025
- :type: class
1026
- :children:
1027
- - :name: compare
1028
- :type: function
1029
- :location: spec/fixtures/hook/compare.rb:4
1030
- :static: true
1031
- :source: |2
1032
- def self.compare(s1, s2)
1033
- ActiveSupport::SecurityUtils.secure_compare(s1, s2)
1034
- end
1035
- - :name: active_support
1036
- :type: package
1037
- :children:
1038
- - :name: ActiveSupport
1039
- :type: class
1040
- :children:
1041
- - :name: SecurityUtils
1042
- :type: class
1043
- :children:
1044
- - :name: secure_compare
1045
- :type: function
1046
- :location: lib/active_support/security_utils.rb:26
1047
- :static: true
1048
- :labels:
1049
- - security
1050
- - crypto
1051
- :comment: |
1052
- # Constant time string comparison, for variable length strings.
1053
- #
1054
- # The values are first processed by SHA256, so that we don't leak length info
1055
- # via timing attacks.
1056
- :source: |2
1057
- def secure_compare(a, b)
1058
- fixed_length_secure_compare(::Digest::SHA256.digest(a), ::Digest::SHA256.digest(b)) && a == b
1059
- end
1060
- - :name: openssl
1061
- :type: package
1062
- :children:
1063
- - :name: Digest
1064
- :type: class
1065
- :children:
1066
- - :name: Instance
1067
- :type: class
1068
- :children:
1069
- - :name: digest
1070
- :type: function
1071
- :location: Digest::Instance#digest
1072
- :static: false
1073
- :labels:
1074
- - security
1075
- - crypto
1076
- YAML
1077
-
1078
- _, tracer = invoke_test_file 'spec/fixtures/hook/compare.rb' do
1079
- expect(Compare.compare('string', 'string')).to be_truthy
1080
- end
1081
- cm = AppMap::Util.sanitize_paths(AppMap::ClassMap.build_from_methods(tracer.event_methods))
1082
- entry = cm[1][:children][0][:children][0][:children][0]
1083
- # Sanity check, make sure we got the right one
1084
- expect(entry[:name]).to eq('secure_compare')
1085
- expect(entry[:labels]).to eq(%w[crypto.secure_compare])
1086
- end
1087
- end
1088
-
1089
- it "doesn't cause expectations on Time.now to fail" do
1090
- events_yaml = <<~YAML
1091
- ---
1092
- - :id: 1
1093
- :event: :call
1094
- :defined_class: InstanceMethod
1095
- :method_id: say_the_time
1096
- :path: spec/fixtures/hook/instance_method.rb
1097
- :lineno: 28
1098
- :static: false
1099
- :parameters: []
1100
- :receiver:
1101
- :class: InstanceMethod
1102
- :value: Instance Method fixture
1103
- - :id: 2
1104
- :event: :return
1105
- :parent_id: 1
1106
- :return_value:
1107
- :class: String
1108
- :value: '2020-01-01 00:00:00 +0000'
1109
- YAML
1110
- test_hook_behavior 'spec/fixtures/hook/instance_method.rb', events_yaml do
1111
- require 'timecop'
1112
- begin
1113
- tz = ENV['TZ']
1114
- ENV['TZ'] = 'UTC'
1115
- Timecop.freeze(Time.utc(2020, 01, 01)) do
1116
- expect(Time).to receive(:now).at_least(3).times.and_call_original
1117
- expect(InstanceMethod.new.say_the_time).to be
1118
- end
1119
- ensure
1120
- ENV['TZ'] = tz
1121
- end
1122
- end
1123
- end
1124
-
1125
- it 'preserves the arity of hooked methods' do
1126
- invoke_test_file 'spec/fixtures/hook/instance_method.rb' do
1127
- expect(InstanceMethod.instance_method(:say_echo).arity).to be(1)
1128
- expect(InstanceMethod.new.method(:say_echo).arity).to be(1)
1129
- end
1130
- end
1131
-
1132
- it 'preserves the sighnature of hooked methods' do
1133
- parameters = []
1134
- events = <<~YAML
1135
- ---
1136
- - :id: 1
1137
- :event: :call
1138
- :defined_class: ReportParameters
1139
- :method_id: report_parameters
1140
- :path: spec/fixtures/hook/report_parameters.rb
1141
- :lineno: 5
1142
- :static: false
1143
- :parameters:
1144
- - :name: :args
1145
- :class: Array
1146
- :value: "[foo]"
1147
- :kind: :rest
1148
- :size: 1
1149
- - :name: :kw1
1150
- :class: String
1151
- :value: kw1
1152
- :kind: :keyreq
1153
- - :name: :kw2
1154
- :class: NilClass
1155
- :value: null
1156
- :kind: :key
1157
- - :name: :kws
1158
- :class: Hash
1159
- :value: "{}"
1160
- :kind: :keyrest
1161
- :size: 0
1162
- :receiver:
1163
- :class: ReportParameters
1164
- :value: ReportParameters
1165
- - :id: 2
1166
- :event: :return
1167
- :parent_id: 1
1168
- :return_value:
1169
- :class: Array
1170
- :value: "[[:rest, :args], [:keyreq, :kw1], [:key, :kw2], [:keyrest, :kws]]"
1171
- :size: 4
1172
- YAML
1173
- parameters = [[:rest, :args], [:keyreq, :kw1], [:key, :kw2], [:keyrest, :kws]]
1174
- test_hook_behavior 'spec/fixtures/hook/report_parameters.rb', events do
1175
- expect(ReportParameters.instance_method(:report_parameters).parameters).to eq(parameters)
1176
- expect(ReportParameters.new.report_parameters('foo', kw1: 'kw1')).to eq(parameters)
1177
- end
1178
- end
1179
-
1180
- describe 'kwargs handling' do
1181
- if ruby_2?
1182
- # https://github.com/applandinc/appmap-ruby/issues/153
1183
- it 'empty hash for **kwrest can be proxied as a regular function argument', github_issue: 153 do
1184
- invoke_test_file 'spec/fixtures/hook/kwargs.rb' do
1185
- expect(Kwargs.has_kwrest_calls_no_kwargs(nil, {})).to eq({})
1186
- end
1187
- end
1188
- end
1189
- end
1190
-
1191
- describe 'prepended override' do
1192
- it 'does not cause stack overflow error' do
1193
- # For the purposes of this test, the code must be statically required, then hooked,
1194
- # then executed.
1195
-
1196
- require_relative './fixtures/hook/prepended_override'
1197
- require 'appmap/hook/method'
1198
-
1199
- pkg = AppMap::Config::Package.new('fixtures/hook/prependend_override')
1200
- AppMap::Handler::Function.new(pkg, PrependedClass, PrependedClass.public_instance_method(:say_hello)).activate
1201
-
1202
- tracer = AppMap.tracing.trace
1203
- AppMap::Event.reset_id_counter
1204
- begin
1205
- expect(PrependedClass.new.say_hello).to eq('please allow me to introduce myself')
1206
- ensure
1207
- AppMap.tracing.delete(tracer)
1208
- end
1209
-
1210
- events = collect_events(tracer)
1211
- expect(events.length).to eq(2)
1212
- expect(events.first[:method_id]).to eq('say_hello')
1213
- expect(events.second[:return_value][:value]).to eq('please allow me to introduce myself')
1214
- end
1215
- end
1216
- end