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

Commit

Permalink
Merge pull request #55 from st0012/force_recording
Browse files Browse the repository at this point in the history
Add force_recording option for debugging
  • Loading branch information
st0012 authored Jun 28, 2020
2 parents 4da9fd3 + 37ccbc2 commit f452073
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
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

0 comments on commit f452073

Please sign in to comment.