appmap 0.41.0 → 0.43.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -0
- data/README.md +32 -6
- data/lib/appmap.rb +5 -0
- data/lib/appmap/command/record.rb +1 -1
- data/lib/appmap/config.rb +16 -12
- data/lib/appmap/event.rb +32 -4
- data/lib/appmap/hook.rb +17 -2
- data/lib/appmap/hook/method.rb +1 -1
- data/lib/appmap/middleware/remote_recording.rb +1 -1
- data/lib/appmap/minitest.rb +17 -14
- data/lib/appmap/rails/request_handler.rb +41 -10
- data/lib/appmap/rspec.rb +13 -78
- data/lib/appmap/version.rb +1 -1
- data/spec/abstract_controller_base_spec.rb +67 -22
- data/spec/fixtures/rails5_users_app/Gemfile +7 -3
- data/spec/fixtures/rails5_users_app/app/controllers/api/users_controller.rb +2 -0
- data/spec/fixtures/rails5_users_app/app/controllers/users_controller.rb +9 -1
- data/spec/fixtures/rails5_users_app/config/application.rb +2 -0
- data/spec/fixtures/rails5_users_app/create_app +8 -2
- data/spec/fixtures/rails5_users_app/docker-compose.yml +3 -0
- data/spec/fixtures/rails5_users_app/spec/controllers/users_controller_api_spec.rb +16 -3
- data/spec/fixtures/rails5_users_app/spec/controllers/users_controller_spec.rb +2 -2
- data/spec/fixtures/rails5_users_app/spec/models/user_spec.rb +2 -12
- data/spec/fixtures/rails5_users_app/spec/rails_helper.rb +3 -9
- data/spec/fixtures/rails6_users_app/Gemfile +5 -4
- data/spec/fixtures/rails6_users_app/app/controllers/api/users_controller.rb +1 -0
- data/spec/fixtures/rails6_users_app/app/controllers/users_controller.rb +9 -1
- data/spec/fixtures/rails6_users_app/config/application.rb +2 -0
- data/spec/fixtures/rails6_users_app/create_app +8 -2
- data/spec/fixtures/rails6_users_app/docker-compose.yml +3 -0
- data/spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb +16 -3
- data/spec/fixtures/rails6_users_app/spec/controllers/users_controller_spec.rb +2 -2
- data/spec/fixtures/rails6_users_app/spec/models/user_spec.rb +2 -12
- data/spec/fixtures/rails6_users_app/spec/rails_helper.rb +3 -9
- data/spec/record_sql_rails_pg_spec.rb +1 -1
- data/spec/spec_helper.rb +6 -0
- data/test/fixtures/gem_test/appmap.yml +1 -1
- data/test/fixtures/gem_test/test/parser_test.rb +12 -0
- data/test/fixtures/rspec_recorder/spec/decorated_hello_spec.rb +3 -3
- data/test/fixtures/rspec_recorder/spec/plain_hello_spec.rb +1 -1
- data/test/gem_test.rb +4 -4
- data/test/minitest_test.rb +1 -2
- data/test/rspec_test.rb +1 -7
- metadata +3 -4
- data/spec/rspec_feature_metadata_spec.rb +0 -31
- data/test/fixtures/gem_test/test/to_param_test.rb +0 -14
@@ -4,7 +4,7 @@ require 'rack/test'
|
|
4
4
|
RSpec.describe UsersController, type: :controller do
|
5
5
|
render_views
|
6
6
|
|
7
|
-
describe 'GET /users'
|
7
|
+
describe 'GET /users' do
|
8
8
|
before do
|
9
9
|
User.create login: 'alice'
|
10
10
|
end
|
@@ -14,7 +14,7 @@ RSpec.describe UsersController, type: :controller do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
describe 'GET /users/:login'
|
17
|
+
describe 'GET /users/:login' do
|
18
18
|
before do
|
19
19
|
User.create login: 'alice'
|
20
20
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe User
|
3
|
+
describe User do
|
4
4
|
# TODO: appmap/rspec doesn't handle shared_examples_for 100% correctly yet.
|
5
5
|
# In my tests, only one of these two tests will be emitted as an appmap.
|
6
6
|
shared_examples_for 'creates the user' do |username|
|
@@ -11,17 +11,7 @@ describe User, feature_group: 'User', appmap: true do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
describe 'creation'
|
15
|
-
context 'using shared_examples_for' do
|
16
|
-
# AppMap.
|
17
|
-
# context "with username 'alice'" do
|
18
|
-
# it_should_behave_like 'creates the user', 'alice'
|
19
|
-
# end
|
20
|
-
# context "with username 'bob'" do
|
21
|
-
# it_should_behave_like 'creates the user', 'bob'
|
22
|
-
# end
|
23
|
-
end
|
24
|
-
|
14
|
+
describe 'creation' do
|
25
15
|
# So, instead of shared_examples_for, let's go with a simple method
|
26
16
|
# containing the assertions. The method can be called from within an example.
|
27
17
|
def save_and_verify
|
@@ -45,7 +45,6 @@ RSpec.configure do |config|
|
|
45
45
|
# arbitrary gems may also be filtered via:
|
46
46
|
# config.filter_gems_from_backtrace("gem name")
|
47
47
|
|
48
|
-
|
49
48
|
DatabaseCleaner.allow_remote_database_url = true
|
50
49
|
|
51
50
|
config.before(:suite) do
|
@@ -54,13 +53,8 @@ RSpec.configure do |config|
|
|
54
53
|
end
|
55
54
|
|
56
55
|
config.around :each do |example|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
DatabaseCleaner.cleaning do
|
62
|
-
example.run
|
63
|
-
end
|
64
|
-
}.call
|
56
|
+
DatabaseCleaner.cleaning do
|
57
|
+
example.run
|
58
|
+
end
|
65
59
|
end
|
66
60
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
3
|
|
4
|
-
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
5
4
|
gem 'rails', '~> 6'
|
6
5
|
|
7
6
|
gem 'haml-rails'
|
@@ -40,12 +39,14 @@ group :development, :test do
|
|
40
39
|
gem 'appmap', appmap_options
|
41
40
|
gem 'cucumber-rails', require: false
|
42
41
|
gem 'rspec-rails'
|
43
|
-
# Required for Sequel, since without ActiveRecord, the Rails transactional fixture support
|
44
|
-
# isn't activated.
|
45
|
-
gem 'database_cleaner'
|
46
42
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
47
43
|
gem 'pry-byebug'
|
48
44
|
end
|
49
45
|
|
46
|
+
group :test do
|
47
|
+
gem 'database_cleaner-active_record', require: false
|
48
|
+
gem 'database_cleaner-sequel', require: false
|
49
|
+
end
|
50
|
+
|
50
51
|
group :development do
|
51
52
|
end
|
@@ -4,7 +4,15 @@ class UsersController < ApplicationController
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def show
|
7
|
-
|
7
|
+
find_user = lambda do |id|
|
8
|
+
if User.respond_to?(:[])
|
9
|
+
User[login: id]
|
10
|
+
else
|
11
|
+
User.find_by_login!(id)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
if (@user = find_user.(params[:id]))
|
8
16
|
render plain: @user
|
9
17
|
else
|
10
18
|
render plain: 'Not found', status: 404
|
@@ -15,8 +15,10 @@ case orm_module
|
|
15
15
|
when 'sequel'
|
16
16
|
require 'sequel-rails'
|
17
17
|
require 'sequel_secure_password'
|
18
|
+
require 'database_cleaner-sequel' if Rails.env.test?
|
18
19
|
when 'activerecord'
|
19
20
|
require 'active_record/railtie'
|
21
|
+
require 'database_cleaner-active_record' if Rails.env.test?
|
20
22
|
end
|
21
23
|
|
22
24
|
require 'appmap/railtie' if defined?(AppMap)
|
@@ -16,11 +16,17 @@ if [[ $? != 0 ]]; then
|
|
16
16
|
exit 1
|
17
17
|
fi
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
# Required for migrations
|
20
|
+
export ORM_MODULE=sequel
|
21
21
|
|
22
|
+
set +e
|
23
|
+
psql -h pg -U postgres -c "drop database if exists app_development"
|
24
|
+
psql -h pg -U postgres -c "drop database if exists app_test"
|
22
25
|
set -e
|
23
26
|
|
27
|
+
psql -h pg -U postgres -c "create database app_development"
|
28
|
+
psql -h pg -U postgres -c "create database app_test"
|
29
|
+
|
24
30
|
RAILS_ENV=development ./bin/rake db:migrate
|
25
31
|
RAILS_ENV=test ./bin/rake db:migrate
|
26
32
|
|
@@ -1,13 +1,19 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
require 'rack/test'
|
3
3
|
|
4
|
-
RSpec.describe Api::UsersController,
|
5
|
-
describe 'POST /api/users'
|
4
|
+
RSpec.describe Api::UsersController, type: :controller do
|
5
|
+
describe 'POST /api/users' do
|
6
6
|
describe 'with required parameters' do
|
7
7
|
it 'creates a user' do
|
8
8
|
post :create, params: { login: 'alice', password: 'foobar' }
|
9
9
|
expect(response.status).to eq(201)
|
10
10
|
end
|
11
|
+
describe 'with object-style parameters' do
|
12
|
+
it 'creates a user' do
|
13
|
+
post :create, params: { user: { login: 'alice', password: 'foobar' } }
|
14
|
+
expect(response.status).to eq(201)
|
15
|
+
end
|
16
|
+
end
|
11
17
|
end
|
12
18
|
describe 'with a missing parameter' do
|
13
19
|
it 'reports error 422' do
|
@@ -16,7 +22,7 @@ RSpec.describe Api::UsersController, feature_group: 'Users', type: :controller,
|
|
16
22
|
end
|
17
23
|
end
|
18
24
|
end
|
19
|
-
describe 'GET /api/users'
|
25
|
+
describe 'GET /api/users' do
|
20
26
|
before do
|
21
27
|
post :create, params: { login: 'alice' }
|
22
28
|
end
|
@@ -25,5 +31,12 @@ RSpec.describe Api::UsersController, feature_group: 'Users', type: :controller,
|
|
25
31
|
users = JSON.parse(response.body)
|
26
32
|
expect(users.map { |r| r['login'] }).to include('alice')
|
27
33
|
end
|
34
|
+
describe 'with a custom header' do
|
35
|
+
it 'lists the users' do
|
36
|
+
request.headers['X-Sandwich'] = 'turkey'
|
37
|
+
get :index, params: {}
|
38
|
+
expect(response.status).to eq(200)
|
39
|
+
end
|
40
|
+
end
|
28
41
|
end
|
29
42
|
end
|
@@ -4,7 +4,7 @@ require 'rack/test'
|
|
4
4
|
RSpec.describe UsersController, type: :controller do
|
5
5
|
render_views
|
6
6
|
|
7
|
-
describe 'GET /users'
|
7
|
+
describe 'GET /users' do
|
8
8
|
before do
|
9
9
|
User.create login: 'alice'
|
10
10
|
end
|
@@ -14,7 +14,7 @@ RSpec.describe UsersController, type: :controller do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
describe 'GET /users/:login'
|
17
|
+
describe 'GET /users/:login' do
|
18
18
|
before do
|
19
19
|
User.create login: 'alice'
|
20
20
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe User
|
3
|
+
describe User do
|
4
4
|
# TODO: appmap/rspec doesn't handle shared_examples_for 100% correctly yet.
|
5
5
|
# In my tests, only one of these two tests will be emitted as an appmap.
|
6
6
|
shared_examples_for 'creates the user' do |username|
|
@@ -11,17 +11,7 @@ describe User, feature_group: 'User', appmap: true do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
describe 'creation'
|
15
|
-
context 'using shared_examples_for' do
|
16
|
-
# AppMap.
|
17
|
-
# context "with username 'alice'" do
|
18
|
-
# it_should_behave_like 'creates the user', 'alice'
|
19
|
-
# end
|
20
|
-
# context "with username 'bob'" do
|
21
|
-
# it_should_behave_like 'creates the user', 'bob'
|
22
|
-
# end
|
23
|
-
end
|
24
|
-
|
14
|
+
describe 'creation' do
|
25
15
|
# So, instead of shared_examples_for, let's go with a simple method
|
26
16
|
# containing the assertions. The method can be called from within an example.
|
27
17
|
def save_and_verify
|
@@ -45,7 +45,6 @@ RSpec.configure do |config|
|
|
45
45
|
# arbitrary gems may also be filtered via:
|
46
46
|
# config.filter_gems_from_backtrace("gem name")
|
47
47
|
|
48
|
-
|
49
48
|
DatabaseCleaner.allow_remote_database_url = true
|
50
49
|
|
51
50
|
config.before(:suite) do
|
@@ -54,13 +53,8 @@ RSpec.configure do |config|
|
|
54
53
|
end
|
55
54
|
|
56
55
|
config.around :each do |example|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
DatabaseCleaner.cleaning do
|
62
|
-
example.run
|
63
|
-
end
|
64
|
-
}.call
|
56
|
+
DatabaseCleaner.cleaning do
|
57
|
+
example.run
|
58
|
+
end
|
65
59
|
end
|
66
60
|
end
|
@@ -61,7 +61,7 @@ describe 'SQL events' do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
context 'while listing records' do
|
64
|
-
let(:test_line_number) {
|
64
|
+
let(:test_line_number) { 29 }
|
65
65
|
let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_GET_api_users_lists_the_users.appmap.json') }
|
66
66
|
|
67
67
|
context 'using Sequel ORM' do
|
data/spec/spec_helper.rb
CHANGED
@@ -14,3 +14,9 @@ require 'appmap'
|
|
14
14
|
RSpec.configure do |config|
|
15
15
|
config.example_status_persistence_file_path = "tmp/rspec_failed_examples.txt"
|
16
16
|
end
|
17
|
+
|
18
|
+
# Re-run the Rails specs without re-generating the data. This is useful for efficiently enhancing and
|
19
|
+
# debugging the test itself.
|
20
|
+
def use_existing_data?
|
21
|
+
ENV['USE_EXISTING_DATA'] == 'true'
|
22
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'appmap/minitest'
|
5
|
+
require 'minitest/autorun'
|
6
|
+
require 'parser/current'
|
7
|
+
|
8
|
+
class ParserTest < ::Minitest::Test
|
9
|
+
def test_parser
|
10
|
+
Parser::CurrentRuby.parse(File.read(__FILE__))
|
11
|
+
end
|
12
|
+
end
|
@@ -2,7 +2,7 @@ require 'rspec'
|
|
2
2
|
require 'appmap/rspec'
|
3
3
|
require 'hello'
|
4
4
|
|
5
|
-
describe Hello
|
5
|
+
describe Hello do
|
6
6
|
before do
|
7
7
|
# Trick appmap-ruby into thinking we're a Rails app.
|
8
8
|
stub_const('Rails', double('rails', version: 'fake.0'))
|
@@ -11,11 +11,11 @@ describe Hello, feature_group: 'Saying hello' do
|
|
11
11
|
# The order of these examples is important. The tests check the
|
12
12
|
# appmap for 'says hello', and we want another example to get run
|
13
13
|
# before it.
|
14
|
-
it 'does not say goodbye'
|
14
|
+
it 'does not say goodbye' do
|
15
15
|
expect(Hello.new.say_hello).not_to eq('Goodbye!')
|
16
16
|
end
|
17
17
|
|
18
|
-
it 'says hello'
|
18
|
+
it 'says hello' do
|
19
19
|
expect(Hello.new.say_hello).to eq('Hello!')
|
20
20
|
end
|
21
21
|
end
|
data/test/gem_test.rb
CHANGED
@@ -19,14 +19,14 @@ class MinitestTest < Minitest::Test
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_record_gem
|
22
|
-
perform_gem_test '
|
23
|
-
appmap_file = 'tmp/appmap/minitest/
|
22
|
+
perform_gem_test 'parser' do
|
23
|
+
appmap_file = 'tmp/appmap/minitest/Parser_parser.appmap.json'
|
24
24
|
appmap = JSON.parse(File.read(appmap_file))
|
25
25
|
events = appmap['events']
|
26
26
|
assert_equal 2, events.size
|
27
27
|
assert_equal 'call', events.first['event']
|
28
|
-
assert_equal '
|
29
|
-
assert_equal "#{Gem.loaded_specs['
|
28
|
+
assert_equal 'default_parser', events.first['method_id']
|
29
|
+
assert_equal "#{Gem.loaded_specs['parser'].gem_dir}/lib/parser/base.rb", events.first['path']
|
30
30
|
assert_equal 'return', events.second['event']
|
31
31
|
assert_equal 1, events.second['parent_id']
|
32
32
|
end
|
data/test/minitest_test.rb
CHANGED
@@ -30,9 +30,8 @@ class MinitestTest < Minitest::Test
|
|
30
30
|
assert_equal 'minitest_recorder', metadata['app']
|
31
31
|
assert_equal 'minitest', metadata['recorder']['name']
|
32
32
|
assert_equal 'ruby', metadata['language']['name']
|
33
|
-
assert_equal 'Hello', metadata['feature_group']
|
34
|
-
assert_equal 'hello', metadata['feature']
|
35
33
|
assert_equal 'Hello hello', metadata['name']
|
34
|
+
assert_equal 'test/hello_test.rb:9', metadata['source_location']
|
36
35
|
end
|
37
36
|
end
|
38
37
|
end
|
data/test/rspec_test.rb
CHANGED
@@ -28,8 +28,6 @@ class RSpecTest < Minitest::Test
|
|
28
28
|
assert_includes appmap.keys, 'metadata'
|
29
29
|
metadata = appmap['metadata']
|
30
30
|
assert_equal 'Inventory', metadata['name']
|
31
|
-
assert_includes metadata.keys, 'labels'
|
32
|
-
assert_equal metadata['labels'], %w[inventory]
|
33
31
|
end
|
34
32
|
end
|
35
33
|
|
@@ -42,9 +40,8 @@ class RSpecTest < Minitest::Test
|
|
42
40
|
assert_equal AppMap::APPMAP_FORMAT_VERSION, appmap['version']
|
43
41
|
assert_includes appmap.keys, 'metadata'
|
44
42
|
metadata = appmap['metadata']
|
45
|
-
assert_equal 'Saying hello', metadata['feature_group']
|
46
|
-
assert_equal 'Speak hello', metadata['feature']
|
47
43
|
assert_equal 'Hello says hello', metadata['name']
|
44
|
+
assert_equal 'spec/decorated_hello_spec.rb', metadata['source_location']
|
48
45
|
assert_includes metadata.keys, 'client'
|
49
46
|
assert_equal({ name: 'appmap', url: AppMap::URL, version: AppMap::VERSION }.stringify_keys, metadata['client'])
|
50
47
|
assert_includes metadata.keys, 'recorder'
|
@@ -63,8 +60,6 @@ class RSpecTest < Minitest::Test
|
|
63
60
|
appmap = JSON.parse(File.read(appmap_file))
|
64
61
|
assert_includes appmap.keys, 'metadata'
|
65
62
|
metadata = appmap['metadata']
|
66
|
-
assert_equal 'Hello', metadata['feature_group']
|
67
|
-
assert_equal 'Hello', metadata['feature']
|
68
63
|
assert_equal 'Hello says hello', metadata['name']
|
69
64
|
end
|
70
65
|
end
|
@@ -76,7 +71,6 @@ class RSpecTest < Minitest::Test
|
|
76
71
|
appmap = JSON.parse(File.read(appmap_file))
|
77
72
|
assert_includes appmap.keys, 'metadata'
|
78
73
|
metadata = appmap['metadata']
|
79
|
-
assert_equal %w[hello speak], metadata['labels'].sort
|
80
74
|
end
|
81
75
|
end
|
82
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.43.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Gilpin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -548,7 +548,6 @@ files:
|
|
548
548
|
- spec/railtie_spec.rb
|
549
549
|
- spec/record_sql_rails_pg_spec.rb
|
550
550
|
- spec/remote_recording_spec.rb
|
551
|
-
- spec/rspec_feature_metadata_spec.rb
|
552
551
|
- spec/spec_helper.rb
|
553
552
|
- spec/util_spec.rb
|
554
553
|
- test/cli_test.rb
|
@@ -573,7 +572,7 @@ files:
|
|
573
572
|
- test/fixtures/cucumber_recorder/lib/hello.rb
|
574
573
|
- test/fixtures/gem_test/Gemfile
|
575
574
|
- test/fixtures/gem_test/appmap.yml
|
576
|
-
- test/fixtures/gem_test/test/
|
575
|
+
- test/fixtures/gem_test/test/parser_test.rb
|
577
576
|
- test/fixtures/minitest_recorder/Gemfile
|
578
577
|
- test/fixtures/minitest_recorder/appmap.yml
|
579
578
|
- test/fixtures/minitest_recorder/lib/hello.rb
|