Files
ubicloud/spec/lib/thread_printer_spec.rb
Jeremy Evans 4dc5c281c9 Support running specs with frozen environment
This allows for running the specs with a frozen environment that
should closely match the production environment.

This adds the following rake tasks:

* coverage: Runs specs in serial with coverage
* frozen_spec: Runs specs in serial in frozen environment
* frozen_pspec: Runs specs in parallel in frozen environment

It changes the default rake task to run both the coverage and
frozen_spec tasks.  It also changes the GitHub CI workflow
to use the default rake task.

When specs are run in the frozen environment they call
clover_freeze before running the specs, after loading all
other code.

There are currently 56 specs that do not work in the frozen
environment.  They are skipped by including the skip_if_frozen
method in each spec.
2024-10-27 13:25:30 -07:00

22 lines
728 B
Ruby

# frozen_string_literal: true
RSpec.describe ThreadPrinter do
describe "#print" do
it "can dump threads" do
expect(described_class).to receive(:puts).with(/Thread: #<Thread:.*>/)
expect(described_class).to receive(:puts).with(/backtrace/)
described_class.run
end
it "can handle threads with a nil backtrace" do
skip_if_frozen
# The documentation calls out that the backtrace is an array or
# nil.
expect(described_class).to receive(:puts).with(/Thread: #<InstanceDouble.*>/)
expect(described_class).to receive(:puts).with(nil)
expect(Thread).to receive(:list).and_return([instance_double(Thread, backtrace: nil)])
described_class.run
end
end
end