mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 20:24:05 -06:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
41 lines
833 B
Ruby
41 lines
833 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe MethodProfiler do
|
|
class Sneetch
|
|
def beach
|
|
end
|
|
|
|
def recurse(count = 5)
|
|
if count > 0
|
|
recurse(count - 1)
|
|
end
|
|
end
|
|
end
|
|
|
|
it "can bypass recursion on demand" do
|
|
MethodProfiler.patch(Sneetch, [:recurse], :recurse, no_recurse: true)
|
|
|
|
MethodProfiler.start
|
|
Sneetch.new.recurse
|
|
result = MethodProfiler.stop
|
|
|
|
expect(result[:recurse][:calls]).to eq(1)
|
|
end
|
|
|
|
it "can transfer data between threads" do
|
|
MethodProfiler.patch(Sneetch, [:beach], :at_beach)
|
|
|
|
MethodProfiler.start
|
|
Sneetch.new.beach
|
|
data = MethodProfiler.transfer
|
|
result = nil
|
|
Thread.new do
|
|
MethodProfiler.start(data)
|
|
Sneetch.new.beach
|
|
result = MethodProfiler.stop
|
|
end.join
|
|
|
|
expect(result[:at_beach][:calls]).to eq(2)
|
|
end
|
|
end
|