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:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-01-09 13:28:14 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-01-09 13:28:14 +0300
commitd5a92c53dd79ff661ca7f8e4b0deefec5e19704d (patch)
tree90c7ac18cd1dfb59853cc712a53ee1765ca38c6a /qa/spec/page
parent4b945e2845cf40456ef71faafbce181f0e60dba7 (diff)
Implement QA pages and views validator
Diffstat (limited to 'qa/spec/page')
-rw-r--r--qa/spec/page/validator_spec.rb83
1 files changed, 83 insertions, 0 deletions
diff --git a/qa/spec/page/validator_spec.rb b/qa/spec/page/validator_spec.rb
new file mode 100644
index 00000000000..abee137f4a1
--- /dev/null
+++ b/qa/spec/page/validator_spec.rb
@@ -0,0 +1,83 @@
+describe QA::Page::Validator do
+ describe '#constants' do
+ subject do
+ described_class.new(QA::Page::Project)
+ end
+
+ it 'returns all costants that are module children' do
+ expect(subject.constants)
+ .to include QA::Page::Project::New, QA::Page::Project::Settings
+ end
+ end
+
+ describe '#descendants' do
+ subject do
+ described_class.new(QA::Page::Project)
+ end
+
+ it 'recursively returns all descendants that are page objects' do
+ expect(subject.descendants)
+ .to include QA::Page::Project::New, QA::Page::Project::Settings::Repository
+ end
+
+ it 'does not return modules that aggregate page objects' do
+ expect(subject.descendants)
+ .not_to include QA::Page::Project::Settings
+ end
+ end
+
+ context 'when checking validation errors' do
+ let(:view) { spy('view') }
+
+ before do
+ allow(QA::Page::Admin::Settings)
+ .to receive(:views).and_return([view])
+ end
+
+ subject do
+ described_class.new(QA::Page::Admin)
+ end
+
+ context 'when there are no validation errors' do
+ before do
+ allow(view).to receive(:errors).and_return([])
+ end
+
+ describe '#errors' do
+ it 'does not return errors' do
+ expect(subject.errors).to be_empty
+ end
+ end
+
+ describe '#validate!' do
+ it 'does not raise error' do
+ expect { subject.validate! }.not_to raise_error
+ end
+ end
+ end
+
+ context 'when there are validation errors' do
+ before do
+ allow(view).to receive(:errors)
+ .and_return(['some error', 'another error'])
+ end
+
+ describe '#errors' do
+ it 'returns errors' do
+ expect(subject.errors.count).to eq 2
+ end
+ end
+
+ describe '#validate!' do
+ it 'does raises an error with descriptive message' do
+ message = <<~EOS
+ We found validation errors!
+ EOS
+
+ expect { subject.validate! }
+ .to raise_error described_class::ValidationError, message
+ end
+ end
+ end
+ end
+end