Sha256: a87e07d9d5b0c6dd703ace8d94b031d271b98cdb95ae9ea8066a88800b52eb0f

Contents?: true

Size: 978 Bytes

Versions: 21

Compression:

Stored size: 978 Bytes

Contents

# encoding: utf-8
#
# This file is part of the lazier gem. Copyright (C) 2013 and above Shogun <shogun_panda@me.com>.
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
#

require "spec_helper"

describe Lazier::Hash do
  let(:reference) {
    rv = {a: 1, "b" => 2}
    rv.default = 0
    rv
  }

  before(:all) do
    ::Lazier.load!
  end

  describe "allows access to keys using method syntax" do
    it "should allow method reference for symbol key" do expect(reference.b).to eq(2) end
    it "should use super for missing key" do expect {reference.c}.to raise_error(NoMethodError) end
  end

  describe "#respond_to" do
    it "should return true for string key" do expect(reference.respond_to?(:a)).to be_true end
    it "should return true for symbol key" do expect(reference.respond_to?(:b)).to be_true end
    it "should return false for missing key" do expect(reference.respond_to?(:c)).to be_false end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
lazier-2.8.1 spec/lazier/hash_spec.rb
lazier-2.8.0 spec/lazier/hash_spec.rb
lazier-2.7.0 spec/lazier/hash_spec.rb
lazier-2.6.7 spec/lazier/hash_spec.rb
lazier-2.6.6 spec/lazier/hash_spec.rb
lazier-2.6.5 spec/lazier/hash_spec.rb
lazier-2.6.4 spec/lazier/hash_spec.rb
lazier-2.6.3 spec/lazier/hash_spec.rb
lazier-2.6.2 spec/lazier/hash_spec.rb
lazier-2.6.1 spec/lazier/hash_spec.rb
lazier-2.5.3 spec/lazier/hash_spec.rb
lazier-2.5.2 spec/lazier/hash_spec.rb
lazier-2.5.1 spec/lazier/hash_spec.rb
lazier-2.5.0 spec/lazier/hash_spec.rb
lazier-2.4.0 spec/lazier/hash_spec.rb
lazier-2.3.1 spec/lazier/hash_spec.rb
lazier-2.3.0 spec/lazier/hash_spec.rb
lazier-2.2.0 spec/lazier/hash_spec.rb
lazier-2.1.1 spec/lazier/hash_spec.rb
lazier-2.1.0 spec/lazier/hash_spec.rb