1
0
mirror of https://github.com/meineerde/rackstash.git synced 2026-02-01 01:37:12 +00:00

Preserve the frozen state when cloning Flows objects

This commit is contained in:
Holger Just 2018-05-16 21:01:10 +02:00
parent cdc237897f
commit a3d66deb7a
2 changed files with 20 additions and 0 deletions

View File

@ -229,6 +229,7 @@ module Rackstash
def initialize_copy(other)
@flows = other.flows.dup
@flows.freeze if other.frozen?
super
end

View File

@ -155,6 +155,25 @@ RSpec.describe Rackstash::Flows do
end
end
describe '#clone' do
it 'clones the flows' do
flows << a_flow
copied = flows.clone
expect(copied).to be_instance_of described_class
expect(copied.length).to eql 1
expect(copied).to_not equal flows
end
it 'preserves the frozen? status' do
flows.freeze
expect(flows).to be_frozen
expect(flows.clone).to be_frozen
expect { flows.clone << a_flow }.to raise_error(RuntimeError)
end
end
describe '#freeze' do
it 'freezes the object' do
expect(flows.freeze).to equal flows