Skip to content

Add specs for Fiber.blocking? #886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions core/fiber/blocking_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require_relative '../../spec_helper'

ruby_version_is "3.0" do
require "fiber"

describe "Fiber.blocking?" do
context "when fiber is non-blocking" do
it "returns false by default" do
fiber = Fiber.new { Fiber.current.blocking? }
blocking = fiber.resume

blocking.should == false
end

it "returns false for blocking: false" do
fiber = Fiber.new(blocking: false) { Fiber.current.blocking? }
blocking = fiber.resume

blocking.should == false
end
end

context "when fiber is blocking" do
it "returns true for blocking: true" do
fiber = Fiber.new(blocking: true) { Fiber.current.blocking? }
blocking = fiber.resume

blocking.should == true
end
end
end
end