Skip to content

Commit

Permalink
Add specs for Queue#freeze and SizedQueue#freeze
Browse files Browse the repository at this point in the history
  • Loading branch information
herwinw authored and eregon committed Sep 23, 2024
1 parent e7233f3 commit ae05448
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
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

0 comments on commit ae05448

Please sign in to comment.