Skip to content
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

Add specs for Queue#freeze and SizedQueue#freeze #1193

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions core/queue/freeze_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require_relative '../../spec_helper'
require_relative '../../shared/queue/freeze'

describe "Queue#freeze" do
it_behaves_like :queue_freeze, :freeze, -> { Queue.new }
end
6 changes: 6 additions & 0 deletions core/sizedqueue/freeze_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require_relative '../../spec_helper'
require_relative '../../shared/queue/freeze'

describe "SizedQueue#freeze" do
it_behaves_like :queue_freeze, :freeze, -> { SizedQueue.new(1) }
end
18 changes: 18 additions & 0 deletions shared/queue/freeze.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
describe :queue_freeze, shared: true do
ruby_version_is ""..."3.3" do
it "can be frozen" do
queue = @object.call
queue.freeze
queue.should.frozen?
end
end

ruby_version_is "3.3" do
it "raises an exception when freezing" do
queue = @object.call
-> {
queue.freeze
}.should raise_error(TypeError, "cannot freeze #{queue}")
end
end
end