appmap 0.31.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.dockerignore +5 -0
- data/.gitignore +17 -0
- data/.rubocop.yml +27 -0
- data/.ruby-version +1 -0
- data/.travis.yml +44 -0
- data/CHANGELOG.md +199 -0
- data/Dockerfile.appmap +5 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +300 -0
- data/Rakefile +132 -0
- data/appmap.gemspec +44 -0
- data/appmap.yml +8 -0
- data/examples/install.rb +76 -0
- data/examples/mock_webapp/Gemfile +1 -0
- data/examples/mock_webapp/appmap.yml +2 -0
- data/examples/mock_webapp/exe/mock_webapp_request +12 -0
- data/examples/mock_webapp/lib/mock_webapp/controller.rb +23 -0
- data/examples/mock_webapp/lib/mock_webapp/request.rb +12 -0
- data/examples/mock_webapp/lib/mock_webapp/user.rb +18 -0
- data/exe/appmap +154 -0
- data/lib/appmap.rb +87 -0
- data/lib/appmap/algorithm/prune_class_map.rb +67 -0
- data/lib/appmap/algorithm/stats.rb +91 -0
- data/lib/appmap/class_map.rb +135 -0
- data/lib/appmap/command/record.rb +38 -0
- data/lib/appmap/command/stats.rb +14 -0
- data/lib/appmap/config.rb +91 -0
- data/lib/appmap/cucumber.rb +89 -0
- data/lib/appmap/event.rb +168 -0
- data/lib/appmap/hook.rb +130 -0
- data/lib/appmap/metadata.rb +62 -0
- data/lib/appmap/middleware/remote_recording.rb +114 -0
- data/lib/appmap/minitest.rb +141 -0
- data/lib/appmap/rails/action_handler.rb +91 -0
- data/lib/appmap/rails/sql_handler.rb +145 -0
- data/lib/appmap/railtie.rb +45 -0
- data/lib/appmap/record.rb +27 -0
- data/lib/appmap/rspec.rb +301 -0
- data/lib/appmap/trace.rb +96 -0
- data/lib/appmap/util.rb +40 -0
- data/lib/appmap/version.rb +9 -0
- data/lore/pages/2019-05-21-install-and-record/index.pug +51 -0
- data/lore/pages/2019-05-21-install-and-record/install_example_appmap.png +0 -0
- data/lore/pages/2019-05-21-install-and-record/metadata.yml +5 -0
- data/lore/pages/layout.pug +66 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-grid.css +1912 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-grid.css.map +1 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-grid.min.css +7 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-grid.min.css.map +1 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-reboot.css +331 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-reboot.css.map +1 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-reboot.min.css +8 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-reboot.min.css.map +1 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap.css +9030 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap.css.map +1 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap.min.css +7 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap.min.css.map +1 -0
- data/lore/public/stylesheets/style.css +8 -0
- data/package-lock.json +1064 -0
- data/package.json +24 -0
- data/spec/abstract_controller4_base_spec.rb +67 -0
- data/spec/abstract_controller_base_spec.rb +72 -0
- data/spec/config_spec.rb +25 -0
- data/spec/fixtures/hook/attr_accessor.rb +5 -0
- data/spec/fixtures/hook/compare.rb +7 -0
- data/spec/fixtures/hook/constructor.rb +7 -0
- data/spec/fixtures/hook/exception_method.rb +11 -0
- data/spec/fixtures/hook/instance_method.rb +23 -0
- data/spec/fixtures/hook/openssl_sign.rb +87 -0
- data/spec/fixtures/hook/singleton_method.rb +54 -0
- data/spec/fixtures/rack_users_app/.dockerignore +2 -0
- data/spec/fixtures/rack_users_app/.gitignore +2 -0
- data/spec/fixtures/rack_users_app/Dockerfile +32 -0
- data/spec/fixtures/rack_users_app/Gemfile +10 -0
- data/spec/fixtures/rack_users_app/appmap.yml +3 -0
- data/spec/fixtures/rack_users_app/config.ru +2 -0
- data/spec/fixtures/rack_users_app/docker-compose.yml +9 -0
- data/spec/fixtures/rack_users_app/lib/app.rb +36 -0
- data/spec/fixtures/rails4_users_app/.gitignore +13 -0
- data/spec/fixtures/rails4_users_app/.rbenv-gemsets +2 -0
- data/spec/fixtures/rails4_users_app/.ruby-version +1 -0
- data/spec/fixtures/rails4_users_app/Dockerfile +30 -0
- data/spec/fixtures/rails4_users_app/Dockerfile.pg +3 -0
- data/spec/fixtures/rails4_users_app/Gemfile +77 -0
- data/spec/fixtures/rails4_users_app/README.rdoc +28 -0
- data/spec/fixtures/rails4_users_app/Rakefile +6 -0
- data/spec/fixtures/rails4_users_app/app/assets/images/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/assets/javascripts/application.js +16 -0
- data/spec/fixtures/rails4_users_app/app/assets/stylesheets/application.css +15 -0
- data/spec/fixtures/rails4_users_app/app/controllers/api/users_controller.rb +27 -0
- data/spec/fixtures/rails4_users_app/app/controllers/application_controller.rb +5 -0
- data/spec/fixtures/rails4_users_app/app/controllers/concerns/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/controllers/health_controller.rb +5 -0
- data/spec/fixtures/rails4_users_app/app/controllers/users_controller.rb +5 -0
- data/spec/fixtures/rails4_users_app/app/helpers/application_helper.rb +2 -0
- 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 +18 -0
- data/spec/fixtures/rails4_users_app/app/views/layouts/application.html.haml +7 -0
- data/spec/fixtures/rails4_users_app/app/views/users/index.html.haml +7 -0
- data/spec/fixtures/rails4_users_app/appmap.yml +3 -0
- data/spec/fixtures/rails4_users_app/bin/rails +9 -0
- data/spec/fixtures/rails4_users_app/bin/setup +29 -0
- data/spec/fixtures/rails4_users_app/bin/spring +17 -0
- data/spec/fixtures/rails4_users_app/config.ru +4 -0
- data/spec/fixtures/rails4_users_app/config/application.rb +26 -0
- data/spec/fixtures/rails4_users_app/config/boot.rb +3 -0
- data/spec/fixtures/rails4_users_app/config/database.yml +18 -0
- data/spec/fixtures/rails4_users_app/config/environment.rb +5 -0
- data/spec/fixtures/rails4_users_app/config/environments/development.rb +41 -0
- data/spec/fixtures/rails4_users_app/config/environments/production.rb +79 -0
- data/spec/fixtures/rails4_users_app/config/environments/test.rb +42 -0
- data/spec/fixtures/rails4_users_app/config/initializers/assets.rb +11 -0
- data/spec/fixtures/rails4_users_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/fixtures/rails4_users_app/config/initializers/cookies_serializer.rb +3 -0
- data/spec/fixtures/rails4_users_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/fixtures/rails4_users_app/config/initializers/inflections.rb +16 -0
- data/spec/fixtures/rails4_users_app/config/initializers/mime_types.rb +4 -0
- data/spec/fixtures/rails4_users_app/config/initializers/session_store.rb +3 -0
- data/spec/fixtures/rails4_users_app/config/initializers/to_time_preserves_timezone.rb +10 -0
- data/spec/fixtures/rails4_users_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/fixtures/rails4_users_app/config/locales/en.yml +23 -0
- data/spec/fixtures/rails4_users_app/config/routes.rb +12 -0
- data/spec/fixtures/rails4_users_app/config/secrets.yml +22 -0
- data/spec/fixtures/rails4_users_app/create_app +23 -0
- data/spec/fixtures/rails4_users_app/db/migrate/20191127112304_create_users.rb +10 -0
- data/spec/fixtures/rails4_users_app/db/schema.rb +26 -0
- data/spec/fixtures/rails4_users_app/db/seeds.rb +7 -0
- data/spec/fixtures/rails4_users_app/docker-compose.yml +26 -0
- 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 +67 -0
- data/spec/fixtures/rails4_users_app/public/422.html +67 -0
- data/spec/fixtures/rails4_users_app/public/500.html +66 -0
- data/spec/fixtures/rails4_users_app/public/favicon.ico +0 -0
- data/spec/fixtures/rails4_users_app/public/robots.txt +5 -0
- data/spec/fixtures/rails4_users_app/spec/controllers/users_controller_api_spec.rb +49 -0
- data/spec/fixtures/rails4_users_app/spec/rails_helper.rb +95 -0
- data/spec/fixtures/rails4_users_app/spec/spec_helper.rb +96 -0
- data/spec/fixtures/rails4_users_app/test/fixtures/users.yml +9 -0
- data/spec/fixtures/rails_users_app/.dockerignore +1 -0
- data/spec/fixtures/rails_users_app/.gitignore +39 -0
- data/spec/fixtures/rails_users_app/.rspec +1 -0
- data/spec/fixtures/rails_users_app/.ruby-version +1 -0
- data/spec/fixtures/rails_users_app/Dockerfile +29 -0
- data/spec/fixtures/rails_users_app/Dockerfile.pg +3 -0
- data/spec/fixtures/rails_users_app/Gemfile +52 -0
- data/spec/fixtures/rails_users_app/Rakefile +6 -0
- data/spec/fixtures/rails_users_app/app/controllers/api/users_controller.rb +27 -0
- data/spec/fixtures/rails_users_app/app/controllers/application_controller.rb +2 -0
- data/spec/fixtures/rails_users_app/app/controllers/concerns/.keep +0 -0
- data/spec/fixtures/rails_users_app/app/controllers/health_controller.rb +5 -0
- data/spec/fixtures/rails_users_app/app/controllers/users_controller.rb +5 -0
- data/spec/fixtures/rails_users_app/app/models/activerecord/user.rb +18 -0
- data/spec/fixtures/rails_users_app/app/models/concerns/.keep +0 -0
- data/spec/fixtures/rails_users_app/app/models/sequel/user.rb +25 -0
- data/spec/fixtures/rails_users_app/app/views/layouts/application.html.haml +7 -0
- data/spec/fixtures/rails_users_app/app/views/users/index.html.haml +7 -0
- data/spec/fixtures/rails_users_app/appmap.yml +3 -0
- data/spec/fixtures/rails_users_app/bin/appmap +29 -0
- data/spec/fixtures/rails_users_app/bin/byebug +29 -0
- data/spec/fixtures/rails_users_app/bin/gli +29 -0
- data/spec/fixtures/rails_users_app/bin/htmldiff +29 -0
- data/spec/fixtures/rails_users_app/bin/ldiff +29 -0
- data/spec/fixtures/rails_users_app/bin/nokogiri +29 -0
- data/spec/fixtures/rails_users_app/bin/rackup +29 -0
- data/spec/fixtures/rails_users_app/bin/rails +4 -0
- data/spec/fixtures/rails_users_app/bin/rake +29 -0
- data/spec/fixtures/rails_users_app/bin/rspec +29 -0
- data/spec/fixtures/rails_users_app/bin/ruby-parse +29 -0
- data/spec/fixtures/rails_users_app/bin/ruby-rewrite +29 -0
- data/spec/fixtures/rails_users_app/bin/sequel +29 -0
- data/spec/fixtures/rails_users_app/bin/setup +25 -0
- data/spec/fixtures/rails_users_app/bin/sprockets +29 -0
- data/spec/fixtures/rails_users_app/bin/thor +29 -0
- data/spec/fixtures/rails_users_app/bin/update +25 -0
- data/spec/fixtures/rails_users_app/config.ru +5 -0
- data/spec/fixtures/rails_users_app/config/application.rb +51 -0
- data/spec/fixtures/rails_users_app/config/boot.rb +3 -0
- data/spec/fixtures/rails_users_app/config/credentials.yml.enc +1 -0
- data/spec/fixtures/rails_users_app/config/database.yml +18 -0
- data/spec/fixtures/rails_users_app/config/environment.rb +5 -0
- data/spec/fixtures/rails_users_app/config/environments/development.rb +40 -0
- data/spec/fixtures/rails_users_app/config/environments/production.rb +68 -0
- data/spec/fixtures/rails_users_app/config/environments/test.rb +36 -0
- data/spec/fixtures/rails_users_app/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/fixtures/rails_users_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/fixtures/rails_users_app/config/initializers/cors.rb +16 -0
- data/spec/fixtures/rails_users_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/fixtures/rails_users_app/config/initializers/inflections.rb +16 -0
- data/spec/fixtures/rails_users_app/config/initializers/mime_types.rb +4 -0
- data/spec/fixtures/rails_users_app/config/initializers/record_button.rb +3 -0
- data/spec/fixtures/rails_users_app/config/initializers/wrap_parameters.rb +9 -0
- data/spec/fixtures/rails_users_app/config/locales/en.yml +33 -0
- data/spec/fixtures/rails_users_app/config/routes.rb +11 -0
- data/spec/fixtures/rails_users_app/create_app +27 -0
- data/spec/fixtures/rails_users_app/db/migrate/20190728211408_create_users.rb +9 -0
- data/spec/fixtures/rails_users_app/db/schema.rb +23 -0
- data/spec/fixtures/rails_users_app/docker-compose.yml +28 -0
- data/spec/fixtures/rails_users_app/features/api_users.feature +13 -0
- data/spec/fixtures/rails_users_app/features/support/env.rb +4 -0
- data/spec/fixtures/rails_users_app/features/support/hooks.rb +11 -0
- data/spec/fixtures/rails_users_app/features/support/steps.rb +18 -0
- data/spec/fixtures/rails_users_app/lib/tasks/.keep +0 -0
- data/spec/fixtures/rails_users_app/log/.keep +0 -0
- data/spec/fixtures/rails_users_app/public/robots.txt +1 -0
- data/spec/fixtures/rails_users_app/spec/controllers/users_controller_api_spec.rb +29 -0
- data/spec/fixtures/rails_users_app/spec/models/user_spec.rb +39 -0
- data/spec/fixtures/rails_users_app/spec/rails_helper.rb +66 -0
- data/spec/fixtures/rails_users_app/spec/spec_helper.rb +96 -0
- data/spec/fixtures/rails_users_app/users_app/.gitignore +20 -0
- data/spec/hook_spec.rb +576 -0
- data/spec/rails_spec_helper.rb +60 -0
- data/spec/railtie_spec.rb +44 -0
- data/spec/record_sql_rails4_pg_spec.rb +76 -0
- data/spec/record_sql_rails_pg_spec.rb +68 -0
- data/spec/remote_recording_spec.rb +117 -0
- data/spec/rspec_feature_metadata_spec.rb +32 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/util_spec.rb +21 -0
- data/test/cli_test.rb +116 -0
- data/test/cucumber_test.rb +72 -0
- data/test/fixtures/cli_record_test/appmap.yml +3 -0
- data/test/fixtures/cli_record_test/lib/cli_record_test/main.rb +9 -0
- data/test/fixtures/cucumber4_recorder/Gemfile +5 -0
- data/test/fixtures/cucumber4_recorder/appmap.yml +3 -0
- data/test/fixtures/cucumber4_recorder/features/say_hello.feature +5 -0
- data/test/fixtures/cucumber4_recorder/features/support/env.rb +5 -0
- data/test/fixtures/cucumber4_recorder/features/support/hooks.rb +11 -0
- data/test/fixtures/cucumber4_recorder/features/support/steps.rb +9 -0
- data/test/fixtures/cucumber4_recorder/lib/hello.rb +7 -0
- data/test/fixtures/cucumber_recorder/Gemfile +5 -0
- data/test/fixtures/cucumber_recorder/appmap.yml +3 -0
- data/test/fixtures/cucumber_recorder/features/say_hello.feature +5 -0
- data/test/fixtures/cucumber_recorder/features/support/env.rb +5 -0
- data/test/fixtures/cucumber_recorder/features/support/hooks.rb +11 -0
- data/test/fixtures/cucumber_recorder/features/support/steps.rb +9 -0
- data/test/fixtures/cucumber_recorder/lib/hello.rb +7 -0
- data/test/fixtures/minitest_recorder/Gemfile +5 -0
- data/test/fixtures/minitest_recorder/appmap.yml +3 -0
- data/test/fixtures/minitest_recorder/lib/hello.rb +5 -0
- data/test/fixtures/minitest_recorder/test/hello_test.rb +12 -0
- data/test/fixtures/process_recorder/appmap.yml +3 -0
- data/test/fixtures/process_recorder/hello.rb +9 -0
- data/test/fixtures/rspec_recorder/Gemfile +5 -0
- data/test/fixtures/rspec_recorder/appmap.yml +3 -0
- data/test/fixtures/rspec_recorder/lib/hello.rb +5 -0
- data/test/fixtures/rspec_recorder/spec/decorated_hello_spec.rb +21 -0
- data/test/fixtures/rspec_recorder/spec/labeled_hello_spec.rb +9 -0
- data/test/fixtures/rspec_recorder/spec/plain_hello_spec.rb +9 -0
- data/test/minitest_test.rb +38 -0
- data/test/record_process_test.rb +35 -0
- data/test/rspec_test.rb +82 -0
- data/test/test_helper.rb +4 -0
- metadata +525 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
require 'English'
|
6
|
+
|
7
|
+
class CucumberTest < Minitest::Test
|
8
|
+
def perform_test(dir)
|
9
|
+
Bundler.with_clean_env do
|
10
|
+
Dir.chdir "test/fixtures/#{dir}" do
|
11
|
+
FileUtils.rm_rf 'tmp'
|
12
|
+
system 'bundle config --local local.appmap ../../..'
|
13
|
+
system 'bundle'
|
14
|
+
system({ 'APPMAP' => 'true' }, %(bundle exec cucumber))
|
15
|
+
|
16
|
+
yield
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_cucumber
|
22
|
+
perform_test 'cucumber_recorder' do
|
23
|
+
appmap_file = 'tmp/appmap/cucumber/Say_hello.appmap.json'
|
24
|
+
|
25
|
+
assert File.file?(appmap_file),
|
26
|
+
%(appmap output file does not exist in #{Dir.new('tmp/appmap/cucumber').entries.join(', ')})
|
27
|
+
appmap = JSON.parse(File.read(appmap_file))
|
28
|
+
assert_equal AppMap::APPMAP_FORMAT_VERSION, appmap['version']
|
29
|
+
assert_includes appmap.keys, 'metadata'
|
30
|
+
metadata = appmap['metadata']
|
31
|
+
|
32
|
+
assert_equal 'say_hello', metadata['feature_group']
|
33
|
+
assert_equal 'I can say hello', metadata['feature']
|
34
|
+
assert_equal 'Say hello', metadata['name']
|
35
|
+
assert_includes metadata.keys, 'client'
|
36
|
+
assert_equal({ name: 'appmap', url: AppMap::URL, version: AppMap::VERSION }.stringify_keys, metadata['client'])
|
37
|
+
assert_includes metadata.keys, 'recorder'
|
38
|
+
assert_equal({ name: 'cucumber' }.stringify_keys, metadata['recorder'])
|
39
|
+
|
40
|
+
assert_includes metadata.keys, 'frameworks'
|
41
|
+
cucumber = metadata['frameworks'].select {|f| f['name'] == 'cucumber'}
|
42
|
+
assert_equal 1, cucumber.count
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_cucumber4
|
47
|
+
perform_test 'cucumber4_recorder' do
|
48
|
+
appmap_file = 'tmp/appmap/cucumber/Say_hello.appmap.json'
|
49
|
+
|
50
|
+
assert File.file?(appmap_file),
|
51
|
+
%(appmap output file does not exist in #{Dir.new('tmp/appmap/cucumber').entries.join(', ')})
|
52
|
+
appmap = JSON.parse(File.read(appmap_file))
|
53
|
+
assert_equal AppMap::APPMAP_FORMAT_VERSION, appmap['version']
|
54
|
+
assert_includes appmap.keys, 'metadata'
|
55
|
+
metadata = appmap['metadata']
|
56
|
+
|
57
|
+
assert_equal 'say_hello', metadata['feature_group']
|
58
|
+
# In cucumber4, there's no access to the feature name from within the executing scenario
|
59
|
+
# (as far as I can tell).
|
60
|
+
assert_equal 'Say hello', metadata['feature']
|
61
|
+
assert_equal 'Say hello', metadata['name']
|
62
|
+
assert_includes metadata.keys, 'client'
|
63
|
+
assert_equal({ name: 'appmap', url: AppMap::URL, version: AppMap::VERSION }.stringify_keys, metadata['client'])
|
64
|
+
assert_includes metadata.keys, 'recorder'
|
65
|
+
assert_equal({ name: 'cucumber' }.stringify_keys, metadata['recorder'])
|
66
|
+
|
67
|
+
assert_includes metadata.keys, 'frameworks'
|
68
|
+
cucumber = metadata['frameworks'].select {|f| f['name'] == 'cucumber'}
|
69
|
+
assert_equal 1, cucumber.count
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'appmap/rspec'
|
3
|
+
require 'hello'
|
4
|
+
|
5
|
+
describe Hello, feature_group: 'Saying hello' do
|
6
|
+
before do
|
7
|
+
# Trick appmap-ruby into thinking we're a Rails app.
|
8
|
+
stub_const('Rails', double('rails', version: 'fake.0'))
|
9
|
+
end
|
10
|
+
|
11
|
+
# The order of these examples is important. The tests check the
|
12
|
+
# appmap for 'says hello', and we want another example to get run
|
13
|
+
# before it.
|
14
|
+
it 'does not say goodbye', feature: 'Speak hello', appmap: true do
|
15
|
+
expect(Hello.new.say_hello).not_to eq('Goodbye!')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'says hello', feature: 'Speak hello', appmap: true do
|
19
|
+
expect(Hello.new.say_hello).to eq('Hello!')
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
require 'English'
|
6
|
+
|
7
|
+
class MinitestTest < Minitest::Test
|
8
|
+
def perform_test(test_name)
|
9
|
+
Bundler.with_clean_env do
|
10
|
+
Dir.chdir 'test/fixtures/minitest_recorder' do
|
11
|
+
FileUtils.rm_rf 'tmp'
|
12
|
+
system 'bundle config --local local.appmap ../../..'
|
13
|
+
system 'bundle'
|
14
|
+
system({ 'APPMAP' => 'true' }, %(bundle exec ruby -Ilib -Itest test/#{test_name}_test.rb))
|
15
|
+
|
16
|
+
yield
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_hello
|
22
|
+
perform_test 'hello' do
|
23
|
+
appmap_file = 'tmp/appmap/minitest/Hello_hello.appmap.json'
|
24
|
+
|
25
|
+
assert File.file?(appmap_file), 'appmap output file does not exist'
|
26
|
+
appmap = JSON.parse(File.read(appmap_file))
|
27
|
+
assert_equal AppMap::APPMAP_FORMAT_VERSION, appmap['version']
|
28
|
+
assert_includes appmap.keys, 'metadata'
|
29
|
+
metadata = appmap['metadata']
|
30
|
+
assert_equal 'minitest_recorder', metadata['app']
|
31
|
+
assert_equal 'minitest', metadata['recorder']['name']
|
32
|
+
assert_equal 'ruby', metadata['language']['name']
|
33
|
+
assert_equal 'Hello', metadata['feature_group']
|
34
|
+
assert_equal 'hello', metadata['feature']
|
35
|
+
assert_equal 'Hello hello', metadata['name']
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
require 'English'
|
6
|
+
|
7
|
+
class RecordProcessTest < Minitest::Test
|
8
|
+
def perform_test(program_name)
|
9
|
+
Bundler.with_clean_env do
|
10
|
+
Dir.chdir 'test/fixtures/process_recorder' do
|
11
|
+
FileUtils.rm_rf 'tmp'
|
12
|
+
system 'bundle config --local local.appmap ../../..'
|
13
|
+
system 'bundle'
|
14
|
+
system(%(bundle exec ruby #{program_name}))
|
15
|
+
|
16
|
+
yield
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_hello
|
22
|
+
perform_test 'hello.rb' do
|
23
|
+
appmap_file = 'appmap.json'
|
24
|
+
|
25
|
+
assert File.file?(appmap_file), 'appmap output file does not exist'
|
26
|
+
appmap = JSON.parse(File.read(appmap_file))
|
27
|
+
assert_equal AppMap::APPMAP_FORMAT_VERSION, appmap['version']
|
28
|
+
assert_includes appmap.keys, 'metadata'
|
29
|
+
metadata = appmap['metadata']
|
30
|
+
assert_equal 'process_recorder', metadata['app']
|
31
|
+
assert_equal 'record_process', metadata['recorder']['name']
|
32
|
+
assert_equal 'ruby', metadata['language']['name']
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/test/rspec_test.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
require 'English'
|
6
|
+
|
7
|
+
class RSpecTest < Minitest::Test
|
8
|
+
def perform_test(test_name)
|
9
|
+
Bundler.with_clean_env do
|
10
|
+
Dir.chdir 'test/fixtures/rspec_recorder' do
|
11
|
+
FileUtils.rm_rf 'tmp'
|
12
|
+
system 'bundle config --local local.appmap ../../..'
|
13
|
+
system 'bundle'
|
14
|
+
system({ 'APPMAP' => 'true' }, %(bundle exec rspec spec/#{test_name}.rb))
|
15
|
+
|
16
|
+
yield
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_inventory
|
22
|
+
perform_test 'plain_hello_spec' do
|
23
|
+
appmap_file = 'tmp/appmap/rspec/Inventory.appmap.json'
|
24
|
+
|
25
|
+
assert File.file?(appmap_file), 'appmap output file does not exist'
|
26
|
+
appmap = JSON.parse(File.read(appmap_file))
|
27
|
+
assert_equal AppMap::APPMAP_FORMAT_VERSION, appmap['version']
|
28
|
+
assert_includes appmap.keys, 'metadata'
|
29
|
+
metadata = appmap['metadata']
|
30
|
+
assert_equal 'Inventory', metadata['name']
|
31
|
+
assert_includes metadata.keys, 'labels'
|
32
|
+
assert_equal metadata['labels'], %w[inventory]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_record_decorated_rspec
|
37
|
+
perform_test 'decorated_hello_spec' do
|
38
|
+
appmap_file = 'tmp/appmap/rspec/Hello_says_hello.appmap.json'
|
39
|
+
|
40
|
+
assert File.file?(appmap_file), 'appmap output file does not exist'
|
41
|
+
appmap = JSON.parse(File.read(appmap_file))
|
42
|
+
assert_equal AppMap::APPMAP_FORMAT_VERSION, appmap['version']
|
43
|
+
assert_includes appmap.keys, 'metadata'
|
44
|
+
metadata = appmap['metadata']
|
45
|
+
assert_equal 'Saying hello', metadata['feature_group']
|
46
|
+
assert_equal 'Speak hello', metadata['feature']
|
47
|
+
assert_equal 'Hello says hello', metadata['name']
|
48
|
+
assert_includes metadata.keys, 'client'
|
49
|
+
assert_equal({ name: 'appmap', url: AppMap::URL, version: AppMap::VERSION }.stringify_keys, metadata['client'])
|
50
|
+
assert_includes metadata.keys, 'recorder'
|
51
|
+
assert_equal({ name: 'rspec' }.stringify_keys, metadata['recorder'])
|
52
|
+
|
53
|
+
assert_includes metadata.keys, 'frameworks'
|
54
|
+
rspec = metadata['frameworks'].select {|f| f['name'] == 'rspec'}
|
55
|
+
assert_equal 1, rspec.count
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_record_plain_rspec
|
60
|
+
perform_test 'plain_hello_spec' do
|
61
|
+
appmap_file = 'tmp/appmap/rspec/Hello_says_hello.appmap.json'
|
62
|
+
assert File.file?(appmap_file), 'appmap output file does not exist'
|
63
|
+
appmap = JSON.parse(File.read(appmap_file))
|
64
|
+
assert_includes appmap.keys, 'metadata'
|
65
|
+
metadata = appmap['metadata']
|
66
|
+
assert_equal 'Hello', metadata['feature_group']
|
67
|
+
assert_equal 'Hello', metadata['feature']
|
68
|
+
assert_equal 'Hello says hello', metadata['name']
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_record_labeled_rspec
|
73
|
+
perform_test 'labeled_hello_spec' do
|
74
|
+
appmap_file = 'tmp/appmap/rspec/Hello_says_hello.appmap.json'
|
75
|
+
assert File.file?(appmap_file), 'appmap output file does not exist'
|
76
|
+
appmap = JSON.parse(File.read(appmap_file))
|
77
|
+
assert_includes appmap.keys, 'metadata'
|
78
|
+
metadata = appmap['metadata']
|
79
|
+
assert_equal %w[hello speak], metadata['labels'].sort
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|