Skip to content

Commit db10a18

Browse files
authored
Merge pull request #266 from applandinc/feat/dont-record-appmap-false
feat: Don't record rspec tests when appmap: false
2 parents 38ae96c + 09c4a24 commit db10a18

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

lib/appmap/rspec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,20 @@ def begin_spec(example)
157157
AppMap.info 'Configuring AppMap recorder for RSpec' if first_recording?
158158
@recording_count += 1
159159

160-
@recordings_by_example[example.object_id] = Recording.new(example)
160+
recording = if example.metadata[:appmap] != false
161+
Recording.new(example)
162+
else
163+
:false
164+
end
165+
166+
@recordings_by_example[example.object_id] = recording
161167
end
162168

163169
def end_spec(example, exception:)
164170
recording = @recordings_by_example.delete(example.object_id)
165171
return warn "No recording found for #{example}" unless recording
166172

167-
recording.finish exception
173+
recording.finish exception unless recording == :false
168174
end
169175

170176
def config

spec/fixtures/rails6_users_app/spec/controllers/users_controller_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@
2323
get :show, params: { id: 'alice' }
2424
expect(response).to be_ok
2525
end
26+
it 'performance test', appmap: false do
27+
end
2628
end
2729
end

spec/rails_recording_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ def rails_versions
1515
include_context 'Rails app pg database', "spec/fixtures/rails#{rails_major_version}_users_app" unless use_existing_data?
1616
include_context 'rails integration test setup'
1717

18+
describe 'rspec metadata' do
19+
let(:appmap_json_files) { Dir.glob("#{tmpdir}/appmap/rspec/*.appmap.json") }
20+
21+
it 'appmap: false disables recording' do
22+
test_names = appmap_json_files.map(&File.method(:read)).map(&JSON.method(:parse)).map do |json|
23+
json['metadata']['name']
24+
end
25+
expect(test_names).to include('UsersController GET /users/:login shows the user')
26+
expect(test_names).to_not include('UsersController GET /users/:login performance test')
27+
end
28+
end
29+
1830
describe 'an API route' do
1931
describe 'creating an object' do
2032
let(:appmap_json_file) do

spec/rails_spec_helper.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ def run_process(method, cmd, env, options = {})
9898

9999
shared_context 'rails integration test setup' do
100100
let(:tmpdir) { app.tmpdir }
101-
102101
before(:all) { @app.run_specs } unless use_existing_data?
103102

104103
let(:appmap_json_path) { File.join(tmpdir, 'appmap/rspec', appmap_json_file) }

0 commit comments

Comments
 (0)