BigW Consortium Gitlab

simple_spec.rb 920 Bytes
Newer Older
1 2 3
require 'spec_helper'

describe Gitlab::View::Presenter::Simple do
4
  let(:project) { double(:project, user: 'John Doe') }
5 6 7 8 9 10 11 12 13 14
  let(:presenter_class) do
    Class.new(described_class)
  end

  it 'includes Gitlab::View::Presenter::Base' do
    expect(described_class).to include(Gitlab::View::Presenter::Base)
  end

  describe '#initialize' do
    it 'takes arbitrary key/values and exposes them' do
15
      presenter = presenter_class.new(project, current_user: 'Jane Doe')
16

17 18 19 20 21 22 23
      expect(presenter.current_user).to eq('Jane Doe')
    end

    it 'override the presentee attributes' do
      presenter = presenter_class.new(project, user: 'Jane Doe')

      expect(presenter.user).to eq('Jane Doe')
24 25 26 27 28
    end
  end

  describe 'delegation' do
    it 'does not forward missing methods to subject' do
29 30
      presenter = presenter_class.new(project)

31
      expect { presenter.user }.to raise_error(NoMethodError)
32 33 34
    end
  end
end