Sha256: dcb9c85b220af90699a507f091f1124ffd8941c0115ffda788ddaaebd3c0b5a0
Contents?: true
Size: 932 Bytes
Versions: 2
Compression:
Stored size: 932 Bytes
Contents
require 'spec_helper' describe Transproc do describe 'composition' do it 'allows composing two transformation functions' do input = '1' output = 1.0 to_i = t(-> value { value.to_i }) to_f = t(-> value { value.to_f }) result = to_i >> to_f expect(result[input]).to eql(output) end end describe 'function registration' do it 'allows registering functions by name' do Transproc.register(:to_boolean, -> value { value == 'true' }) result = t(-> value { value.to_s }) >> t(:to_boolean) expect(result[:true]).to be(true) expect(result[:false]).to be(false) end it 'allows registering function by passing a block' do Transproc.register(:to_boolean) { |value| value == 'true' } result = t(-> value { value.to_s }) >> t(:to_boolean) expect(result[:true]).to be(true) expect(result[:false]).to be(false) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
transproc-0.2.0 | spec/integration/transproc_spec.rb |
transproc-0.1.3 | spec/integration/transproc_spec.rb |