diff options
Diffstat (limited to 'spec/ruby/core/tracepoint/enable_spec.rb')
| -rw-r--r-- | spec/ruby/core/tracepoint/enable_spec.rb | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/spec/ruby/core/tracepoint/enable_spec.rb b/spec/ruby/core/tracepoint/enable_spec.rb index ab392c7583..bf61c35154 100644 --- a/spec/ruby/core/tracepoint/enable_spec.rb +++ b/spec/ruby/core/tracepoint/enable_spec.rb @@ -54,10 +54,10 @@ 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 - it 'enables the trace object for any thread' 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 @@ -75,7 +75,7 @@ describe 'TracePoint#enable' do threads = threads.uniq threads.should.include?(Thread.current) - threads.should.include?(thread) + threads.should_not.include?(thread) end it 'can accept arguments within a block but it should not yield arguments' do @@ -85,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? @@ -124,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 @@ -307,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 @@ -323,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 @@ -332,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 @@ -344,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 @@ -355,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 @@ -366,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 @@ -377,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 @@ -480,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 @@ -497,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 @@ -506,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 @@ -515,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 @@ -524,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 |
