Sha256: ff46ab85f45d1d49a6859a739037b5d9ebc61a1ab6939dfa0fa323ecae127345

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 Bytes

Contents

require 'spec_helper'

describe Esearch::Presenter, '.new' do
  let(:object) { class_under_test }

  subject { object.new(raw) }

  let(:value) { double('Value') }

  class DummyPresenter
    include Concord.new(:raw)
  end

  context 'with exposed tagged collection' do
    let(:raw) { { 'foo' => { 'bar' => { 'baz' => 'bor' } } } }

    let(:class_under_test) do
      Class.new(described_class) do
        expose_tagged_collection(:foo, DummyPresenter)
      end
    end

    its(:foo) { should eql([DummyPresenter.new('baz' => 'bor', 'name' => 'bar')]) }
  end

  context 'with exposed primitive' do
    let(:raw) { { 'foo' => value } }

    let(:class_under_test) do
      Class.new(described_class) do
        expose_primitive :foo
      end
    end

    its(:foo) { should be(value) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
esearch-0.2.1 spec/unit/esearch/presenter/class_methods/new_spec.rb