summaryrefslogtreecommitdiff
path: root/spec/ruby/core/tracepoint/enable_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/tracepoint/enable_spec.rb')
-rw-r--r--spec/ruby/core/tracepoint/enable_spec.rb91
1 files changed, 30 insertions, 61 deletions
diff --git a/spec/ruby/core/tracepoint/enable_spec.rb b/spec/ruby/core/tracepoint/enable_spec.rb
index 24f6070b97..bf61c35154 100644
--- a/spec/ruby/core/tracepoint/enable_spec.rb
+++ b/spec/ruby/core/tracepoint/enable_spec.rb
@@ -54,53 +54,28 @@ describe 'TracePoint#enable' do
TracePoint.new(:line) do |tp|
next unless TracePointSpec.target_thread?
event_name = tp.event
- end.enable { event_name.should equal(:line) }
+ end.enable { event_name.should.equal?(:line) }
end
- ruby_version_is '3.2' do
- it 'enables the trace object only for the current thread' do
- threads = []
- trace = TracePoint.new(:line) do |tp|
- # Runs on purpose on any Thread
- threads << Thread.current
- end
-
- thread = nil
- trace.enable do
- line_event = true
- thread = Thread.new do
- event_in_other_thread = true
- end
- thread.join
- end
-
- threads = threads.uniq
- threads.should.include?(Thread.current)
- threads.should_not.include?(thread)
+ it 'enables the trace object only for the current thread' do
+ threads = []
+ trace = TracePoint.new(:line) do |tp|
+ # Runs on purpose on any Thread
+ threads << Thread.current
end
- end
-
- ruby_version_is ''...'3.2' do
- it 'enables the trace object for any thread' do
- threads = []
- trace = TracePoint.new(:line) do |tp|
- # Runs on purpose on any Thread
- threads << Thread.current
- end
- thread = nil
- trace.enable do
- line_event = true
- thread = Thread.new do
- event_in_other_thread = true
- end
- thread.join
+ thread = nil
+ trace.enable do
+ line_event = true
+ thread = Thread.new do
+ event_in_other_thread = true
end
-
- threads = threads.uniq
- threads.should.include?(Thread.current)
- threads.should.include?(thread)
+ thread.join
end
+
+ threads = threads.uniq
+ threads.should.include?(Thread.current)
+ threads.should_not.include?(thread)
end
it 'can accept arguments within a block but it should not yield arguments' do
@@ -110,7 +85,7 @@ describe 'TracePoint#enable' do
event_name = tp.event
end
trace.enable do |*args|
- event_name.should equal(:line)
+ event_name.should.equal?(:line)
args.should == []
end
trace.should_not.enabled?
@@ -149,13 +124,7 @@ describe 'TracePoint#enable' do
describe "when nested" do
before do
- ruby_version_is ""..."3.0" do
- @path_prefix = '@'
- end
-
- ruby_version_is "3.0" do
- @path_prefix = ' '
- end
+ @path_prefix = ' '
end
it "enables both TracePoints but only calls the respective callbacks" do
@@ -332,7 +301,7 @@ describe 'TracePoint#enable' do
end
ScratchPad.recorded.should == [lineno]
- lineno.should be_kind_of(Integer)
+ lineno.should.is_a?(Integer)
end
end
@@ -348,7 +317,7 @@ describe 'TracePoint#enable' do
trace.enable(target: block) do
block.call # triggers :b_call and :b_return events
end
- }.should raise_error(ArgumentError, /can not enable any hooks/)
+ }.should.raise(ArgumentError, /can not enable any hooks/)
end
it "raises ArgumentError if passed not Method/UnboundMethod/Proc" do
@@ -357,7 +326,7 @@ describe 'TracePoint#enable' do
-> {
trace.enable(target: Object.new) do
end
- }.should raise_error(ArgumentError, /specified target is not supported/)
+ }.should.raise(ArgumentError, /specified target is not supported/)
end
context "nested enabling and disabling" do
@@ -369,7 +338,7 @@ describe 'TracePoint#enable' do
trace.enable(target: -> {}) do
end
end
- }.should raise_error(ArgumentError, /can't nest-enable a targett?ing TracePoint/)
+ }.should.raise(ArgumentError, /can't nest-enable a targett?ing TracePoint/)
end
it "raises ArgumentError if trace point already enabled without target is re-enabled with target" do
@@ -380,7 +349,7 @@ describe 'TracePoint#enable' do
trace.enable(target: -> {}) do
end
end
- }.should raise_error(ArgumentError, /can't nest-enable a targett?ing TracePoint/)
+ }.should.raise(ArgumentError, /can't nest-enable a targett?ing TracePoint/)
end
it "raises ArgumentError if trace point already enabled with target is re-enabled without target" do
@@ -391,7 +360,7 @@ describe 'TracePoint#enable' do
trace.enable do
end
end
- }.should raise_error(ArgumentError, /can't nest-enable a targett?ing TracePoint/)
+ }.should.raise(ArgumentError, /can't nest-enable a targett?ing TracePoint/)
end
it "raises ArgumentError if trace point already enabled with target is disabled with block" do
@@ -402,7 +371,7 @@ describe 'TracePoint#enable' do
trace.disable do
end
end
- }.should raise_error(ArgumentError, /can't disable a targett?ing TracePoint in a block/)
+ }.should.raise(ArgumentError, /can't disable a targett?ing TracePoint in a block/)
end
it "traces events when trace point with target is enabled in another trace point enabled without target" do
@@ -505,7 +474,7 @@ describe 'TracePoint#enable' do
-> {
trace.enable(target_line: 67) do
end
- }.should raise_error(ArgumentError, /only target_line is specified/)
+ }.should.raise(ArgumentError, /only target_line is specified/)
end
it "raises ArgumentError if :line event isn't registered" do
@@ -522,7 +491,7 @@ describe 'TracePoint#enable' do
-> {
trace.enable(target_line: target_line, target: target) do
end
- }.should raise_error(ArgumentError, /target_line is specified, but line event is not specified/)
+ }.should.raise(ArgumentError, /target_line is specified, but line event is not specified/)
end
it "raises ArgumentError if :target_line value is out of target code lines range" do
@@ -531,7 +500,7 @@ describe 'TracePoint#enable' do
-> {
trace.enable(target_line: 1, target: -> { }) do
end
- }.should raise_error(ArgumentError, /can not enable any hooks/)
+ }.should.raise(ArgumentError, /can not enable any hooks/)
end
it "raises TypeError if :target_line value couldn't be coerced to Integer" do
@@ -540,7 +509,7 @@ describe 'TracePoint#enable' do
-> {
trace.enable(target_line: Object.new, target: -> { }) do
end
- }.should raise_error(TypeError, /no implicit conversion of \w+? into Integer/)
+ }.should.raise(TypeError, /no implicit conversion of \w+? into Integer/)
end
it "raises ArgumentError if :target_line value is negative" do
@@ -549,7 +518,7 @@ describe 'TracePoint#enable' do
-> {
trace.enable(target_line: -2, target: -> { }) do
end
- }.should raise_error(ArgumentError, /can not enable any hooks/)
+ }.should.raise(ArgumentError, /can not enable any hooks/)
end
it "accepts value that could be coerced to Integer" do