RubyMine quickstart

2. Install the AppMap agent for Ruby

  1. Install the AppMap gem

    Add gem 'appmap' to your Gemfile. We recommend that you add the appmap gem to the :development, :test group. Your Gemfile should look something like this:

     source 'https://rubygems.org'
     git_source(:github) { |repo| "https://github.com/#{repo}.git" }
    
     # Optional rubRuby version
     # ruby '2.7.2'
    
     group :development, :test do
       gem 'appmap'
     end
    

    Install with bundle install.

  2. Create a file named appmap.yml in the root folder of your project
  3. Add your application source code directories and gems to appmap.yml

     # 'name' should be the same as the code repo name.
     name: my_project
     packages:
     - path: app/controllers
     - path: app/models
     # Include the gems that you want to see in the dependency maps.
     # This is just an example.
     - gem: devise
    

    For a full reference to appmap.yml, see the appmap-ruby reference documentation.

Record AppMaps from tests

RSpec

Run the tests with the environment variable APPMAP=true:

$ APPMAP=true bundle exec rspec

Each RSpec test will output an AppMap file into the directory tmp/appmap/rspec.

Next: View your AppMaps arrow_forward


Minitest

Run your tests as you normally would with the environment variable APPMAP=true. For example:

$ APPMAP=true bundle exec rake test

or

$ APPMAP=true bundle exec ruby -Ilib -Itest test/*_test.rb

Each Minitest test will output an AppMap file into the directory tmp/appmap/minitest.

Next: View your AppMaps arrow_forward


Cucumber

To record Cucumber tests, follow these additional steps:

1) Require appmap/cucumber in support/env.rb:

  require 'appmap/cucumber'

Be sure to require it before config/environment is required.

2) Create an Around hook in support/hooks.rb to record the scenario:

if AppMap::Cucumber.enabled?
  Around('not @appmap-disable') do |scenario, block|
    appmap = AppMap.record do
      block.call
    end

    AppMap::Cucumber.write_scenario(scenario, appmap)
  end
end

3) Run the tests with the environment variable APPMAP=true:

$ APPMAP=true bundle exec cucumber

Each Cucumber test will output an AppMap file into the directory tmp/appmap/cucumber.

Next: View your AppMaps arrow_forward


I dont have tests

AppMap agent can record all running application code - not just tests - provided there is control logic that determines when the recording is started, when it stopped, and how it should be named, such as remote recording.

To record AppMaps using other than the test method, follow the instructions in recording methods.


Was this page helpful? thumb_up Yes thumb_down No
Thank you for your feedback!