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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-01-09 23:46:38 +0300
committerRémy Coutable <remy@rymai.me>2017-01-18 18:38:34 +0300
commite5a29b451473c6f188d5096f21055d27a51fdf90 (patch)
tree0cbbd7e09b0636a2a19c1a19078ae95dc6f538c6 /spec/lib/gitlab/view
parentbf789ff567c71ff68c216bfa8f3d43e09b6f49fb (diff)
Improve presenter factory
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/lib/gitlab/view')
-rw-r--r--spec/lib/gitlab/view/presenter/factory_spec.rb42
-rw-r--r--spec/lib/gitlab/view/presenter_factory_spec.rb48
2 files changed, 42 insertions, 48 deletions
diff --git a/spec/lib/gitlab/view/presenter/factory_spec.rb b/spec/lib/gitlab/view/presenter/factory_spec.rb
new file mode 100644
index 00000000000..7a65429b500
--- /dev/null
+++ b/spec/lib/gitlab/view/presenter/factory_spec.rb
@@ -0,0 +1,42 @@
+require 'spec_helper'
+
+describe Gitlab::View::Presenter::Factory do
+ let(:variable) { create(:ci_variable) }
+
+ describe '#initialize' do
+ context 'without optional parameters' do
+ subject do
+ described_class.new(variable)
+ end
+
+ it 'takes a subject and optional params' do
+ expect { subject }.not_to raise_error
+ end
+ end
+
+ context 'with optional parameters' do
+ subject do
+ described_class.new(variable, user: 'user')
+ end
+
+ it 'takes a subject and optional params' do
+ expect { subject }.not_to raise_error
+ end
+ end
+ end
+
+ describe '#fabricate!' do
+ subject do
+ described_class.new(variable, user: 'user', foo: 'bar').fabricate!
+ end
+
+ it 'exposes given params' do
+ expect(subject.user).to eq('user')
+ expect(subject.foo).to eq('bar')
+ end
+
+ it 'detects the presenter based on the given subject' do
+ expect(subject).to be_a(Ci::Variable::Presenter)
+ end
+ end
+end
diff --git a/spec/lib/gitlab/view/presenter_factory_spec.rb b/spec/lib/gitlab/view/presenter_factory_spec.rb
deleted file mode 100644
index c5e4d86f6c9..00000000000
--- a/spec/lib/gitlab/view/presenter_factory_spec.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-require 'spec_helper'
-
-describe Gitlab::View::PresenterFactory do
- let(:appearance) { build(:appearance) }
- let(:broadcast_message) { build(:broadcast_message) }
-
- before do
- class AppearancePresenter
- include Gitlab::View::Presenter
- end
-
- class BroadcastMessagePresenter < SimpleDelegator
- include Gitlab::View::Presenter
- end
- end
-
- describe '#initialize' do
- subject do
- described_class.new(appearance)
- end
-
- it 'takes a subject and optional params' do
- expect { subject }.not_to raise_error
- end
- end
-
- describe '#fabricate!' do
- context 'without delegation' do
- subject do
- described_class.new(appearance).fabricate!
- end
-
- it 'does not forward missing methods to subject' do
- expect { subject.title }.to raise_error(NoMethodError)
- end
- end
-
- context 'with delegation' do
- subject do
- described_class.new(broadcast_message).fabricate!
- end
-
- it 'forwards missing methods to subject' do
- expect(subject.message).to eq(broadcast_message.message)
- end
- end
- end
-end