Sha256: fd1cac3603de26b077b7366ec76678b908c958e55068ddd969a224c96d5ec5ba
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
require 'hash_generator' RSpec.describe HashGenerator do let(:generator) { described_class.new } subject { generator.to_h } describe '#push_scope' do it 'pushes an object into the outer scope' do generator.new_array generator.new_object generator.store(:key, 1) generator.push_scope generator.store_scope(:array) should eq(:array => [{:key => 1}]) end end describe '#reopen_scope' do it 'reopens the scope at the given key' do generator.new_object generator.store(:key1, 1) generator.store_scope(:object) generator.reopen_scope(:object) generator.store(:key2, 2) generator.end_scope should eq(:object => {:key1 => 1, :key2 => 2}) end end describe '#store' do it 'stores a value in the current scope at the given key' do generator.store(:key, 1) should eq(:key => 1) end end describe '#store_scope' do it 'stores the current scope in the outer scope at the given key' do generator.new_object generator.store(:key, 1) generator.store_scope(:object) should eq(:object => {:key => 1}) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hash_generator-1.0.0 | spec/hash_generator_spec.rb |