Sha256: a96abe27623ea112b13adba9394095b44326989cf420f450705a4f15d6b0f3db

Contents?: true

Size: 801 Bytes

Versions: 1

Compression:

Stored size: 801 Bytes

Contents

require 'spec_helper'

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

  subject { object.new(raw) }

  let(:value) { mock('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.0 spec/unit/esearch/presenter/class_methods/new_spec.rb