Sha256: 4768d45e35343c1a127cf2a3a45e8026c7b84d503742dc6ecd7a602b096a202c

Contents?: true

Size: 1.84 KB

Versions: 3

Compression:

Stored size: 1.84 KB

Contents

require 'rails_spec_helper'

describe 'AbstractControllerBase' do
  include_context 'Rails app pg database', 'spec/fixtures/rails4_users_app' do
    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"
      run_cmd cmd, chdir: fixture_dir

      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
  thread_id: .*
  defined_class: Api::UsersController
  method_id: build_user
  path: app/controllers/api/users_controller.rb
  lineno: 23
  static: false
  parameters:
  - name: params
    class: Hash
    object_id: .*
    value: '{"login"=>"alice"}'
    kind: req
  receiver:
        CREATE_CALL
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
appmap-0.39.0 spec/abstract_controller4_base_spec.rb
appmap-0.38.1 spec/abstract_controller4_base_spec.rb
appmap-0.37.2 spec/abstract_controller4_base_spec.rb