Sha256: 129cb1956695038bce507f8f30c9defa6de29b9e1b36d008048a7b52e738a0ba

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

describe Monolens do

  subject {
    Monolens.load_file(file)
  }

  context 'on simple.yml' do
    let(:file){ Path.dir/'fixtures/simple.yml' }

    it 'works' do
      expect(subject.call(' foo  ')).to eql('FOO')
    end
  end

  context 'on transform.yml' do
    let(:file){ Path.dir/'fixtures/transform.yml' }

    it 'works' do
      input = {
        firstname: 'Bernard',
        lastname: 'Lambeau'
      }
      expected = {
        firstname: 'BERNARD',
        lastname: 'lambeau'
      }
      expect(subject.call(input)).to eql(expected)
    end
  end

  context 'on coerce.yml' do
    let(:file){ Path.dir/'fixtures/coerce.yml' }

    it 'works' do
      input = {
        at: '04/05/2022',
      }
      expected = {
        at: Date.parse('2022-05-04')
      }
      expect(subject.call(input)).to eql(expected)
    end
  end

  context 'on macro.yml' do
    let(:file){ Path.dir/'fixtures/macro.yml' }

    it 'works' do
      input = [' Monolens ', ' Finitio ', '  Bmg']
      expected = 'MONOLENS, FINITIO, BMG'
      expect(subject.call(input)).to eql(expected)
    end
  end

  context 'on recursive.yml' do
    let(:file){ Path.dir/'fixtures/recursive.yml' }

    it 'fails' do
      expect {
        subject
      }.to raise_error(/No such lens core.join_them/)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
monolens-0.6.4 spec/test_monolens.rb
monolens-0.6.3 spec/test_monolens.rb
monolens-0.6.2 spec/test_monolens.rb
monolens-0.6.1 spec/test_monolens.rb
monolens-0.6.0 spec/test_monolens.rb