appmap 0.37.0 → 0.37.2

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fba24ecdb42c951741292378419eef430a56cc16816df46a14b2ae3e318f8f94
4
- data.tar.gz: 67ff27467f72322c5a8514c90b0a6039e3fd1268dba103dea3b832eda95ac317
3
+ metadata.gz: 0211b21334945f6786d150fdf1a0dea8a062cbc2d59c4b347f72555232ec6480
4
+ data.tar.gz: ac2785471ed35210ba1c3801e8a7d186adb99d9b9369c24eb2c9f4d41a352e33
5
5
  SHA512:
6
- metadata.gz: 1823304c2733b46470481fd731a1f4650a80e769d96b47dbcdb0e5763e59930d6754068b4cf0729f9f748c55109575f3c8146b09030741fccfafd06cd45669b9
7
- data.tar.gz: bbebe31041ed1720dc54b9522e4c6baac3b27d8d77be0622315657d0fa5b355c3e12474aa756811a6d747b563999c6e76206805c1392a015f92c6b863e8eeda0
6
+ metadata.gz: d5049f8c464b5f6e6afd7567fcfe62d481c70b7db6d473f93a832763e4352c04b6d2cff3d3d03a452f82033f4220cb821f36152c003794c7adba89432a2b513a
7
+ data.tar.gz: 631f8ab86e132e45c1b95b667d7789b870eab393293d62c7e1f77daf3cf3f9a5c7174e913fa0bc20ec92a87f88f278bee69f41c6b2c14d166b1745df71321d0b
@@ -1,5 +1,5 @@
1
1
  vendor
2
2
  node_modules
3
- spec/fixtures/rails_users_app
3
+ spec/fixtures/rails*_users_app
4
4
  spec/fixtures/rack_users_app
5
5
 
@@ -1,6 +1,9 @@
1
1
  AllCops:
2
2
  NewCops: enable
3
3
 
4
+ Layout/CaseIndentation:
5
+ EnforcedStyle: end
6
+
4
7
  Layout/SpaceInsideArrayLiteralBrackets:
5
8
  Enabled: false
6
9
 
@@ -11,6 +14,10 @@ Layout/HeredocIndentation:
11
14
  Layout/LineLength:
12
15
  Max: 120
13
16
 
17
+ Metrics/BlockLength:
18
+ ExcludedMethods:
19
+ - it
20
+
14
21
  Style/MultilineBlockChain:
15
22
  Enabled: false
16
23
 
@@ -1,3 +1,9 @@
1
+ # v0.37.2
2
+ * Fix ParameterFilter deprecation warning.
3
+
4
+ # v0.37.1
5
+ * Fix parameter mapping with keyword and rest arguments.
6
+
1
7
  # v0.37.0
2
8
  * Capture method source and comment.
3
9
 
data/Rakefile CHANGED
@@ -19,7 +19,7 @@ namespace 'gem' do
19
19
  end
20
20
 
21
21
  RUBY_VERSIONS=%w[2.5 2.6]
22
- FIXTURE_APPS=%w[rack_users_app rails_users_app rails4_users_app]
22
+ FIXTURE_APPS=%w[rack_users_app rails6_users_app rails5_users_app rails4_users_app]
23
23
 
24
24
  def run_cmd(*cmd)
25
25
  $stderr.puts "Running: #{cmd}"
@@ -89,10 +89,25 @@ module AppMap
89
89
  else
90
90
  mc.path = [ defined_class, static ? '.' : '#', method.name ].join
91
91
  end
92
+
93
+ # Check if the method has key parameters. If there are any they'll always be last.
94
+ # If yes, then extract it from arguments.
95
+ has_key = [[:dummy], *method.parameters].last.first.to_s.start_with?('key') && arguments[-1].is_a?(Hash)
96
+ kwargs = has_key && arguments[-1].dup || {}
97
+
92
98
  mc.parameters = method.parameters.map.with_index do |method_param, idx|
93
99
  param_type, param_name = method_param
94
100
  param_name ||= 'arg'
95
- value = arguments[idx]
101
+ value = case param_type
102
+ when :keyrest
103
+ kwargs
104
+ when /^key/
105
+ kwargs.delete param_name
106
+ when :rest
107
+ arguments[idx..(has_key ? -2 : -1)]
108
+ else
109
+ arguments[idx]
110
+ end
96
111
  {
97
112
  name: param_name,
98
113
  class: value.class.name,
@@ -14,7 +14,14 @@ module AppMap
14
14
 
15
15
  @request_method = request.request_method
16
16
  @path_info = request.path_info.split('?')[0]
17
- @params = ActionDispatch::Http::ParameterFilter.new(::Rails.application.config.filter_parameters).filter(request.params)
17
+ # ActionDispatch::Http::ParameterFilter is deprecated
18
+ parameter_filter_cls = \
19
+ if defined?(ActiveSupport::ParameterFilter)
20
+ ActiveSupport::ParameterFilter
21
+ else
22
+ ActionDispatch::Http::ParameterFilter
23
+ end
24
+ @params = parameter_filter_cls.new(::Rails.application.config.filter_parameters).filter(request.params)
18
25
  end
19
26
 
20
27
  def to_h
@@ -3,7 +3,7 @@
3
3
  module AppMap
4
4
  URL = 'https://github.com/applandinc/appmap-ruby'
5
5
 
6
- VERSION = '0.37.0'
6
+ VERSION = '0.37.2'
7
7
 
8
8
  APPMAP_FORMAT_VERSION = '1.3'
9
9
  end
@@ -1,52 +1,50 @@
1
1
  require 'rails_spec_helper'
2
2
 
3
3
  describe 'AbstractControllerBase' do
4
- before(:all) { @fixture_dir = 'spec/fixtures/rails4_users_app' }
5
- include_examples '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 APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:8"
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 APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:8"
9
+ run_cmd cmd, chdir: fixture_dir
12
10
 
13
- example.run
14
- end
11
+ example.run
12
+ end
15
13
 
16
- let(:tmpdir) { 'tmp/spec/AbstractControllerBase' }
17
- let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }
14
+ let(:tmpdir) { 'tmp/spec/AbstractControllerBase' }
15
+ let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }
18
16
 
19
- describe 'testing with rspec' do
20
- it 'Message fields are recorded in the appmap' do
21
- expect(File).to exist(appmap_json)
22
- appmap = JSON.parse(File.read(appmap_json)).to_yaml
17
+ describe 'testing with rspec' do
18
+ it 'Message fields are recorded in the appmap' do
19
+ expect(File).to exist(appmap_json)
20
+ appmap = JSON.parse(File.read(appmap_json)).to_yaml
23
21
 
24
- expect(appmap).to include(<<-MESSAGE.strip)
22
+ expect(appmap).to include(<<-MESSAGE.strip)
25
23
  message:
26
24
  - name: login
27
25
  class: String
28
26
  value: alice
29
27
  object_id:
30
- MESSAGE
28
+ MESSAGE
31
29
 
32
- expect(appmap).to include(<<-MESSAGE.strip)
30
+ expect(appmap).to include(<<-MESSAGE.strip)
33
31
  - name: password
34
32
  class: String
35
33
  value: "[FILTERED]"
36
34
  object_id:
37
- MESSAGE
35
+ MESSAGE
38
36
 
39
- expect(appmap).to include(<<-SERVER_REQUEST.strip)
37
+ expect(appmap).to include(<<-SERVER_REQUEST.strip)
40
38
  http_server_request:
41
39
  request_method: POST
42
40
  path_info: "/api/users"
43
- SERVER_REQUEST
44
- end
45
- it 'Properly captures method parameters in the appmap' do
46
- expect(File).to exist(appmap_json)
47
- appmap = JSON.parse(File.read(appmap_json)).to_yaml
41
+ SERVER_REQUEST
42
+ end
43
+ it 'Properly captures method parameters in the appmap' do
44
+ expect(File).to exist(appmap_json)
45
+ appmap = JSON.parse(File.read(appmap_json)).to_yaml
48
46
 
49
- expect(appmap).to match(<<-CREATE_CALL.strip)
47
+ expect(appmap).to match(<<-CREATE_CALL.strip)
50
48
  event: call
51
49
  thread_id: .*
52
50
  defined_class: Api::UsersController
@@ -61,7 +59,8 @@ describe 'AbstractControllerBase' do
61
59
  value: '{"login"=>"alice"}'
62
60
  kind: req
63
61
  receiver:
64
- CREATE_CALL
62
+ CREATE_CALL
63
+ end
65
64
  end
66
65
  end
67
66
  end
@@ -1,63 +1,62 @@
1
1
  require 'rails_spec_helper'
2
2
 
3
3
  describe 'AbstractControllerBase' do
4
- before(:all) { @fixture_dir = 'spec/fixtures/rails_users_app' }
5
- include_context 'Rails app pg database'
4
+ shared_examples 'rails version' do |rails_major_version|
5
+ include_context 'Rails app pg database', "spec/fixtures/rails#{rails_major_version}_users_app" do
6
+ around(:each) do |example|
7
+ FileUtils.rm_rf tmpdir
8
+ FileUtils.mkdir_p tmpdir
9
+ cmd = "docker-compose run --rm -e APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:8"
10
+ run_cmd cmd, chdir: fixture_dir
6
11
 
7
- around(:each) do |example|
8
- FileUtils.rm_rf tmpdir
9
- FileUtils.mkdir_p tmpdir
10
- cmd = "docker-compose run --rm -e APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:8"
11
- run_cmd cmd, chdir: @fixture_dir
12
+ example.run
13
+ end
12
14
 
13
- example.run
14
- end
15
-
16
- let(:tmpdir) { 'tmp/spec/AbstractControllerBase' }
17
- let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }
15
+ let(:tmpdir) { 'tmp/spec/AbstractControllerBase' }
16
+ let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }
18
17
 
19
- describe 'testing with rspec' do
20
- it 'inventory file is printed' do
21
- expect(File).to exist(File.join(tmpdir, 'appmap/rspec/Inventory.appmap.json'))
22
- end
18
+ describe 'testing with rspec' do
19
+ it 'inventory file is printed' do
20
+ expect(File).to exist(File.join(tmpdir, 'appmap/rspec/Inventory.appmap.json'))
21
+ end
23
22
 
24
- it 'message fields are recorded in the appmap' do
25
- expect(File).to exist(appmap_json)
26
- appmap = JSON.parse(File.read(appmap_json)).to_yaml
23
+ it 'message fields are recorded in the appmap' do
24
+ expect(File).to exist(appmap_json)
25
+ appmap = JSON.parse(File.read(appmap_json)).to_yaml
27
26
 
28
- expect(appmap).to include(<<-MESSAGE.strip)
27
+ expect(appmap).to include(<<-MESSAGE.strip)
29
28
  message:
30
29
  - name: login
31
30
  class: String
32
31
  value: alice
33
32
  object_id:
34
- MESSAGE
33
+ MESSAGE
35
34
 
36
- expect(appmap).to include(<<-MESSAGE.strip)
35
+ expect(appmap).to include(<<-MESSAGE.strip)
37
36
  - name: password
38
37
  class: String
39
38
  value: "[FILTERED]"
40
39
  object_id:
41
- MESSAGE
40
+ MESSAGE
42
41
 
43
- expect(appmap).to include(<<-SERVER_REQUEST.strip)
42
+ expect(appmap).to include(<<-SERVER_REQUEST.strip)
44
43
  http_server_request:
45
44
  request_method: POST
46
45
  path_info: "/api/users"
47
- SERVER_REQUEST
46
+ SERVER_REQUEST
48
47
 
49
- expect(appmap).to include(<<-SERVER_RESPONSE.strip)
48
+ expect(appmap).to include(<<-SERVER_RESPONSE.strip)
50
49
  http_server_response:
51
50
  status: 201
52
51
  mime_type: application/json; charset=utf-8
53
- SERVER_RESPONSE
54
- end
52
+ SERVER_RESPONSE
53
+ end
55
54
 
56
- it 'properly captures method parameters in the appmap' do
57
- expect(File).to exist(appmap_json)
58
- appmap = JSON.parse(File.read(appmap_json)).to_yaml
55
+ it 'properly captures method parameters in the appmap' do
56
+ expect(File).to exist(appmap_json)
57
+ appmap = JSON.parse(File.read(appmap_json)).to_yaml
59
58
 
60
- expect(appmap).to match(<<-CREATE_CALL.strip)
59
+ expect(appmap).to match(<<-CREATE_CALL.strip)
61
60
  event: call
62
61
  thread_id: .*
63
62
  defined_class: Api::UsersController
@@ -72,14 +71,19 @@ describe 'AbstractControllerBase' do
72
71
  value: '{"login"=>"alice"}'
73
72
  kind: req
74
73
  receiver:
75
- CREATE_CALL
76
- end
74
+ CREATE_CALL
75
+ end
77
76
 
78
- it 'returns a minimal event' do
79
- expect(File).to exist(appmap_json)
80
- appmap = JSON.parse(File.read(appmap_json))
81
- event = appmap['events'].find { |event| event['event'] == 'return' && event['return_value'] }
82
- expect(event.keys).to eq(%w[id event thread_id parent_id elapsed return_value])
77
+ it 'returns a minimal event' do
78
+ expect(File).to exist(appmap_json)
79
+ appmap = JSON.parse(File.read(appmap_json))
80
+ event = appmap['events'].find { |event| event['event'] == 'return' && event['return_value'] }
81
+ expect(event.keys).to eq(%w[id event thread_id parent_id elapsed return_value])
82
+ end
83
+ end
83
84
  end
84
85
  end
86
+
87
+ it_behaves_like 'rails version', '5'
88
+ it_behaves_like 'rails version', '6'
85
89
  end
@@ -17,6 +17,10 @@ class InstanceMethod
17
17
  kw.to_s
18
18
  end
19
19
 
20
+ def say_kws(*args, kw1:, kw2: 'kw2', **kws)
21
+ [kw1, kw2, kws, args].join
22
+ end
23
+
20
24
  def say_block(&block)
21
25
  yield
22
26
  end
@@ -0,0 +1,51 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ gem 'rails', '~> 6'
5
+
6
+ gem 'haml-rails'
7
+
8
+ gem 'activerecord', require: false
9
+ gem 'pg'
10
+ gem 'sequel', '= 5.20.0', require: false
11
+ gem 'sequel-rails', require: false
12
+ gem 'sequel_secure_password', require: false
13
+
14
+ appmap_path = \
15
+ # Support debugging inside the container with volume-mounted source
16
+ if File.directory?('/src/appmap-ruby')
17
+ '/src/appmap-ruby'
18
+ elsif File.exist?('../../../appmap.gemspec')
19
+ '../../..'
20
+ end
21
+
22
+ if appmap_path
23
+ # Set the branch parameter, so that 'bundle config local.appmap' will work
24
+ appmap_branch = Dir.chdir appmap_path do
25
+ `git rev-parse --abbrev-ref HEAD`.strip
26
+ end
27
+ end
28
+
29
+ appmap_options = \
30
+ if appmap_path && appmap_branch
31
+ { git: appmap_path, branch: appmap_branch }
32
+ elsif appmap_path
33
+ { path: appmap_path }
34
+ else
35
+ {}
36
+ end.merge(require: %w[appmap appmap/railtie])
37
+
38
+ gem 'appmap', appmap_options
39
+
40
+ group :development, :test do
41
+ gem 'cucumber-rails', require: false
42
+ gem 'rspec-rails'
43
+ # Required for Sequel, since without ActiveRecord, the Rails transactional fixture support
44
+ # isn't activated.
45
+ gem 'database_cleaner'
46
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
47
+ gem 'pry-byebug'
48
+ end
49
+
50
+ group :development do
51
+ end
@@ -1,3 +1,3 @@
1
- name: rails_users_app
1
+ name: rails5_users_app
2
2
  packages:
3
3
  - path: app