Sha256: acb0e963f915c6b1e0312450c351cac6a4ddd0705b09aad2a8146b390bcd1f56
Contents?: true
Size: 623 Bytes
Versions: 2
Compression:
Stored size: 623 Bytes
Contents
require 'rspec' require 'abstractivator/value_map' describe '#value_map' do Foo = Struct.new(:a) it 'maps arrays' do expect([[:a, 1], [:b, 2]].value_map(&:reverse)).to eql [[1, :a], [2, :b]] end it 'maps single values' do expect(3.value_map(&method(:square))).to eql 9 end it 'structs are treated as single values' do expect(Foo.new(42).value_map { |x| x.a }).to eql 42 end it 'hashes are treated as single values' do expect({a: 1, b: 2}.value_map { |x| x[:a] }).to eql 1 end it 'maps nil' do expect(nil.value_map(&:to_s)).to eql '' end def square(x) x * x end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
abstractivator-0.20.0 | spec/lib/abstractivator/value_map_spec.rb |
abstractivator-0.19.0 | spec/lib/abstractivator/value_map_spec.rb |