Welcome to mirror list, hosted at ThFree Co, Russian Federation.

factory_spec.rb « presenter « view « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 55c5ecbf92f79dad70d41671457e702269ab2dd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'spec_helper'

describe Gitlab::View::Presenter::Factory do
  let(:build) { Ci::Build.new }

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

        expect { presenter }.not_to raise_error
      end
    end

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

        expect { presenter }.not_to raise_error
      end
    end
  end

  describe '#fabricate!' do
    it 'exposes given params' do
      presenter = described_class.new(build, user: 'user', foo: 'bar').fabricate!

      expect(presenter.user).to eq('user')
      expect(presenter.foo).to eq('bar')
    end

    it 'detects the presenter based on the given subject' do
      presenter = described_class.new(build).fabricate!

      expect(presenter).to be_a(Ci::BuildPresenter)
    end
  end
end