Sha256: 9ab2de7f54495fe0f4f06c5555e55de3ad83d524a031dbf046083dc3e18e963d

Contents?: true

Size: 667 Bytes

Versions: 1

Compression:

Stored size: 667 Bytes

Contents

require 'spec_helper'

describe Transproc::Conditional do
  describe '.guard' do
    let(:fn) { described_class.t(:guard, condition, operation) }
    let(:condition) { ->(value) { value.is_a?(::String) } }
    let(:operation) { Transproc::Coercions.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

1 entries across 1 versions & 1 rubygems

Version Path
transproc-0.3.0 spec/unit/conditional_spec.rb