Sha256: d9527a882b5c9a0736f1d606da9bb9c7f16e8a6fa6eee12f66996e4a7fa286f5
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
require 'spec_helper' describe "Transproc::Function" do describe "#>>" do it "composes named functions" do f1 = t(:symbolize_keys) f2 = t(:rename_keys, user_name: :name) f3 = f1 >> f2 expect(f3.to_ast).to eql( [ :symbolize_keys, [], [ :rename_keys, [ user_name: :name ] ] ] ) expect(f3['user_name' => 'Jane']).to eql(name: 'Jane') f4 = f3 >> t(:nest, :details, [:name]) expect(f4.to_ast).to eql( [ :symbolize_keys, [], [ :rename_keys, [ user_name: :name ] ], [ :nest, [:details, [:name]] ] ] ) expect(f4['user_name' => 'Jane']).to eql(details: { name: 'Jane' }) end it "composes anonymous functions" do # TODO: Use Transproc -> (v) { v.to_s } after release of jruby-9k f1 = Transproc proc { |v, m| v * m }, 2 f2 = Transproc proc { |v| v.to_s } f3 = f1 >> f2 expect(f3.to_ast).to eql( [ f1.fn, [2], [ f2.fn, [] ] ] ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
transproc-0.2.0 | spec/integration/function_spec.rb |