debian-mirror-gitlab/spec/lib/gitlab/view/presenter/simple_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
957 B
Ruby
Raw Normal View History

2019-12-04 20:38:33 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::View::Presenter::Simple do
2017-08-17 22:00:37 +05:30
let(:project) { double(:project, user: 'John Doe') }
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
presenter = presenter_class.new(project, current_user: 'Jane Doe')
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')
end
end
describe 'delegation' do
it 'does not forward missing methods to subject' do
presenter = presenter_class.new(project)
expect { presenter.user }.to raise_error(NoMethodError)
end
end
end