appmap 0.37.2 → 0.41.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -1
- data/.travis.yml +2 -23
- data/CHANGELOG.md +23 -0
- data/CONTRIBUTING.md +22 -0
- data/README.md +102 -54
- data/Rakefile +3 -3
- data/lib/appmap/class_map.rb +25 -8
- data/lib/appmap/config.rb +54 -26
- data/lib/appmap/hook.rb +18 -3
- data/lib/appmap/hook/method.rb +18 -12
- data/lib/appmap/rails/request_handler.rb +17 -3
- data/lib/appmap/railtie.rb +1 -5
- data/lib/appmap/trace.rb +18 -7
- data/lib/appmap/version.rb +2 -2
- data/spec/abstract_controller_base_spec.rb +125 -64
- data/spec/config_spec.rb +1 -0
- data/spec/fixtures/hook/exclude.rb +15 -0
- data/spec/fixtures/hook/labels.rb +6 -0
- data/spec/fixtures/rails5_users_app/Gemfile +3 -4
- data/spec/fixtures/rails5_users_app/app/controllers/users_controller.rb +8 -0
- data/spec/fixtures/rails5_users_app/appmap.yml +5 -1
- data/spec/fixtures/rails5_users_app/config/application.rb +2 -0
- data/spec/fixtures/rails5_users_app/config/routes.rb +1 -1
- data/spec/fixtures/rails5_users_app/spec/controllers/users_controller_api_spec.rb +1 -1
- data/spec/fixtures/rails5_users_app/spec/controllers/users_controller_spec.rb +27 -0
- data/spec/fixtures/rails6_users_app/Gemfile +3 -4
- data/spec/fixtures/rails6_users_app/app/controllers/users_controller.rb +8 -0
- data/spec/fixtures/rails6_users_app/appmap.yml +6 -1
- data/spec/fixtures/rails6_users_app/config/application.rb +2 -0
- data/spec/fixtures/rails6_users_app/config/routes.rb +1 -1
- data/spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb +1 -1
- data/spec/fixtures/rails6_users_app/spec/controllers/users_controller_spec.rb +27 -0
- data/spec/hook_spec.rb +69 -47
- data/spec/rails_spec_helper.rb +2 -2
- data/spec/record_sql_rails_pg_spec.rb +1 -1
- data/spec/rspec_feature_metadata_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- metadata +7 -68
- data/spec/abstract_controller4_base_spec.rb +0 -66
- data/spec/fixtures/rails4_users_app/.gitignore +0 -13
- data/spec/fixtures/rails4_users_app/.rbenv-gemsets +0 -2
- data/spec/fixtures/rails4_users_app/.ruby-version +0 -1
- data/spec/fixtures/rails4_users_app/Dockerfile +0 -30
- data/spec/fixtures/rails4_users_app/Dockerfile.pg +0 -3
- data/spec/fixtures/rails4_users_app/Gemfile +0 -77
- data/spec/fixtures/rails4_users_app/README.rdoc +0 -28
- data/spec/fixtures/rails4_users_app/Rakefile +0 -6
- data/spec/fixtures/rails4_users_app/app/assets/images/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/assets/javascripts/application.js +0 -16
- data/spec/fixtures/rails4_users_app/app/assets/stylesheets/application.css +0 -15
- data/spec/fixtures/rails4_users_app/app/controllers/api/users_controller.rb +0 -27
- data/spec/fixtures/rails4_users_app/app/controllers/application_controller.rb +0 -5
- data/spec/fixtures/rails4_users_app/app/controllers/concerns/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/controllers/health_controller.rb +0 -5
- data/spec/fixtures/rails4_users_app/app/controllers/users_controller.rb +0 -5
- data/spec/fixtures/rails4_users_app/app/helpers/application_helper.rb +0 -2
- data/spec/fixtures/rails4_users_app/app/mailers/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/models/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/models/concerns/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/models/user.rb +0 -18
- data/spec/fixtures/rails4_users_app/app/views/layouts/application.html.haml +0 -7
- data/spec/fixtures/rails4_users_app/app/views/users/index.html.haml +0 -7
- data/spec/fixtures/rails4_users_app/appmap.yml +0 -3
- data/spec/fixtures/rails4_users_app/bin/rails +0 -9
- data/spec/fixtures/rails4_users_app/bin/setup +0 -29
- data/spec/fixtures/rails4_users_app/bin/spring +0 -17
- data/spec/fixtures/rails4_users_app/config.ru +0 -4
- data/spec/fixtures/rails4_users_app/config/application.rb +0 -26
- data/spec/fixtures/rails4_users_app/config/boot.rb +0 -3
- data/spec/fixtures/rails4_users_app/config/database.yml +0 -18
- data/spec/fixtures/rails4_users_app/config/environment.rb +0 -5
- data/spec/fixtures/rails4_users_app/config/environments/development.rb +0 -41
- data/spec/fixtures/rails4_users_app/config/environments/production.rb +0 -79
- data/spec/fixtures/rails4_users_app/config/environments/test.rb +0 -42
- data/spec/fixtures/rails4_users_app/config/initializers/assets.rb +0 -11
- data/spec/fixtures/rails4_users_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/fixtures/rails4_users_app/config/initializers/cookies_serializer.rb +0 -3
- data/spec/fixtures/rails4_users_app/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/fixtures/rails4_users_app/config/initializers/inflections.rb +0 -16
- data/spec/fixtures/rails4_users_app/config/initializers/mime_types.rb +0 -4
- data/spec/fixtures/rails4_users_app/config/initializers/session_store.rb +0 -3
- data/spec/fixtures/rails4_users_app/config/initializers/to_time_preserves_timezone.rb +0 -10
- data/spec/fixtures/rails4_users_app/config/initializers/wrap_parameters.rb +0 -14
- data/spec/fixtures/rails4_users_app/config/locales/en.yml +0 -23
- data/spec/fixtures/rails4_users_app/config/routes.rb +0 -12
- data/spec/fixtures/rails4_users_app/config/secrets.yml +0 -22
- data/spec/fixtures/rails4_users_app/create_app +0 -23
- data/spec/fixtures/rails4_users_app/db/migrate/20191127112304_create_users.rb +0 -10
- data/spec/fixtures/rails4_users_app/db/schema.rb +0 -26
- data/spec/fixtures/rails4_users_app/db/seeds.rb +0 -7
- data/spec/fixtures/rails4_users_app/docker-compose.yml +0 -26
- data/spec/fixtures/rails4_users_app/lib/assets/.keep +0 -0
- data/spec/fixtures/rails4_users_app/lib/tasks/.keep +0 -0
- data/spec/fixtures/rails4_users_app/log/.keep +0 -0
- data/spec/fixtures/rails4_users_app/public/404.html +0 -67
- data/spec/fixtures/rails4_users_app/public/422.html +0 -67
- data/spec/fixtures/rails4_users_app/public/500.html +0 -66
- data/spec/fixtures/rails4_users_app/public/favicon.ico +0 -0
- data/spec/fixtures/rails4_users_app/public/robots.txt +0 -5
- data/spec/fixtures/rails4_users_app/spec/controllers/users_controller_api_spec.rb +0 -49
- data/spec/fixtures/rails4_users_app/spec/rails_helper.rb +0 -95
- data/spec/fixtures/rails4_users_app/spec/spec_helper.rb +0 -96
- data/spec/fixtures/rails4_users_app/test/fixtures/users.yml +0 -9
- data/spec/record_sql_rails4_pg_spec.rb +0 -75
@@ -1,95 +0,0 @@
|
|
1
|
-
STDERR.puts "rails4_users_app rails_helper"
|
2
|
-
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
3
|
-
require 'spec_helper'
|
4
|
-
ENV['RAILS_ENV'] ||= 'test'
|
5
|
-
|
6
|
-
require File.expand_path('../config/environment', __dir__)
|
7
|
-
|
8
|
-
# Prevent database truncation if the environment is production
|
9
|
-
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
10
|
-
require 'rspec/rails'
|
11
|
-
# Add additional requires below this line. Rails is not loaded until this point!
|
12
|
-
|
13
|
-
# The issue this hack works around is discussed here
|
14
|
-
# https://github.com/rails/rails/issues/34790, with the comment that
|
15
|
-
# it won't be fixed here:
|
16
|
-
# https://github.com/rails/rails/issues/34790#issuecomment-450036849
|
17
|
-
if RUBY_VERSION >= '2.6.0'
|
18
|
-
class ActionController::TestResponse < ActionDispatch::TestResponse
|
19
|
-
def recycle!
|
20
|
-
# hack to avoid MonitorMixin double-initialize error:
|
21
|
-
@mon_mutex_owner_object_id = nil
|
22
|
-
@mon_mutex = nil
|
23
|
-
initialize
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
require 'appmap/rspec'
|
30
|
-
|
31
|
-
# Requires supporting ruby files with custom matchers and macros, etc, in
|
32
|
-
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
33
|
-
# run as spec files by default. This means that files in spec/support that end
|
34
|
-
# in _spec.rb will both be required and run as specs, causing the specs to be
|
35
|
-
# run twice. It is recommended that you do not name files matching this glob to
|
36
|
-
# end with _spec.rb. You can configure this pattern with the --pattern
|
37
|
-
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
38
|
-
#
|
39
|
-
# The following line is provided for convenience purposes. It has the downside
|
40
|
-
# of increasing the boot-up time by auto-requiring all files in the support
|
41
|
-
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
42
|
-
# require only the support files necessary.
|
43
|
-
#
|
44
|
-
# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
|
45
|
-
|
46
|
-
# Checks for pending migrations and applies them before tests are run.
|
47
|
-
# If you are not using ActiveRecord, you can remove these lines.
|
48
|
-
begin
|
49
|
-
ActiveRecord::Migration.maintain_test_schema!
|
50
|
-
rescue ActiveRecord::PendingMigrationError => e
|
51
|
-
puts e.to_s.strip
|
52
|
-
exit 1
|
53
|
-
end
|
54
|
-
RSpec.configure do |config|
|
55
|
-
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
56
|
-
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
57
|
-
|
58
|
-
# RSpec Rails can automatically mix in different behaviours to your tests
|
59
|
-
# based on their file location, for example enabling you to call `get` and
|
60
|
-
# `post` in specs under `spec/controllers`.
|
61
|
-
#
|
62
|
-
# You can disable this behaviour by removing the line below, and instead
|
63
|
-
# explicitly tag your specs with their type, e.g.:
|
64
|
-
#
|
65
|
-
# RSpec.describe UsersController, :type => :controller do
|
66
|
-
# # ...
|
67
|
-
# end
|
68
|
-
#
|
69
|
-
# The different available types are documented in the features, such as in
|
70
|
-
# https://relishapp.com/rspec/rspec-rails/docs
|
71
|
-
config.infer_spec_type_from_file_location!
|
72
|
-
|
73
|
-
# Filter lines from Rails gems in backtraces.
|
74
|
-
config.filter_rails_from_backtrace!
|
75
|
-
# arbitrary gems may also be filtered via:
|
76
|
-
# config.filter_gems_from_backtrace("gem name")
|
77
|
-
|
78
|
-
|
79
|
-
config.before(:suite) do
|
80
|
-
DatabaseCleaner.strategy = :transaction
|
81
|
-
DatabaseCleaner.clean_with(:truncation)
|
82
|
-
end
|
83
|
-
|
84
|
-
config.around :each do |example|
|
85
|
-
# Enable the use of 'return' from a guard
|
86
|
-
-> {
|
87
|
-
return example.run unless %i[model controller].member?(example.metadata[:type])
|
88
|
-
|
89
|
-
DatabaseCleaner.cleaning do
|
90
|
-
example.run
|
91
|
-
end
|
92
|
-
}.call
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
@@ -1,96 +0,0 @@
|
|
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
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'rails_spec_helper'
|
2
|
-
|
3
|
-
describe 'Record SQL queries in a Rails4 app' do
|
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
|
10
|
-
|
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 }
|
16
|
-
|
17
|
-
context 'when running specs' do
|
18
|
-
let(:test_line_number) { 31 }
|
19
|
-
let(:orm_module) { 'activerecord' }
|
20
|
-
|
21
|
-
it { is_expected.to be }
|
22
|
-
end
|
23
|
-
|
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') }
|
27
|
-
|
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)
|
32
|
-
sql_query:
|
33
|
-
sql: INSERT INTO "users" ("login") VALUES ('alice') RETURNING *
|
34
|
-
SQL_QUERY
|
35
|
-
end
|
36
|
-
end
|
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)
|
41
|
-
sql_query:
|
42
|
-
sql: INSERT INTO "users" ("login", "created_at", "updated_at") VALUES ($1, $2,
|
43
|
-
$3) RETURNING "id"
|
44
|
-
SQL_QUERY
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
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') }
|
52
|
-
|
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)
|
57
|
-
sql_query:
|
58
|
-
sql: SELECT * FROM "users"
|
59
|
-
SQL_QUERY
|
60
|
-
|
61
|
-
expect(appmap).to include('sql:')
|
62
|
-
end
|
63
|
-
end
|
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)
|
68
|
-
sql_query:
|
69
|
-
sql: SELECT "users".* FROM "users"
|
70
|
-
SQL_QUERY
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|