Sha256: b83ca463e5f5998521dab65d13dabd7d9e84dac3393e60b26d684879f7aedba7
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 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 "#inspect" do it "should return a formatted string" do pretty_string = "#<#{@oh.class.name}:#{@oh.object_id} {hash: #{@hash.to_s}}" expect(@oh.inspect).to eq(pretty_string) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gitlab-3.5.0 | spec/gitlab/objectified_hash_spec.rb |
gitlab-3.4.0 | spec/gitlab/objectified_hash_spec.rb |