Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Add force_recording option for debugging #55

Merged
merged 1 commit into from
Jun 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/tapping_device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ def track(object)
def build_minimum_trace_point(event_type:)
TracePoint.new(*event_type) do |tp|
next unless filter_condition_satisfied?(tp)
next if is_tapping_device_call?(tp)

filepath, line_number = get_call_location(tp)
payload = build_payload(tp: tp, filepath: filepath, line_number: line_number)

next if should_be_skipped_by_paths?(filepath)
next unless with_condition_satisfied?(payload)
unless @options[:force_recording]
next if is_tapping_device_call?(tp)
next if should_be_skipped_by_paths?(filepath)
next unless with_condition_satisfied?(payload)
end

yield(payload)
end
Expand Down Expand Up @@ -204,6 +206,8 @@ def process_options(options)
options[:event_type] ||= config[:event_type]
options[:hijack_attr_methods] ||= config[:hijack_attr_methods]
options[:track_as_records] ||= config[:track_as_records]
# for debugging the gem more easily
options[:force_recording] ||= false

options[:descendants] ||= []
options[:root_device] ||= self
Expand Down
9 changes: 9 additions & 0 deletions spec/shared_examples/optionable_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,13 @@
expect(count).to eq(1)
end
end
context "with options - force_recording: true" do
it "skips all other filtering options" do
device = send(subject, target, filter_by_paths: [/lib/], force_recording: true)

trigger_action.call(target)

expect(device.calls.count).to be >= 1
end
end
end