BigW Consortium Gitlab

factory_spec.rb 782 Bytes
Newer Older
1 2 3
require 'spec_helper'

describe Gitlab::View::Presenter::Factory do
4
  let(:build) { Ci::Build.new }
5 6 7 8

  describe '#initialize' do
    context 'without optional parameters' do
      it 'takes a subject and optional params' do
9 10 11
        presenter = described_class.new(build)

        expect { presenter }.not_to raise_error
12 13 14 15 16
      end
    end

    context 'with optional parameters' do
      it 'takes a subject and optional params' do
17 18 19
        presenter = described_class.new(build, user: 'user')

        expect { presenter }.not_to raise_error
20 21 22 23 24 25
      end
    end
  end

  describe '#fabricate!' do
    it 'detects the presenter based on the given subject' do
26 27 28
      presenter = described_class.new(build).fabricate!

      expect(presenter).to be_a(Ci::BuildPresenter)
29 30 31
    end
  end
end