Sha256: 77a6a6a6aa46c86661253373cb7559e51f0b2a6995b2fb7389e20671ceb2a876

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

describe Gitlab::ObjectifiedHash do
  before do
    @hash = {a: 1, b: 2, 'string' => 'string', symbol: :symbol}
    @oh = Gitlab::ObjectifiedHash.new @hash
  end

  it "should objectify hash" do
    expect(@oh.a).to eq(@hash[:a])
    expect(@oh.b).to eq(@hash[:b])
  end

  describe "#to_hash" do
    it "should return an original hash" do
      expect(@oh.to_hash).to eq(@hash)
    end

    it "should have an alias #to_h" do
      expect(@oh.respond_to?(:to_h)).to be_truthy
    end
  end

  describe "#respond_to" do
    it "should return true for methods this object responds to through method_missing as sym" do
      expect(@oh.respond_to?(:a)).to be_truthy
    end

    it "should return true for methods this object responds to through method_missing as string" do
      expect(@oh.respond_to?('string')).to be_truthy
    end

    it "should not care if you use a string or symbol to reference a method" do
      expect(@oh.respond_to?(:string)).to be_truthy
    end

    it "should not care if you use a string or symbol to reference a method" do
      expect(@oh.respond_to?('symbol')).to be_truthy
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitlab-3.3.0 spec/gitlab/objectified_hash_spec.rb