File: hash_spec.rb

package info (click to toggle)
yard 0.9.38-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,736 kB
  • sloc: ruby: 31,680; javascript: 7,658; makefile: 21
file content (14 lines) | stat: -rw-r--r-- 370 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# frozen_string_literal: true

RSpec.describe Hash do
  describe ".[]" do
    it "accepts an Array argument (Ruby 1.8.6 and older)" do
      list = [['foo', 'bar'], ['foo2', 'bar2']]
      expect(Hash[list]).to eq('foo' => 'bar', 'foo2' => 'bar2')
    end

    it "accepts an array as a key" do
      expect(Hash[['a', 'b'], 1]).to eq(['a', 'b'] => 1)
    end
  end
end