appmap 0.37.0 → 0.37.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +1 -1
  3. data/.rubocop.yml +7 -0
  4. data/CHANGELOG.md +6 -0
  5. data/Rakefile +1 -1
  6. data/lib/appmap/event.rb +16 -1
  7. data/lib/appmap/rails/request_handler.rb +8 -1
  8. data/lib/appmap/version.rb +1 -1
  9. data/spec/abstract_controller4_base_spec.rb +27 -28
  10. data/spec/abstract_controller_base_spec.rb +43 -39
  11. data/spec/fixtures/hook/instance_method.rb +4 -0
  12. data/spec/fixtures/{rails_users_app → rails5_users_app}/.dockerignore +0 -0
  13. data/spec/fixtures/{rails_users_app → rails5_users_app}/.gitignore +0 -0
  14. data/spec/fixtures/{rails_users_app → rails5_users_app}/.rspec +0 -0
  15. data/spec/fixtures/{rails_users_app → rails5_users_app}/.ruby-version +0 -0
  16. data/spec/fixtures/{rails_users_app → rails5_users_app}/Dockerfile +0 -0
  17. data/spec/fixtures/{rails_users_app → rails5_users_app}/Dockerfile.pg +0 -0
  18. data/spec/fixtures/rails5_users_app/Gemfile +51 -0
  19. data/spec/fixtures/{rails_users_app → rails5_users_app}/Rakefile +0 -0
  20. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/api/users_controller.rb +0 -0
  21. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/application_controller.rb +0 -0
  22. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/concerns/.keep +0 -0
  23. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/health_controller.rb +0 -0
  24. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/users_controller.rb +0 -0
  25. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/models/activerecord/user.rb +0 -0
  26. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/models/concerns/.keep +0 -0
  27. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/models/sequel/user.rb +0 -0
  28. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/views/layouts/application.html.haml +0 -0
  29. data/spec/fixtures/{rails_users_app → rails5_users_app}/app/views/users/index.html.haml +0 -0
  30. data/spec/fixtures/{rails_users_app → rails5_users_app}/appmap.yml +1 -1
  31. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/appmap +0 -0
  32. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/byebug +0 -0
  33. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/gli +0 -0
  34. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/htmldiff +0 -0
  35. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/ldiff +0 -0
  36. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/nokogiri +0 -0
  37. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rackup +0 -0
  38. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rails +0 -0
  39. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rake +0 -0
  40. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rspec +0 -0
  41. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/ruby-parse +0 -0
  42. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/ruby-rewrite +0 -0
  43. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/sequel +0 -0
  44. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/setup +0 -0
  45. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/sprockets +0 -0
  46. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/thor +0 -0
  47. data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/update +0 -0
  48. data/spec/fixtures/{rails_users_app → rails5_users_app}/config.ru +0 -0
  49. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/application.rb +0 -0
  50. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/boot.rb +0 -0
  51. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/credentials.yml.enc +0 -0
  52. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/database.yml +0 -0
  53. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environment.rb +0 -0
  54. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environments/development.rb +0 -0
  55. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environments/production.rb +0 -0
  56. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environments/test.rb +0 -0
  57. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/application_controller_renderer.rb +0 -0
  58. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/backtrace_silencers.rb +0 -0
  59. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/cors.rb +0 -0
  60. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/filter_parameter_logging.rb +0 -0
  61. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/inflections.rb +0 -0
  62. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/mime_types.rb +0 -0
  63. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/record_button.rb +0 -0
  64. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/wrap_parameters.rb +0 -0
  65. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/locales/en.yml +0 -0
  66. data/spec/fixtures/{rails_users_app → rails5_users_app}/config/routes.rb +0 -0
  67. data/spec/fixtures/{rails_users_app → rails5_users_app}/create_app +0 -0
  68. data/spec/fixtures/{rails_users_app → rails5_users_app}/db/migrate/20190728211408_create_users.rb +0 -0
  69. data/spec/fixtures/{rails_users_app → rails5_users_app}/db/schema.rb +0 -0
  70. data/spec/fixtures/{rails_users_app → rails5_users_app}/docker-compose.yml +0 -0
  71. data/spec/fixtures/{rails_users_app → rails5_users_app}/features/api_users.feature +0 -0
  72. data/spec/fixtures/{rails_users_app → rails5_users_app}/features/support/env.rb +0 -0
  73. data/spec/fixtures/{rails_users_app → rails5_users_app}/features/support/hooks.rb +0 -0
  74. data/spec/fixtures/{rails_users_app → rails5_users_app}/features/support/steps.rb +0 -0
  75. data/spec/fixtures/{rails_users_app → rails5_users_app}/lib/tasks/.keep +0 -0
  76. data/spec/fixtures/{rails_users_app → rails5_users_app}/log/.keep +0 -0
  77. data/spec/fixtures/{rails_users_app → rails5_users_app}/public/robots.txt +0 -0
  78. data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/controllers/users_controller_api_spec.rb +0 -0
  79. data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/models/user_spec.rb +0 -0
  80. data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/rails_helper.rb +0 -0
  81. data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/spec_helper.rb +0 -0
  82. data/spec/fixtures/{rails_users_app → rails5_users_app}/users_app/.gitignore +0 -0
  83. data/spec/fixtures/rails6_users_app/.dockerignore +1 -0
  84. data/spec/fixtures/rails6_users_app/.gitignore +39 -0
  85. data/spec/fixtures/rails6_users_app/.rspec +1 -0
  86. data/spec/fixtures/rails6_users_app/.ruby-version +1 -0
  87. data/spec/fixtures/rails6_users_app/Dockerfile +29 -0
  88. data/spec/fixtures/rails6_users_app/Dockerfile.pg +3 -0
  89. data/spec/fixtures/{rails_users_app → rails6_users_app}/Gemfile +0 -0
  90. data/spec/fixtures/rails6_users_app/Rakefile +6 -0
  91. data/spec/fixtures/rails6_users_app/app/controllers/api/users_controller.rb +27 -0
  92. data/spec/fixtures/rails6_users_app/app/controllers/application_controller.rb +2 -0
  93. data/spec/fixtures/rails6_users_app/app/controllers/concerns/.keep +0 -0
  94. data/spec/fixtures/rails6_users_app/app/controllers/health_controller.rb +5 -0
  95. data/spec/fixtures/rails6_users_app/app/controllers/users_controller.rb +5 -0
  96. data/spec/fixtures/rails6_users_app/app/models/activerecord/user.rb +18 -0
  97. data/spec/fixtures/rails6_users_app/app/models/concerns/.keep +0 -0
  98. data/spec/fixtures/rails6_users_app/app/models/sequel/user.rb +25 -0
  99. data/spec/fixtures/rails6_users_app/app/views/layouts/application.html.haml +7 -0
  100. data/spec/fixtures/rails6_users_app/app/views/users/index.html.haml +7 -0
  101. data/spec/fixtures/rails6_users_app/appmap.yml +3 -0
  102. data/spec/fixtures/rails6_users_app/bin/appmap +29 -0
  103. data/spec/fixtures/rails6_users_app/bin/byebug +29 -0
  104. data/spec/fixtures/rails6_users_app/bin/gli +29 -0
  105. data/spec/fixtures/rails6_users_app/bin/htmldiff +29 -0
  106. data/spec/fixtures/rails6_users_app/bin/ldiff +29 -0
  107. data/spec/fixtures/rails6_users_app/bin/nokogiri +29 -0
  108. data/spec/fixtures/rails6_users_app/bin/rackup +29 -0
  109. data/spec/fixtures/rails6_users_app/bin/rails +4 -0
  110. data/spec/fixtures/rails6_users_app/bin/rake +29 -0
  111. data/spec/fixtures/rails6_users_app/bin/rspec +29 -0
  112. data/spec/fixtures/rails6_users_app/bin/ruby-parse +29 -0
  113. data/spec/fixtures/rails6_users_app/bin/ruby-rewrite +29 -0
  114. data/spec/fixtures/rails6_users_app/bin/sequel +29 -0
  115. data/spec/fixtures/rails6_users_app/bin/setup +25 -0
  116. data/spec/fixtures/rails6_users_app/bin/sprockets +29 -0
  117. data/spec/fixtures/rails6_users_app/bin/thor +29 -0
  118. data/spec/fixtures/rails6_users_app/bin/update +25 -0
  119. data/spec/fixtures/rails6_users_app/config.ru +5 -0
  120. data/spec/fixtures/rails6_users_app/config/application.rb +51 -0
  121. data/spec/fixtures/rails6_users_app/config/boot.rb +3 -0
  122. data/spec/fixtures/rails6_users_app/config/credentials.yml.enc +1 -0
  123. data/spec/fixtures/rails6_users_app/config/database.yml +18 -0
  124. data/spec/fixtures/rails6_users_app/config/environment.rb +5 -0
  125. data/spec/fixtures/rails6_users_app/config/environments/development.rb +40 -0
  126. data/spec/fixtures/rails6_users_app/config/environments/production.rb +68 -0
  127. data/spec/fixtures/rails6_users_app/config/environments/test.rb +36 -0
  128. data/spec/fixtures/rails6_users_app/config/initializers/application_controller_renderer.rb +8 -0
  129. data/spec/fixtures/rails6_users_app/config/initializers/backtrace_silencers.rb +7 -0
  130. data/spec/fixtures/rails6_users_app/config/initializers/cors.rb +16 -0
  131. data/spec/fixtures/rails6_users_app/config/initializers/filter_parameter_logging.rb +4 -0
  132. data/spec/fixtures/rails6_users_app/config/initializers/inflections.rb +16 -0
  133. data/spec/fixtures/rails6_users_app/config/initializers/mime_types.rb +4 -0
  134. data/spec/fixtures/rails6_users_app/config/initializers/record_button.rb +3 -0
  135. data/spec/fixtures/rails6_users_app/config/initializers/wrap_parameters.rb +9 -0
  136. data/spec/fixtures/rails6_users_app/config/locales/en.yml +33 -0
  137. data/spec/fixtures/rails6_users_app/config/routes.rb +11 -0
  138. data/spec/fixtures/rails6_users_app/create_app +27 -0
  139. data/spec/fixtures/rails6_users_app/db/migrate/20190728211408_create_users.rb +9 -0
  140. data/spec/fixtures/rails6_users_app/db/schema.rb +23 -0
  141. data/spec/fixtures/rails6_users_app/docker-compose.yml +28 -0
  142. data/spec/fixtures/rails6_users_app/features/api_users.feature +13 -0
  143. data/spec/fixtures/rails6_users_app/features/support/env.rb +4 -0
  144. data/spec/fixtures/rails6_users_app/features/support/hooks.rb +11 -0
  145. data/spec/fixtures/rails6_users_app/features/support/steps.rb +18 -0
  146. data/spec/fixtures/rails6_users_app/lib/tasks/.keep +0 -0
  147. data/spec/fixtures/rails6_users_app/log/.keep +0 -0
  148. data/spec/fixtures/rails6_users_app/public/robots.txt +1 -0
  149. data/spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb +29 -0
  150. data/spec/fixtures/rails6_users_app/spec/models/user_spec.rb +39 -0
  151. data/spec/fixtures/rails6_users_app/spec/rails_helper.rb +66 -0
  152. data/spec/fixtures/rails6_users_app/spec/spec_helper.rb +96 -0
  153. data/spec/fixtures/rails6_users_app/users_app/.gitignore +20 -0
  154. data/spec/hook_spec.rb +56 -14
  155. data/spec/rails_spec_helper.rb +5 -5
  156. data/spec/railtie_spec.rb +31 -32
  157. data/spec/record_sql_rails4_pg_spec.rb +47 -48
  158. data/spec/record_sql_rails_pg_spec.rb +62 -63
  159. data/spec/remote_recording_spec.rb +90 -89
  160. data/spec/rspec_feature_metadata_spec.rb +17 -18
  161. metadata +144 -73
@@ -0,0 +1,66 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ require 'spec_helper'
3
+ ENV['RAILS_ENV'] ||= 'test'
4
+ require File.expand_path('../../config/environment', __FILE__)
5
+ # Prevent database truncation if the environment is production
6
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
7
+ require 'rspec/rails'
8
+ # Add additional requires below this line. Rails is not loaded until this point!
9
+
10
+ require 'appmap/rspec'
11
+
12
+ # Requires supporting ruby files with custom matchers and macros, etc, in
13
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
14
+ # run as spec files by default. This means that files in spec/support that end
15
+ # in _spec.rb will both be required and run as specs, causing the specs to be
16
+ # run twice. It is recommended that you do not name files matching this glob to
17
+ # end with _spec.rb. You can configure this pattern with the --pattern
18
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
19
+ #
20
+ # The following line is provided for convenience purposes. It has the downside
21
+ # of increasing the boot-up time by auto-requiring all files in the support
22
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
23
+ # require only the support files necessary.
24
+ #
25
+ # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
26
+
27
+ RSpec.configure do |config|
28
+ # RSpec Rails can automatically mix in different behaviours to your tests
29
+ # based on their file location, for example enabling you to call `get` and
30
+ # `post` in specs under `spec/controllers`.
31
+ #
32
+ # You can disable this behaviour by removing the line below, and instead
33
+ # explicitly tag your specs with their type, e.g.:
34
+ #
35
+ # RSpec.describe UsersController, :type => :controller do
36
+ # # ...
37
+ # end
38
+ #
39
+ # The different available types are documented in the features, such as in
40
+ # https://relishapp.com/rspec/rspec-rails/docs
41
+ config.infer_spec_type_from_file_location!
42
+
43
+ # Filter lines from Rails gems in backtraces.
44
+ config.filter_rails_from_backtrace!
45
+ # arbitrary gems may also be filtered via:
46
+ # config.filter_gems_from_backtrace("gem name")
47
+
48
+
49
+ DatabaseCleaner.allow_remote_database_url = true
50
+
51
+ config.before(:suite) do
52
+ DatabaseCleaner.strategy = :transaction
53
+ DatabaseCleaner.clean_with(:truncation)
54
+ end
55
+
56
+ config.around :each do |example|
57
+ # Enable the use of 'return' from a guard
58
+ -> {
59
+ return example.run unless %i[model controller].member?(example.metadata[:type])
60
+
61
+ DatabaseCleaner.cleaning do
62
+ example.run
63
+ end
64
+ }.call
65
+ end
66
+ end
@@ -0,0 +1,96 @@
1
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
+ RSpec.configure do |config|
17
+ # rspec-expectations config goes here. You can use an alternate
18
+ # assertion/expectation library such as wrong or the stdlib/minitest
19
+ # assertions if you prefer.
20
+ config.expect_with :rspec do |expectations|
21
+ # This option will default to `true` in RSpec 4. It makes the `description`
22
+ # and `failure_message` of custom matchers include text for helper methods
23
+ # defined using `chain`, e.g.:
24
+ # be_bigger_than(2).and_smaller_than(4).description
25
+ # # => "be bigger than 2 and smaller than 4"
26
+ # ...rather than:
27
+ # # => "be bigger than 2"
28
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
29
+ end
30
+
31
+ # rspec-mocks config goes here. You can use an alternate test double
32
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
33
+ config.mock_with :rspec do |mocks|
34
+ # Prevents you from mocking or stubbing a method that does not exist on
35
+ # a real object. This is generally recommended, and will default to
36
+ # `true` in RSpec 4.
37
+ mocks.verify_partial_doubles = true
38
+ end
39
+
40
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
41
+ # have no way to turn it off -- the option exists only for backwards
42
+ # compatibility in RSpec 3). It causes shared context metadata to be
43
+ # inherited by the metadata hash of host groups and examples, rather than
44
+ # triggering implicit auto-inclusion in groups with matching metadata.
45
+ config.shared_context_metadata_behavior = :apply_to_host_groups
46
+
47
+ # The settings below are suggested to provide a good initial experience
48
+ # with RSpec, but feel free to customize to your heart's content.
49
+ =begin
50
+ # This allows you to limit a spec run to individual examples or groups
51
+ # you care about by tagging them with `:focus` metadata. When nothing
52
+ # is tagged with `:focus`, all examples get run. RSpec also provides
53
+ # aliases for `it`, `describe`, and `context` that include `:focus`
54
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
55
+ config.filter_run_when_matching :focus
56
+
57
+ # Allows RSpec to persist some state between runs in order to support
58
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
59
+ # you configure your source control system to ignore this file.
60
+ config.example_status_persistence_file_path = "spec/examples.txt"
61
+
62
+ # Limits the available syntax to the non-monkey patched syntax that is
63
+ # recommended. For more details, see:
64
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
65
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
66
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
67
+ config.disable_monkey_patching!
68
+
69
+ # Many RSpec users commonly either run the entire suite or an individual
70
+ # file, and it's useful to allow more verbose output when running an
71
+ # individual spec file.
72
+ if config.files_to_run.one?
73
+ # Use the documentation formatter for detailed output,
74
+ # unless a formatter has already been configured
75
+ # (e.g. via a command-line flag).
76
+ config.default_formatter = "doc"
77
+ end
78
+
79
+ # Print the 10 slowest examples and example groups at the
80
+ # end of the spec run, to help surface which specs are running
81
+ # particularly slow.
82
+ config.profile_examples = 10
83
+
84
+ # Run specs in random order to surface order dependencies. If you find an
85
+ # order dependency and want to debug it, you can fix the order by providing
86
+ # the seed, which is printed after each run.
87
+ # --seed 1234
88
+ config.order = :random
89
+
90
+ # Seed global randomization in this process using the `--seed` CLI option.
91
+ # Setting this allows you to use `--seed` to deterministically reproduce
92
+ # test failures related to randomization by passing the same `--seed` value
93
+ # as the one that triggered the failure.
94
+ Kernel.srand config.seed
95
+ =end
96
+ end
@@ -0,0 +1,20 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore all logfiles and tempfiles.
11
+ /log/*
12
+ /tmp/*
13
+ !/log/.keep
14
+ !/tmp/.keep
15
+
16
+
17
+ .byebug_history
18
+
19
+ # Ignore master key for decrypting credentials and more.
20
+ /config/master.key
@@ -181,8 +181,8 @@ describe 'AppMap class Hooking', docker: false do
181
181
  :static: false
182
182
  :parameters:
183
183
  - :name: :kw
184
- :class: Hash
185
- :value: '{:kw=>"kw"}'
184
+ :class: String
185
+ :value: kw
186
186
  :kind: :key
187
187
  :receiver:
188
188
  :class: InstanceMethod
@@ -229,6 +229,48 @@ describe 'AppMap class Hooking', docker: false do
229
229
  end
230
230
  end
231
231
 
232
+ it 'hooks an instance method that takes keyword arguments' do
233
+ events_yaml = <<~YAML
234
+ ---
235
+ - :id: 1
236
+ :event: :call
237
+ :defined_class: InstanceMethod
238
+ :method_id: say_kws
239
+ :path: spec/fixtures/hook/instance_method.rb
240
+ :lineno: 20
241
+ :static: false
242
+ :parameters:
243
+ - :name: :args
244
+ :class: Array
245
+ :value: "[4, 5]"
246
+ :kind: :rest
247
+ - :name: :kw1
248
+ :class: String
249
+ :value: one
250
+ :kind: :keyreq
251
+ - :name: :kw2
252
+ :class: Integer
253
+ :value: '2'
254
+ :kind: :key
255
+ - :name: :kws
256
+ :class: Hash
257
+ :value: "{:kw3=>:three}"
258
+ :kind: :keyrest
259
+ :receiver:
260
+ :class: InstanceMethod
261
+ :value: Instance Method fixture
262
+ - :id: 2
263
+ :event: :return
264
+ :parent_id: 1
265
+ :return_value:
266
+ :class: String
267
+ :value: one2{:kw3=>:three}45
268
+ YAML
269
+ test_hook_behavior 'spec/fixtures/hook/instance_method.rb', events_yaml do
270
+ expect(InstanceMethod.new.say_kws(4, 5, kw1: 'one', kw2: 2, kw3: :three)).to eq('one2{:kw3=>:three}45')
271
+ end
272
+ end
273
+
232
274
  it 'hooks an instance method that takes a block argument' do
233
275
  events_yaml = <<~YAML
234
276
  ---
@@ -237,7 +279,7 @@ describe 'AppMap class Hooking', docker: false do
237
279
  :defined_class: InstanceMethod
238
280
  :method_id: say_block
239
281
  :path: spec/fixtures/hook/instance_method.rb
240
- :lineno: 20
282
+ :lineno: 24
241
283
  :static: false
242
284
  :parameters:
243
285
  - :name: :block
@@ -405,7 +447,7 @@ describe 'AppMap class Hooking', docker: false do
405
447
 
406
448
  # Verify the native extension works as expected
407
449
  expect(AppMap::Hook.singleton_method_owner_name(say_instance_defined)).to eq('SingletonMethod')
408
-
450
+
409
451
  expect(s.say_instance_defined).to eq('defined for an instance')
410
452
  end
411
453
  end
@@ -436,7 +478,7 @@ describe 'AppMap class Hooking', docker: false do
436
478
  expect(SingletonMethod::STRUCT_TEST.say_struct_singleton).to eq('singleton for a struct')
437
479
  end
438
480
  end
439
-
481
+
440
482
  it 'Reports exceptions' do
441
483
  events_yaml = <<~YAML
442
484
  ---
@@ -483,8 +525,8 @@ describe 'AppMap class Hooking', docker: false do
483
525
  :static: false
484
526
  :parameters:
485
527
  - :name: :args
486
- :class: Symbol
487
- :value: to_s
528
+ :class: Array
529
+ :value: "[:to_s]"
488
530
  :kind: :rest
489
531
  :receiver:
490
532
  :class: Class
@@ -531,8 +573,8 @@ describe 'AppMap class Hooking', docker: false do
531
573
  :static: false
532
574
  :parameters:
533
575
  - :name: :args
534
- :class: Symbol
535
- :value: to_s
576
+ :class: Array
577
+ :value: "[:to_s]"
536
578
  :kind: :rest
537
579
  :receiver:
538
580
  :class: Class
@@ -653,8 +695,8 @@ describe 'AppMap class Hooking', docker: false do
653
695
  :static: false
654
696
  :parameters:
655
697
  - :name: arg
656
- :class: String
657
- :value: string
698
+ :class: Array
699
+ :value: '["string"]'
658
700
  :kind: :rest
659
701
  :receiver:
660
702
  :class: Digest::SHA256
@@ -673,8 +715,8 @@ describe 'AppMap class Hooking', docker: false do
673
715
  :static: false
674
716
  :parameters:
675
717
  - :name: arg
676
- :class: String
677
- :value: string
718
+ :class: Array
719
+ :value: '["string"]'
678
720
  :kind: :rest
679
721
  :receiver:
680
722
  :class: Digest::SHA256
@@ -785,7 +827,7 @@ describe 'AppMap class Hooking', docker: false do
785
827
  :defined_class: InstanceMethod
786
828
  :method_id: say_the_time
787
829
  :path: spec/fixtures/hook/instance_method.rb
788
- :lineno: 24
830
+ :lineno: 28
789
831
  :static: false
790
832
  :parameters: []
791
833
  :receiver:
@@ -29,10 +29,10 @@ def run_cmd(*cmd, &failed)
29
29
  raise 'Command failed'
30
30
  end
31
31
 
32
- shared_context 'Rails app pg database' do
33
- before(:all) do
34
- raise 'you must set @fixure_dir' unless @fixture_dir
32
+ shared_context 'Rails app pg database' do |fixture_dir|
33
+ let(:fixture_dir) { fixture_dir }
35
34
 
35
+ before(:all) do
36
36
  print_pg_logs = lambda do
37
37
  logs, = run_cmd 'docker-compose logs pg'
38
38
  puts "docker-compose logs for pg:"
@@ -40,7 +40,7 @@ shared_context 'Rails app pg database' do
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
@@ -54,7 +54,7 @@ shared_context 'Rails app pg database' do
54
54
  after(:all) do
55
55
  if ENV['NOKILL'] != 'true'
56
56
  cmd = 'docker-compose down -v'
57
- run_cmd cmd, chdir: @fixture_dir
57
+ run_cmd cmd, chdir: fixture_dir
58
58
  end
59
59
  end
60
60
  end
@@ -1,43 +1,42 @@
1
1
  require 'rails_spec_helper'
2
2
 
3
3
  describe 'AppMap tracer via Railtie' do
4
- before(:all) { @fixture_dir = 'spec/fixtures/rails_users_app' }
5
- include_context 'Rails app pg database'
6
-
7
- let(:env) { {} }
4
+ include_context 'Rails app pg database', 'spec/fixtures/rails5_users_app' do
5
+ let(:env) { {} }
8
6
 
9
- let(:cmd) { %(docker-compose run --rm -e RAILS_ENV -e APPMAP app ./bin/rails r "puts Rails.configuration.appmap.enabled.inspect") }
10
- let(:command_capture2) do
11
- require 'open3'
12
- Open3.capture3(env, cmd, chdir: @fixture_dir).tap do |result|
13
- unless result[2] == 0
14
- $stderr.puts <<~END
15
- Failed to run rails_users_app container
16
- <<< Output:
17
- #{result[0]}
18
- #{result[1]}
19
- >>> End of output
20
- END
21
- raise 'Failed to run rails_users_app container'
7
+ let(:cmd) { %(docker-compose run --rm -e RAILS_ENV -e APPMAP app ./bin/rails r "puts Rails.configuration.appmap.enabled.inspect") }
8
+ let(:command_capture2) do
9
+ require 'open3'
10
+ Open3.capture3(env, cmd, chdir: fixture_dir).tap do |result|
11
+ unless result[2] == 0
12
+ warn <<~STDERR
13
+ Failed to run rails5_users_app container
14
+ <<< Output:
15
+ #{result[0]}
16
+ #{result[1]}
17
+ >>> End of output
18
+ STDERR
19
+ raise 'Failed to run rails5_users_app container'
20
+ end
22
21
  end
23
22
  end
24
- end
25
- let(:command_output) { command_capture2[0].strip }
26
- let(:command_result) { command_capture2[2] }
27
-
28
- it 'is disabled by default' do
29
- expect(command_output).to eq('nil')
30
- end
23
+ let(:command_output) { command_capture2[0].strip }
24
+ let(:command_result) { command_capture2[2] }
31
25
 
32
- describe 'with APPMAP=true' do
33
- let(:env) { { 'APPMAP' => 'true' } }
34
- it 'is enabled' do
35
- expect(command_output.split("\n")).to include('true')
26
+ it 'is disabled by default' do
27
+ expect(command_output).to eq('nil')
36
28
  end
37
- context 'and RAILS_ENV=test' do
38
- let(:env) { { 'APPMAP' => 'true', 'RAILS_ENV' => 'test' } }
39
- it 'is disabled' do
40
- expect(command_output).to eq('nil')
29
+
30
+ describe 'with APPMAP=true' do
31
+ let(:env) { { 'APPMAP' => 'true' } }
32
+ it 'is enabled' do
33
+ expect(command_output.split("\n")).to include('true')
34
+ end
35
+ context 'and RAILS_ENV=test' do
36
+ let(:env) { { 'APPMAP' => 'true', 'RAILS_ENV' => 'test' } }
37
+ it 'is disabled' do
38
+ expect(command_output).to eq('nil')
39
+ end
41
40
  end
42
41
  end
43
42
  end
@@ -1,75 +1,74 @@
1
1
  require 'rails_spec_helper'
2
2
 
3
3
  describe 'Record SQL queries in a Rails4 app' do
4
- before(:all) { @fixture_dir = 'spec/fixtures/rails4_users_app' }
5
- include_context 'Rails app pg database'
6
-
7
- around(:each) do |example|
8
- FileUtils.rm_rf tmpdir
9
- FileUtils.mkdir_p tmpdir
10
- cmd = "docker-compose run --rm -e ORM_MODULE=#{orm_module} -e APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:#{test_line_number}"
11
- run_cmd cmd, chdir: @fixture_dir
4
+ include_context 'Rails app pg database', 'spec/fixtures/rails4_users_app' do
5
+ around(:each) do |example|
6
+ FileUtils.rm_rf tmpdir
7
+ FileUtils.mkdir_p tmpdir
8
+ cmd = "docker-compose run --rm -e ORM_MODULE=#{orm_module} -e APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:#{test_line_number}"
9
+ run_cmd cmd, chdir: fixture_dir
12
10
 
13
- example.run
14
- end
11
+ example.run
12
+ end
13
+
14
+ let(:tmpdir) { "tmp/spec/record_sql_rails_pg_spec" }
15
+ let(:appmap) { JSON.parse(File.read(appmap_json)).to_yaml }
15
16
 
16
- let(:tmpdir) { "tmp/spec/record_sql_rails_pg_spec" }
17
- let(:appmap) { JSON.parse(File.read(appmap_json)).to_yaml }
17
+ context 'when running specs' do
18
+ let(:test_line_number) { 31 }
19
+ let(:orm_module) { 'activerecord' }
18
20
 
19
- context 'when running specs' do
20
- let(:test_line_number) { 31 }
21
- let(:orm_module) { 'activerecord' }
21
+ it { is_expected.to be }
22
+ end
22
23
 
23
- it { is_expected.to be }
24
- end
25
-
26
- context 'while creating a new record' do
27
- let(:test_line_number) { 8 }
28
- let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }
24
+ context 'while creating a new record' do
25
+ let(:test_line_number) { 8 }
26
+ let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }
29
27
 
30
- xcontext 'using Sequel ORM' do
31
- let(:orm_module) { 'sequel' }
32
- it 'detects the sql INSERT' do
33
- expect(appmap).to include(<<-SQL_QUERY.strip)
28
+ xcontext 'using Sequel ORM' do
29
+ let(:orm_module) { 'sequel' }
30
+ it 'detects the sql INSERT' do
31
+ expect(appmap).to include(<<-SQL_QUERY.strip)
34
32
  sql_query:
35
33
  sql: INSERT INTO "users" ("login") VALUES ('alice') RETURNING *
36
- SQL_QUERY
34
+ SQL_QUERY
35
+ end
37
36
  end
38
- end
39
- context 'using ActiveRecord ORM' do
40
- let(:orm_module) { 'activerecord' }
41
- it 'detects the sql INSERT' do
42
- expect(appmap).to include(<<-SQL_QUERY.strip)
37
+ context 'using ActiveRecord ORM' do
38
+ let(:orm_module) { 'activerecord' }
39
+ it 'detects the sql INSERT' do
40
+ expect(appmap).to include(<<-SQL_QUERY.strip)
43
41
  sql_query:
44
42
  sql: INSERT INTO "users" ("login", "created_at", "updated_at") VALUES ($1, $2,
45
43
  $3) RETURNING "id"
46
- SQL_QUERY
44
+ SQL_QUERY
45
+ end
47
46
  end
48
47
  end
49
- end
50
48
 
51
- context 'while listing records' do
52
- let(:test_line_number) { 23 }
53
- let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_GET_api_users_lists_the_users.appmap.json') }
49
+ context 'while listing records' do
50
+ let(:test_line_number) { 23 }
51
+ let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_GET_api_users_lists_the_users.appmap.json') }
54
52
 
55
- xcontext 'using Sequel ORM' do
56
- let(:orm_module) { 'sequel' }
57
- it 'detects the sql SELECT' do
58
- expect(appmap).to include(<<-SQL_QUERY.strip)
53
+ xcontext 'using Sequel ORM' do
54
+ let(:orm_module) { 'sequel' }
55
+ it 'detects the sql SELECT' do
56
+ expect(appmap).to include(<<-SQL_QUERY.strip)
59
57
  sql_query:
60
58
  sql: SELECT * FROM "users"
61
- SQL_QUERY
59
+ SQL_QUERY
62
60
 
63
- expect(appmap).to include('sql:')
61
+ expect(appmap).to include('sql:')
62
+ end
64
63
  end
65
- end
66
- context 'using ActiveRecord ORM' do
67
- let(:orm_module) { 'activerecord' }
68
- it 'detects the sql SELECT' do
69
- expect(appmap).to include(<<-SQL_QUERY.strip)
64
+ context 'using ActiveRecord ORM' do
65
+ let(:orm_module) { 'activerecord' }
66
+ it 'detects the sql SELECT' do
67
+ expect(appmap).to include(<<-SQL_QUERY.strip)
70
68
  sql_query:
71
69
  sql: SELECT "users".* FROM "users"
72
- SQL_QUERY
70
+ SQL_QUERY
71
+ end
73
72
  end
74
73
  end
75
74
  end