Sha256: 64c1af08059a33906c65f46efc8955e4ef12104d875aa41c120484f5d5806b24

Contents?: true

Size: 562 Bytes

Versions: 4

Compression:

Stored size: 562 Bytes

Contents

require 'spec_helper'

describe Transproc::Conditional do
  describe '.guard' do
    let(:fn) { t(:guard, ->(value) { value.is_a?(::String) }, t(:to_integer)) }

    context 'when predicate returns truthy value' do
      it 'applies the transformation and returns the result' do
        input = '2'

        expect(fn[input]).to eql(2)
      end
    end

    context 'when predicate returns falsey value' do
      it 'returns the original value' do
        input = { 'foo' => 'bar' }

        expect(fn[input]).to eql('foo' => 'bar')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
transproc-0.2.4 spec/unit/conditional_spec.rb
transproc-0.2.3 spec/unit/conditional_spec.rb
transproc-0.2.2 spec/unit/conditional_spec.rb
transproc-0.2.1 spec/unit/conditional_spec.rb