Sha256: cb883bfe68524c095914e8afe2772fd3e0b42dbad49c4d35b2de09d502ca28ee

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

module WhosGotDirt
  RSpec.describe Renderer do
    describe '#initialize' do
      it 'should set the template' do
        expect(Renderer.new('name' => 'John Smith').template).to eq('name' => 'John Smith')
      end
    end

    describe '#result' do
      it 'should render a result' do
        expect(Renderer.new({
          'id' => 123,
          'name' => '/fn',
          'identifiers' => [{
            'identifier' => '/id',
            'scheme' => 'ACME',
          }],
          'delete' => '/blank',
        }).result({
          'id' => 456,
          'fn' => 'John Smith',
          'blank' => nil,
        })).to eq({
          'id' => 123,
          'name' => 'John Smith',
          'identifiers' => [{
            'identifier' => 456,
            'scheme' => 'ACME',
          }],
        })
      end

      it 'should render a result using lambdas' do
        expect(Renderer.new({
          'lambda' => lambda{|data|
            ['key', 'value']
          },
        }).result({
          'lambda' => 123,
        })).to eq({
          'key' => 'value',
        })
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
whos_got_dirt-0.0.5 spec/renderer_spec.rb
whos_got_dirt-0.0.4 spec/renderer_spec.rb
whos_got_dirt-0.0.3 spec/renderer_spec.rb
whos_got_dirt-0.0.2 spec/renderer_spec.rb