Sha256: 7d0102c93d3f3a25e87f2b2e6d9b30c4dc34758026b847c1016fa8bfc9606a2f

Contents?: true

Size: 895 Bytes

Versions: 2

Compression:

Stored size: 895 Bytes

Contents

require "spec_helper"

RSpec.describe Timeout::Extensions do
  describe ".timeout" do
    let(:dummy_timeout) { double(:meta_timeout) }
    let(:exception) { double(:exception) }
    let(:action) { proc { |t| } }
    context "inside and outside of thread" do
      it "hits the proper timeout handler" do
        within_thread do
          Thread.current.timeout_handler = dummy_timeout
          expect(dummy_timeout).to receive(:call).with(2, exception, &action)
          timeout(2, exception, &action)
        end
      end
    end
  end

  describe ".sleep" do
    let(:dummy_sleep) { double(:meta_sleep) }
    context "inside and outside of thread" do
      it "hits the proper sleep handler" do
        within_thread do
          Thread.current.sleep_handler = dummy_sleep
          expect(dummy_sleep).to receive(:call).with(2)
          sleep(2)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
timeout-extensions-0.1.1 spec/timeout/extensions_spec.rb
timeout-extensions-0.1.0 spec/timeout/extensions_spec.rb