Skip to content

Commit

Permalink
Clone store when registries are cloned
Browse files Browse the repository at this point in the history
  • Loading branch information
getand committed Jan 15, 2020
1 parent 053eca4 commit fe17abd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
nxt_registry (0.1.3)
nxt_registry (0.1.4)
activesupport

GEM
Expand All @@ -16,10 +16,10 @@ GEM
coderay (1.1.2)
concurrent-ruby (1.1.5)
diff-lcs (1.3)
i18n (1.7.0)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
method_source (0.9.2)
minitest (5.13.0)
minitest (5.14.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
Expand Down
1 change: 1 addition & 0 deletions lib/nxt_registry/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ def transformed_key(key)
def initialize_copy(original)
super
@store = original.send(:store).deep_dup
@options = original.send(:options).deep_dup
end
end
end
2 changes: 1 addition & 1 deletion lib/nxt_registry/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module NxtRegistry
VERSION = "0.1.3"
VERSION = "0.1.4"
end
17 changes: 17 additions & 0 deletions spec/nxt_registry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,21 @@ def passengers
expect { subject.resolve(:andy) }.to raise_error KeyError, "Key andy was never registered"
end
end

describe '#clone' do
subject do
extend NxtRegistry

registry :developers do
call(false)
end
end

let(:clone) { subject.clone }

it 'clones the store' do
expect { clone.register(:luetfi, 'legend') }.to_not change { subject.developers.to_h }
expect { subject.register(:rapha, 'dog') }.to_not change { clone.developers.to_h }
end
end
end

0 comments on commit fe17abd

Please sign in to comment.