Sha256: f93d295e7ea027f57e89817d1887147b47655b1381ac8a56eebc8af90d79114d

Contents?: true

Size: 1.9 KB

Versions: 3

Compression:

Stored size: 1.9 KB

Contents

require 'rails_spec_helper'

describe 'AbstractControllerBase' do
  before(:all) { @fixture_dir = 'spec/fixtures/rails_users_app' }
  include_context 'Rails app pg database'
  
  around(:each) do |example|
    FileUtils.rm_rf tmpdir
    FileUtils.mkdir_p tmpdir
    cmd = "docker-compose run --rm -e APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:8"
    system cmd, chdir: @fixture_dir or raise 'Failed to run rails_users_app container'

    example.run
  end

  let(:tmpdir) { 'tmp/spec/AbstractControllerBase' }
  let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }

  describe 'testing with rspec' do
    it 'Message fields are recorded in the appmap' do
      expect(File).to exist(appmap_json)
      appmap = JSON.parse(File.read(appmap_json)).to_yaml

      expect(appmap).to include(<<-MESSAGE.strip)
  message:
  - name: login
    class: String
    value: alice
    object_id:
      MESSAGE

      expect(appmap).to include(<<-MESSAGE.strip)
  - name: password
    class: String
    value: "[FILTERED]"
    object_id:
      MESSAGE

      expect(appmap).to include(<<-SERVER_REQUEST.strip)
  http_server_request:
    request_method: POST
    path_info: "/api/users"
      SERVER_REQUEST
    end

    it 'Properly captures method parameters in the appmap' do
      expect(File).to exist(appmap_json)
      appmap = JSON.parse(File.read(appmap_json)).to_yaml

      expect(appmap).to match(<<-CREATE_CALL.strip)
  event: call
  defined_class: Api::UsersController
  method_id: create_user
  path: app/controllers/api/users_controller.rb
  lineno: 23
  static: false
  thread_id: .*
  parameters:
  - name: params
    class: ActiveSupport::HashWithIndifferentAccess
    object_id: .*
    value: '{"login"=>"alice"}'
    kind: req
  receiver:
      CREATE_CALL
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
appmap-0.22.0 spec/abstract_controller_base_spec.rb
appmap-0.21.0 spec/abstract_controller_base_spec.rb
appmap-0.20.0 spec/abstract_controller_base_spec.rb