Sha256: 3a048488e0cc5571534fb1e4a4fc5b34a6f26877f483e0d930318310d0720ddf

Contents?: true

Size: 617 Bytes

Versions: 2

Compression:

Stored size: 617 Bytes

Contents

require 'spec_helper'

using HashWithKeyAccessMethod
describe HashWithKeyAccessMethod do
	it 'has a version number' do
		expect(HashWithKeyAccessMethod::VERSION).not_to be nil
	end

	hash = { name: :mami, "name" => :mado, "name2" => :homu }
	it 'Symbol key access' do
		expect(hash.name).to eq(:mami)
	end

	it 'String key access' do
		expect{ hash.name2 }.to raise_error(NoMethodError)
	end

	it 'Assign' do
		hash.name = :saya
		expect(hash.name).to eq(:saya)
	end

	it 'Assign new key' do
		hash.age = 13
		expect(hash.age).to eq(13)
	end

	it 'Assign new key [] access' do
		expect(hash[:age]).to eq(13)
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hash_with_key_access_method-0.0.2 spec/hash_with_key_access_method_spec.rb
hash_with_key_access_method-0.0.1 spec/hash_with_key_access_method_spec.rb