appmap 0.37.0 → 0.37.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +1 -1
- data/.rubocop.yml +7 -0
- data/CHANGELOG.md +6 -0
- data/Rakefile +1 -1
- data/lib/appmap/event.rb +16 -1
- data/lib/appmap/rails/request_handler.rb +8 -1
- data/lib/appmap/version.rb +1 -1
- data/spec/abstract_controller4_base_spec.rb +27 -28
- data/spec/abstract_controller_base_spec.rb +43 -39
- data/spec/fixtures/hook/instance_method.rb +4 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/.dockerignore +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/.gitignore +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/.rspec +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/.ruby-version +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/Dockerfile +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/Dockerfile.pg +0 -0
- data/spec/fixtures/rails5_users_app/Gemfile +51 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/Rakefile +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/api/users_controller.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/application_controller.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/concerns/.keep +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/health_controller.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/users_controller.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/models/activerecord/user.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/models/concerns/.keep +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/models/sequel/user.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/views/layouts/application.html.haml +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/views/users/index.html.haml +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/appmap.yml +1 -1
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/appmap +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/byebug +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/gli +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/htmldiff +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/ldiff +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/nokogiri +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rackup +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rails +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rake +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rspec +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/ruby-parse +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/ruby-rewrite +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/sequel +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/setup +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/sprockets +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/thor +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/update +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config.ru +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/application.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/boot.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/credentials.yml.enc +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/database.yml +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environment.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environments/development.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environments/production.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environments/test.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/application_controller_renderer.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/cors.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/filter_parameter_logging.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/inflections.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/mime_types.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/record_button.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/wrap_parameters.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/locales/en.yml +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/routes.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/create_app +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/db/migrate/20190728211408_create_users.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/db/schema.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/docker-compose.yml +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/features/api_users.feature +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/features/support/env.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/features/support/hooks.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/features/support/steps.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/lib/tasks/.keep +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/log/.keep +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/public/robots.txt +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/controllers/users_controller_api_spec.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/models/user_spec.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/rails_helper.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/spec_helper.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/users_app/.gitignore +0 -0
- data/spec/fixtures/rails6_users_app/.dockerignore +1 -0
- data/spec/fixtures/rails6_users_app/.gitignore +39 -0
- data/spec/fixtures/rails6_users_app/.rspec +1 -0
- data/spec/fixtures/rails6_users_app/.ruby-version +1 -0
- data/spec/fixtures/rails6_users_app/Dockerfile +29 -0
- data/spec/fixtures/rails6_users_app/Dockerfile.pg +3 -0
- data/spec/fixtures/{rails_users_app → rails6_users_app}/Gemfile +0 -0
- data/spec/fixtures/rails6_users_app/Rakefile +6 -0
- data/spec/fixtures/rails6_users_app/app/controllers/api/users_controller.rb +27 -0
- data/spec/fixtures/rails6_users_app/app/controllers/application_controller.rb +2 -0
- data/spec/fixtures/rails6_users_app/app/controllers/concerns/.keep +0 -0
- data/spec/fixtures/rails6_users_app/app/controllers/health_controller.rb +5 -0
- data/spec/fixtures/rails6_users_app/app/controllers/users_controller.rb +5 -0
- data/spec/fixtures/rails6_users_app/app/models/activerecord/user.rb +18 -0
- data/spec/fixtures/rails6_users_app/app/models/concerns/.keep +0 -0
- data/spec/fixtures/rails6_users_app/app/models/sequel/user.rb +25 -0
- data/spec/fixtures/rails6_users_app/app/views/layouts/application.html.haml +7 -0
- data/spec/fixtures/rails6_users_app/app/views/users/index.html.haml +7 -0
- data/spec/fixtures/rails6_users_app/appmap.yml +3 -0
- data/spec/fixtures/rails6_users_app/bin/appmap +29 -0
- data/spec/fixtures/rails6_users_app/bin/byebug +29 -0
- data/spec/fixtures/rails6_users_app/bin/gli +29 -0
- data/spec/fixtures/rails6_users_app/bin/htmldiff +29 -0
- data/spec/fixtures/rails6_users_app/bin/ldiff +29 -0
- data/spec/fixtures/rails6_users_app/bin/nokogiri +29 -0
- data/spec/fixtures/rails6_users_app/bin/rackup +29 -0
- data/spec/fixtures/rails6_users_app/bin/rails +4 -0
- data/spec/fixtures/rails6_users_app/bin/rake +29 -0
- data/spec/fixtures/rails6_users_app/bin/rspec +29 -0
- data/spec/fixtures/rails6_users_app/bin/ruby-parse +29 -0
- data/spec/fixtures/rails6_users_app/bin/ruby-rewrite +29 -0
- data/spec/fixtures/rails6_users_app/bin/sequel +29 -0
- data/spec/fixtures/rails6_users_app/bin/setup +25 -0
- data/spec/fixtures/rails6_users_app/bin/sprockets +29 -0
- data/spec/fixtures/rails6_users_app/bin/thor +29 -0
- data/spec/fixtures/rails6_users_app/bin/update +25 -0
- data/spec/fixtures/rails6_users_app/config.ru +5 -0
- data/spec/fixtures/rails6_users_app/config/application.rb +51 -0
- data/spec/fixtures/rails6_users_app/config/boot.rb +3 -0
- data/spec/fixtures/rails6_users_app/config/credentials.yml.enc +1 -0
- data/spec/fixtures/rails6_users_app/config/database.yml +18 -0
- data/spec/fixtures/rails6_users_app/config/environment.rb +5 -0
- data/spec/fixtures/rails6_users_app/config/environments/development.rb +40 -0
- data/spec/fixtures/rails6_users_app/config/environments/production.rb +68 -0
- data/spec/fixtures/rails6_users_app/config/environments/test.rb +36 -0
- data/spec/fixtures/rails6_users_app/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/fixtures/rails6_users_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/fixtures/rails6_users_app/config/initializers/cors.rb +16 -0
- data/spec/fixtures/rails6_users_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/fixtures/rails6_users_app/config/initializers/inflections.rb +16 -0
- data/spec/fixtures/rails6_users_app/config/initializers/mime_types.rb +4 -0
- data/spec/fixtures/rails6_users_app/config/initializers/record_button.rb +3 -0
- data/spec/fixtures/rails6_users_app/config/initializers/wrap_parameters.rb +9 -0
- data/spec/fixtures/rails6_users_app/config/locales/en.yml +33 -0
- data/spec/fixtures/rails6_users_app/config/routes.rb +11 -0
- data/spec/fixtures/rails6_users_app/create_app +27 -0
- data/spec/fixtures/rails6_users_app/db/migrate/20190728211408_create_users.rb +9 -0
- data/spec/fixtures/rails6_users_app/db/schema.rb +23 -0
- data/spec/fixtures/rails6_users_app/docker-compose.yml +28 -0
- data/spec/fixtures/rails6_users_app/features/api_users.feature +13 -0
- data/spec/fixtures/rails6_users_app/features/support/env.rb +4 -0
- data/spec/fixtures/rails6_users_app/features/support/hooks.rb +11 -0
- data/spec/fixtures/rails6_users_app/features/support/steps.rb +18 -0
- data/spec/fixtures/rails6_users_app/lib/tasks/.keep +0 -0
- data/spec/fixtures/rails6_users_app/log/.keep +0 -0
- data/spec/fixtures/rails6_users_app/public/robots.txt +1 -0
- data/spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb +29 -0
- data/spec/fixtures/rails6_users_app/spec/models/user_spec.rb +39 -0
- data/spec/fixtures/rails6_users_app/spec/rails_helper.rb +66 -0
- data/spec/fixtures/rails6_users_app/spec/spec_helper.rb +96 -0
- data/spec/fixtures/rails6_users_app/users_app/.gitignore +20 -0
- data/spec/hook_spec.rb +56 -14
- data/spec/rails_spec_helper.rb +5 -5
- data/spec/railtie_spec.rb +31 -32
- data/spec/record_sql_rails4_pg_spec.rb +47 -48
- data/spec/record_sql_rails_pg_spec.rb +62 -63
- data/spec/remote_recording_spec.rb +90 -89
- data/spec/rspec_feature_metadata_spec.rb +17 -18
- metadata +144 -73
@@ -1,89 +1,88 @@
|
|
1
1
|
require 'rails_spec_helper'
|
2
2
|
|
3
3
|
describe 'SQL events' do
|
4
|
-
|
5
|
-
|
4
|
+
include_context 'Rails app pg database', 'spec/fixtures/rails5_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
|
6
10
|
|
7
|
-
|
8
|
-
|
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
|
12
|
-
|
13
|
-
example.run
|
14
|
-
end
|
11
|
+
example.run
|
12
|
+
end
|
15
13
|
|
16
|
-
|
14
|
+
let(:tmpdir) { "tmp/spec/record_sql_rails_pg_spec" }
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
16
|
+
describe 'fields' do
|
17
|
+
let(:test_line_number) { 8 }
|
18
|
+
let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }
|
19
|
+
let(:orm_module) { 'sequel' }
|
20
|
+
let(:appmap) { JSON.parse(File.read(appmap_json)) }
|
21
|
+
describe 'on a call event' do
|
22
|
+
let(:event) do
|
23
|
+
appmap['events'].find do |event|
|
24
|
+
event['event'] == 'call' &&
|
25
|
+
event.keys.include?('sql_query')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
it 'do not include function-only fields' do
|
29
|
+
expect(event.keys).to_not include('defined_class')
|
30
|
+
expect(event.keys).to_not include('method_id')
|
31
|
+
expect(event.keys).to_not include('path')
|
32
|
+
expect(event.keys).to_not include('lineno')
|
28
33
|
end
|
29
|
-
end
|
30
|
-
it 'do not include function-only fields' do
|
31
|
-
expect(event.keys).to_not include('defined_class')
|
32
|
-
expect(event.keys).to_not include('method_id')
|
33
|
-
expect(event.keys).to_not include('path')
|
34
|
-
expect(event.keys).to_not include('lineno')
|
35
34
|
end
|
36
35
|
end
|
37
|
-
end
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
describe 'in a Rails app' do
|
38
|
+
let(:appmap) { JSON.parse(File.read(appmap_json)).to_yaml }
|
39
|
+
context 'while creating a new record' do
|
40
|
+
let(:test_line_number) { 8 }
|
41
|
+
let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
context 'using Sequel ORM' do
|
44
|
+
let(:orm_module) { 'sequel' }
|
45
|
+
it 'detects the sql INSERT' do
|
46
|
+
expect(appmap).to include(<<-SQL_QUERY.strip)
|
49
47
|
sql_query:
|
50
48
|
sql: INSERT INTO "users" ("login") VALUES ('alice') RETURNING *
|
51
|
-
|
49
|
+
SQL_QUERY
|
50
|
+
end
|
52
51
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
expect(appmap).to include(<<-SQL_QUERY.strip)
|
52
|
+
context 'using ActiveRecord ORM' do
|
53
|
+
let(:orm_module) { 'activerecord' }
|
54
|
+
it 'detects the sql INSERT' do
|
55
|
+
expect(appmap).to include(<<-SQL_QUERY.strip)
|
58
56
|
sql_query:
|
59
57
|
sql: INSERT INTO "users" ("login") VALUES ($1) RETURNING "id"
|
60
|
-
|
58
|
+
SQL_QUERY
|
59
|
+
end
|
61
60
|
end
|
62
61
|
end
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
expect(appmap).to include(<<-SQL_QUERY.strip)
|
62
|
+
|
63
|
+
context 'while listing records' do
|
64
|
+
let(:test_line_number) { 23 }
|
65
|
+
let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_GET_api_users_lists_the_users.appmap.json') }
|
66
|
+
|
67
|
+
context 'using Sequel ORM' do
|
68
|
+
let(:orm_module) { 'sequel' }
|
69
|
+
it 'detects the sql SELECT' do
|
70
|
+
expect(appmap).to include(<<-SQL_QUERY.strip)
|
73
71
|
sql_query:
|
74
72
|
sql: SELECT * FROM "users"
|
75
|
-
|
76
|
-
|
77
|
-
|
73
|
+
SQL_QUERY
|
74
|
+
|
75
|
+
expect(appmap).to include('sql:')
|
76
|
+
end
|
78
77
|
end
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
expect(appmap).to include(<<-SQL_QUERY.strip)
|
78
|
+
context 'using ActiveRecord ORM' do
|
79
|
+
let(:orm_module) { 'activerecord' }
|
80
|
+
it 'detects the sql SELECT' do
|
81
|
+
expect(appmap).to include(<<-SQL_QUERY.strip)
|
84
82
|
sql_query:
|
85
83
|
sql: SELECT "users".* FROM "users"
|
86
|
-
|
84
|
+
SQL_QUERY
|
85
|
+
end
|
87
86
|
end
|
88
87
|
end
|
89
88
|
end
|
@@ -3,115 +3,116 @@ require 'net/http'
|
|
3
3
|
require 'socket'
|
4
4
|
|
5
5
|
describe 'remote recording', :order => :defined do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
port_cmd = 'docker-compose port app 3000'
|
17
|
-
port_out, = run_cmd port_cmd, chdir: @fixture_dir
|
18
|
-
@service_port = port_out.strip.split(':')[1]
|
19
|
-
|
20
|
-
service_running = false
|
21
|
-
retry_count = 0
|
22
|
-
uri = URI("http://localhost:#{@service_port}/health")
|
6
|
+
include_context 'Rails app pg database', 'spec/fixtures/rails5_users_app' do
|
7
|
+
before(:all) do
|
8
|
+
fixture_dir = 'spec/fixtures/rails5_users_app'
|
9
|
+
start_cmd = 'docker-compose up -d app'
|
10
|
+
run_cmd({ 'ORM_MODULE' => 'sequel', 'APPMAP' => 'true' }, start_cmd, chdir: fixture_dir)
|
11
|
+
Dir.chdir fixture_dir do
|
12
|
+
wait_for_container 'app'
|
13
|
+
end
|
23
14
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
15
|
+
port_cmd = 'docker-compose port app 3000'
|
16
|
+
port_out, = run_cmd port_cmd, chdir: fixture_dir
|
17
|
+
@service_port = port_out.strip.split(':')[1]
|
18
|
+
|
19
|
+
service_running = false
|
20
|
+
retry_count = 0
|
21
|
+
uri = URI("http://localhost:#{@service_port}/health")
|
22
|
+
|
23
|
+
until service_running
|
24
|
+
sleep(0.25)
|
25
|
+
begin
|
26
|
+
res = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
27
|
+
http.request(Net::HTTP::Get.new(uri))
|
28
|
+
end
|
29
|
+
|
30
|
+
status = res.response.code.to_i
|
31
|
+
service_running = true if status >= 200 && status < 300
|
32
|
+
|
33
|
+
# give up after a certain error threshold is met
|
34
|
+
# we don't want to wait forever if there's an unrecoverable issue
|
35
|
+
raise 'gave up waiting on fixture service' if (retry_count += 1) == 10
|
36
|
+
rescue Errno::ETIMEDOUT, Errno::ECONNRESET, EOFError
|
37
|
+
$stderr.print('.')
|
29
38
|
end
|
30
|
-
|
31
|
-
status = res.response.code.to_i
|
32
|
-
service_running = true if status >= 200 && status < 300
|
33
|
-
|
34
|
-
# give up after a certain error threshold is met
|
35
|
-
# we don't want to wait forever if there's an unrecoverable issue
|
36
|
-
raise 'gave up waiting on fixture service' if (retry_count += 1) == 10
|
37
|
-
rescue Errno::ETIMEDOUT, Errno::ECONNRESET, EOFError
|
38
|
-
$stderr.print('.')
|
39
39
|
end
|
40
40
|
end
|
41
|
-
end
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
def json_body(res)
|
43
|
+
JSON.parse(res.body).deep_symbolize_keys
|
44
|
+
end
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
after(:all) do
|
47
|
+
fixture_dir = 'spec/fixtures/rails5_users_app'
|
48
|
+
run_cmd 'docker-compose rm -fs app', chdir: fixture_dir
|
49
|
+
end
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
let(:service_address) { URI("http://localhost:#{@service_port}") }
|
52
|
+
let(:users_path) { '/users' }
|
53
|
+
let(:record_path) { '/_appmap/record' }
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
it 'returns the recording status' do
|
56
|
+
res = Net::HTTP.start(service_address.hostname, service_address.port) { |http|
|
57
|
+
http.request(Net::HTTP::Get.new(record_path))
|
58
|
+
}
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
expect(res).to be_a(Net::HTTPOK)
|
61
|
+
expect(res['Content-Type']).to eq('application/json')
|
62
|
+
expect(json_body(res)).to eq(enabled: false)
|
63
|
+
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
it 'starts a new recording session' do
|
66
|
+
res = Net::HTTP.start(service_address.hostname, service_address.port) { |http|
|
67
|
+
http.request(Net::HTTP::Post.new(record_path))
|
68
|
+
}
|
69
69
|
|
70
|
-
|
71
|
-
|
70
|
+
expect(res).to be_a(Net::HTTPOK)
|
71
|
+
end
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
it 'reflects the recording status' do
|
74
|
+
res = Net::HTTP.start(service_address.hostname, service_address.port) { |http|
|
75
|
+
http.request(Net::HTTP::Get.new(record_path))
|
76
|
+
}
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
expect(res).to be_a(Net::HTTPOK)
|
79
|
+
expect(res['Content-Type']).to eq('application/json')
|
80
|
+
expect(json_body(res)).to eq(enabled: true)
|
81
|
+
end
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
83
|
+
it 'fails to start a new recording session while recording is already active' do
|
84
|
+
res = Net::HTTP.start(service_address.hostname, service_address.port) { |http|
|
85
|
+
http.request(Net::HTTP::Post.new(record_path))
|
86
|
+
}
|
87
87
|
|
88
|
-
|
89
|
-
|
88
|
+
expect(res).to be_a(Net::HTTPConflict)
|
89
|
+
end
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
91
|
+
it 'stops recording' do
|
92
|
+
# Generate some events
|
93
|
+
Net::HTTP.start(service_address.hostname, service_address.port) { |http|
|
94
|
+
http.request(Net::HTTP::Get.new(users_path) )
|
95
|
+
}
|
96
96
|
|
97
|
-
|
98
|
-
|
99
|
-
|
97
|
+
res = Net::HTTP.start(service_address.hostname, service_address.port) { |http|
|
98
|
+
http.request(Net::HTTP::Delete.new(record_path))
|
99
|
+
}
|
100
100
|
|
101
|
-
|
102
|
-
|
101
|
+
expect(res).to be_a(Net::HTTPOK)
|
102
|
+
expect(res['Content-Type']).to eq('application/json')
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
104
|
+
data = json_body(res)
|
105
|
+
expect(data[:metadata]).to be_truthy
|
106
|
+
expect(data[:classMap].length).to be > 0
|
107
|
+
expect(data[:events].length).to be > 0
|
108
|
+
end
|
109
109
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
110
|
+
it 'fails to stop recording if there is no active recording session' do
|
111
|
+
res = Net::HTTP.start(service_address.hostname, service_address.port) { |http|
|
112
|
+
http.request(Net::HTTP::Delete.new(record_path))
|
113
|
+
}
|
114
114
|
|
115
|
-
|
115
|
+
expect(res).to be_a(Net::HTTPNotFound)
|
116
|
+
end
|
116
117
|
end
|
117
118
|
end
|
@@ -3,30 +3,29 @@
|
|
3
3
|
require 'rails_spec_helper'
|
4
4
|
|
5
5
|
describe 'RSpec feature and feature group metadata' do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
cmd = "docker-compose run --rm -e APPMAP=true -v #{File.absolute_path(tmpdir).shellescape}:/app/tmp app ./bin/rspec spec/models/user_spec.rb"
|
13
|
-
run_cmd cmd, chdir: @fixture_dir
|
6
|
+
include_examples 'Rails app pg database', 'spec/fixtures/rails5_users_app' do
|
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).shellescape}:/app/tmp app ./bin/rspec spec/models/user_spec.rb"
|
11
|
+
run_cmd cmd, chdir: fixture_dir
|
14
12
|
|
15
|
-
|
16
|
-
|
13
|
+
example.run
|
14
|
+
end
|
17
15
|
|
18
|
-
|
19
|
-
|
16
|
+
let(:tmpdir) { 'tmp/spec/RSpec feature and feature group metadata' }
|
17
|
+
let(:appmap_json) { File.join(tmpdir, %(appmap/rspec/User_creation_creates_charles.appmap.json)) }
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
describe do
|
20
|
+
it 'are recorded in the appmap' do
|
21
|
+
expect(File).to exist(appmap_json)
|
22
|
+
appmap = JSON.parse(File.read(appmap_json)).to_yaml
|
25
23
|
|
26
|
-
|
24
|
+
expect(appmap).to include(<<-METADATA.strip)
|
27
25
|
feature: Create a user
|
28
26
|
feature_group: User
|
29
|
-
|
27
|
+
METADATA
|
28
|
+
end
|
30
29
|
end
|
31
30
|
end
|
32
31
|
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.37.
|
4
|
+
version: 0.37.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Gilpin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -460,77 +460,148 @@ files:
|
|
460
460
|
- spec/fixtures/rails4_users_app/spec/rails_helper.rb
|
461
461
|
- spec/fixtures/rails4_users_app/spec/spec_helper.rb
|
462
462
|
- spec/fixtures/rails4_users_app/test/fixtures/users.yml
|
463
|
-
- spec/fixtures/
|
464
|
-
- spec/fixtures/
|
465
|
-
- spec/fixtures/
|
466
|
-
- spec/fixtures/
|
467
|
-
- spec/fixtures/
|
468
|
-
- spec/fixtures/
|
469
|
-
- spec/fixtures/
|
470
|
-
- spec/fixtures/
|
471
|
-
- spec/fixtures/
|
472
|
-
- spec/fixtures/
|
473
|
-
- spec/fixtures/
|
474
|
-
- spec/fixtures/
|
475
|
-
- spec/fixtures/
|
476
|
-
- spec/fixtures/
|
477
|
-
- spec/fixtures/
|
478
|
-
- spec/fixtures/
|
479
|
-
- spec/fixtures/
|
480
|
-
- spec/fixtures/
|
481
|
-
- spec/fixtures/
|
482
|
-
- spec/fixtures/
|
483
|
-
- spec/fixtures/
|
484
|
-
- spec/fixtures/
|
485
|
-
- spec/fixtures/
|
486
|
-
- spec/fixtures/
|
487
|
-
- spec/fixtures/
|
488
|
-
- spec/fixtures/
|
489
|
-
- spec/fixtures/
|
490
|
-
- spec/fixtures/
|
491
|
-
- spec/fixtures/
|
492
|
-
- spec/fixtures/
|
493
|
-
- spec/fixtures/
|
494
|
-
- spec/fixtures/
|
495
|
-
- spec/fixtures/
|
496
|
-
- spec/fixtures/
|
497
|
-
- spec/fixtures/
|
498
|
-
- spec/fixtures/
|
499
|
-
- spec/fixtures/
|
500
|
-
- spec/fixtures/
|
501
|
-
- spec/fixtures/
|
502
|
-
- spec/fixtures/
|
503
|
-
- spec/fixtures/
|
504
|
-
- spec/fixtures/
|
505
|
-
- spec/fixtures/
|
506
|
-
- spec/fixtures/
|
507
|
-
- spec/fixtures/
|
508
|
-
- spec/fixtures/
|
509
|
-
- spec/fixtures/
|
510
|
-
- spec/fixtures/
|
511
|
-
- spec/fixtures/
|
512
|
-
- spec/fixtures/
|
513
|
-
- spec/fixtures/
|
514
|
-
- spec/fixtures/
|
515
|
-
- spec/fixtures/
|
516
|
-
- spec/fixtures/
|
517
|
-
- spec/fixtures/
|
518
|
-
- spec/fixtures/
|
519
|
-
- spec/fixtures/
|
520
|
-
- spec/fixtures/
|
521
|
-
- spec/fixtures/
|
522
|
-
- spec/fixtures/
|
523
|
-
- spec/fixtures/
|
524
|
-
- spec/fixtures/
|
525
|
-
- spec/fixtures/
|
526
|
-
- spec/fixtures/
|
527
|
-
- spec/fixtures/
|
528
|
-
- spec/fixtures/
|
529
|
-
- spec/fixtures/
|
530
|
-
- spec/fixtures/
|
531
|
-
- spec/fixtures/
|
532
|
-
- spec/fixtures/
|
533
|
-
- spec/fixtures/
|
463
|
+
- spec/fixtures/rails5_users_app/.dockerignore
|
464
|
+
- spec/fixtures/rails5_users_app/.gitignore
|
465
|
+
- spec/fixtures/rails5_users_app/.rspec
|
466
|
+
- spec/fixtures/rails5_users_app/.ruby-version
|
467
|
+
- spec/fixtures/rails5_users_app/Dockerfile
|
468
|
+
- spec/fixtures/rails5_users_app/Dockerfile.pg
|
469
|
+
- spec/fixtures/rails5_users_app/Gemfile
|
470
|
+
- spec/fixtures/rails5_users_app/Rakefile
|
471
|
+
- spec/fixtures/rails5_users_app/app/controllers/api/users_controller.rb
|
472
|
+
- spec/fixtures/rails5_users_app/app/controllers/application_controller.rb
|
473
|
+
- spec/fixtures/rails5_users_app/app/controllers/concerns/.keep
|
474
|
+
- spec/fixtures/rails5_users_app/app/controllers/health_controller.rb
|
475
|
+
- spec/fixtures/rails5_users_app/app/controllers/users_controller.rb
|
476
|
+
- spec/fixtures/rails5_users_app/app/models/activerecord/user.rb
|
477
|
+
- spec/fixtures/rails5_users_app/app/models/concerns/.keep
|
478
|
+
- spec/fixtures/rails5_users_app/app/models/sequel/user.rb
|
479
|
+
- spec/fixtures/rails5_users_app/app/views/layouts/application.html.haml
|
480
|
+
- spec/fixtures/rails5_users_app/app/views/users/index.html.haml
|
481
|
+
- spec/fixtures/rails5_users_app/appmap.yml
|
482
|
+
- spec/fixtures/rails5_users_app/bin/appmap
|
483
|
+
- spec/fixtures/rails5_users_app/bin/byebug
|
484
|
+
- spec/fixtures/rails5_users_app/bin/gli
|
485
|
+
- spec/fixtures/rails5_users_app/bin/htmldiff
|
486
|
+
- spec/fixtures/rails5_users_app/bin/ldiff
|
487
|
+
- spec/fixtures/rails5_users_app/bin/nokogiri
|
488
|
+
- spec/fixtures/rails5_users_app/bin/rackup
|
489
|
+
- spec/fixtures/rails5_users_app/bin/rails
|
490
|
+
- spec/fixtures/rails5_users_app/bin/rake
|
491
|
+
- spec/fixtures/rails5_users_app/bin/rspec
|
492
|
+
- spec/fixtures/rails5_users_app/bin/ruby-parse
|
493
|
+
- spec/fixtures/rails5_users_app/bin/ruby-rewrite
|
494
|
+
- spec/fixtures/rails5_users_app/bin/sequel
|
495
|
+
- spec/fixtures/rails5_users_app/bin/setup
|
496
|
+
- spec/fixtures/rails5_users_app/bin/sprockets
|
497
|
+
- spec/fixtures/rails5_users_app/bin/thor
|
498
|
+
- spec/fixtures/rails5_users_app/bin/update
|
499
|
+
- spec/fixtures/rails5_users_app/config.ru
|
500
|
+
- spec/fixtures/rails5_users_app/config/application.rb
|
501
|
+
- spec/fixtures/rails5_users_app/config/boot.rb
|
502
|
+
- spec/fixtures/rails5_users_app/config/credentials.yml.enc
|
503
|
+
- spec/fixtures/rails5_users_app/config/database.yml
|
504
|
+
- spec/fixtures/rails5_users_app/config/environment.rb
|
505
|
+
- spec/fixtures/rails5_users_app/config/environments/development.rb
|
506
|
+
- spec/fixtures/rails5_users_app/config/environments/production.rb
|
507
|
+
- spec/fixtures/rails5_users_app/config/environments/test.rb
|
508
|
+
- spec/fixtures/rails5_users_app/config/initializers/application_controller_renderer.rb
|
509
|
+
- spec/fixtures/rails5_users_app/config/initializers/backtrace_silencers.rb
|
510
|
+
- spec/fixtures/rails5_users_app/config/initializers/cors.rb
|
511
|
+
- spec/fixtures/rails5_users_app/config/initializers/filter_parameter_logging.rb
|
512
|
+
- spec/fixtures/rails5_users_app/config/initializers/inflections.rb
|
513
|
+
- spec/fixtures/rails5_users_app/config/initializers/mime_types.rb
|
514
|
+
- spec/fixtures/rails5_users_app/config/initializers/record_button.rb
|
515
|
+
- spec/fixtures/rails5_users_app/config/initializers/wrap_parameters.rb
|
516
|
+
- spec/fixtures/rails5_users_app/config/locales/en.yml
|
517
|
+
- spec/fixtures/rails5_users_app/config/routes.rb
|
518
|
+
- spec/fixtures/rails5_users_app/create_app
|
519
|
+
- spec/fixtures/rails5_users_app/db/migrate/20190728211408_create_users.rb
|
520
|
+
- spec/fixtures/rails5_users_app/db/schema.rb
|
521
|
+
- spec/fixtures/rails5_users_app/docker-compose.yml
|
522
|
+
- spec/fixtures/rails5_users_app/features/api_users.feature
|
523
|
+
- spec/fixtures/rails5_users_app/features/support/env.rb
|
524
|
+
- spec/fixtures/rails5_users_app/features/support/hooks.rb
|
525
|
+
- spec/fixtures/rails5_users_app/features/support/steps.rb
|
526
|
+
- spec/fixtures/rails5_users_app/lib/tasks/.keep
|
527
|
+
- spec/fixtures/rails5_users_app/log/.keep
|
528
|
+
- spec/fixtures/rails5_users_app/public/robots.txt
|
529
|
+
- spec/fixtures/rails5_users_app/spec/controllers/users_controller_api_spec.rb
|
530
|
+
- spec/fixtures/rails5_users_app/spec/models/user_spec.rb
|
531
|
+
- spec/fixtures/rails5_users_app/spec/rails_helper.rb
|
532
|
+
- spec/fixtures/rails5_users_app/spec/spec_helper.rb
|
533
|
+
- spec/fixtures/rails5_users_app/users_app/.gitignore
|
534
|
+
- spec/fixtures/rails6_users_app/.dockerignore
|
535
|
+
- spec/fixtures/rails6_users_app/.gitignore
|
536
|
+
- spec/fixtures/rails6_users_app/.rspec
|
537
|
+
- spec/fixtures/rails6_users_app/.ruby-version
|
538
|
+
- spec/fixtures/rails6_users_app/Dockerfile
|
539
|
+
- spec/fixtures/rails6_users_app/Dockerfile.pg
|
540
|
+
- spec/fixtures/rails6_users_app/Gemfile
|
541
|
+
- spec/fixtures/rails6_users_app/Rakefile
|
542
|
+
- spec/fixtures/rails6_users_app/app/controllers/api/users_controller.rb
|
543
|
+
- spec/fixtures/rails6_users_app/app/controllers/application_controller.rb
|
544
|
+
- spec/fixtures/rails6_users_app/app/controllers/concerns/.keep
|
545
|
+
- spec/fixtures/rails6_users_app/app/controllers/health_controller.rb
|
546
|
+
- spec/fixtures/rails6_users_app/app/controllers/users_controller.rb
|
547
|
+
- spec/fixtures/rails6_users_app/app/models/activerecord/user.rb
|
548
|
+
- spec/fixtures/rails6_users_app/app/models/concerns/.keep
|
549
|
+
- spec/fixtures/rails6_users_app/app/models/sequel/user.rb
|
550
|
+
- spec/fixtures/rails6_users_app/app/views/layouts/application.html.haml
|
551
|
+
- spec/fixtures/rails6_users_app/app/views/users/index.html.haml
|
552
|
+
- spec/fixtures/rails6_users_app/appmap.yml
|
553
|
+
- spec/fixtures/rails6_users_app/bin/appmap
|
554
|
+
- spec/fixtures/rails6_users_app/bin/byebug
|
555
|
+
- spec/fixtures/rails6_users_app/bin/gli
|
556
|
+
- spec/fixtures/rails6_users_app/bin/htmldiff
|
557
|
+
- spec/fixtures/rails6_users_app/bin/ldiff
|
558
|
+
- spec/fixtures/rails6_users_app/bin/nokogiri
|
559
|
+
- spec/fixtures/rails6_users_app/bin/rackup
|
560
|
+
- spec/fixtures/rails6_users_app/bin/rails
|
561
|
+
- spec/fixtures/rails6_users_app/bin/rake
|
562
|
+
- spec/fixtures/rails6_users_app/bin/rspec
|
563
|
+
- spec/fixtures/rails6_users_app/bin/ruby-parse
|
564
|
+
- spec/fixtures/rails6_users_app/bin/ruby-rewrite
|
565
|
+
- spec/fixtures/rails6_users_app/bin/sequel
|
566
|
+
- spec/fixtures/rails6_users_app/bin/setup
|
567
|
+
- spec/fixtures/rails6_users_app/bin/sprockets
|
568
|
+
- spec/fixtures/rails6_users_app/bin/thor
|
569
|
+
- spec/fixtures/rails6_users_app/bin/update
|
570
|
+
- spec/fixtures/rails6_users_app/config.ru
|
571
|
+
- spec/fixtures/rails6_users_app/config/application.rb
|
572
|
+
- spec/fixtures/rails6_users_app/config/boot.rb
|
573
|
+
- spec/fixtures/rails6_users_app/config/credentials.yml.enc
|
574
|
+
- spec/fixtures/rails6_users_app/config/database.yml
|
575
|
+
- spec/fixtures/rails6_users_app/config/environment.rb
|
576
|
+
- spec/fixtures/rails6_users_app/config/environments/development.rb
|
577
|
+
- spec/fixtures/rails6_users_app/config/environments/production.rb
|
578
|
+
- spec/fixtures/rails6_users_app/config/environments/test.rb
|
579
|
+
- spec/fixtures/rails6_users_app/config/initializers/application_controller_renderer.rb
|
580
|
+
- spec/fixtures/rails6_users_app/config/initializers/backtrace_silencers.rb
|
581
|
+
- spec/fixtures/rails6_users_app/config/initializers/cors.rb
|
582
|
+
- spec/fixtures/rails6_users_app/config/initializers/filter_parameter_logging.rb
|
583
|
+
- spec/fixtures/rails6_users_app/config/initializers/inflections.rb
|
584
|
+
- spec/fixtures/rails6_users_app/config/initializers/mime_types.rb
|
585
|
+
- spec/fixtures/rails6_users_app/config/initializers/record_button.rb
|
586
|
+
- spec/fixtures/rails6_users_app/config/initializers/wrap_parameters.rb
|
587
|
+
- spec/fixtures/rails6_users_app/config/locales/en.yml
|
588
|
+
- spec/fixtures/rails6_users_app/config/routes.rb
|
589
|
+
- spec/fixtures/rails6_users_app/create_app
|
590
|
+
- spec/fixtures/rails6_users_app/db/migrate/20190728211408_create_users.rb
|
591
|
+
- spec/fixtures/rails6_users_app/db/schema.rb
|
592
|
+
- spec/fixtures/rails6_users_app/docker-compose.yml
|
593
|
+
- spec/fixtures/rails6_users_app/features/api_users.feature
|
594
|
+
- spec/fixtures/rails6_users_app/features/support/env.rb
|
595
|
+
- spec/fixtures/rails6_users_app/features/support/hooks.rb
|
596
|
+
- spec/fixtures/rails6_users_app/features/support/steps.rb
|
597
|
+
- spec/fixtures/rails6_users_app/lib/tasks/.keep
|
598
|
+
- spec/fixtures/rails6_users_app/log/.keep
|
599
|
+
- spec/fixtures/rails6_users_app/public/robots.txt
|
600
|
+
- spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb
|
601
|
+
- spec/fixtures/rails6_users_app/spec/models/user_spec.rb
|
602
|
+
- spec/fixtures/rails6_users_app/spec/rails_helper.rb
|
603
|
+
- spec/fixtures/rails6_users_app/spec/spec_helper.rb
|
604
|
+
- spec/fixtures/rails6_users_app/users_app/.gitignore
|
534
605
|
- spec/hook_spec.rb
|
535
606
|
- spec/open_spec.rb
|
536
607
|
- spec/rails_spec_helper.rb
|