summaryrefslogtreecommitdiff
path: root/qa/spec
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-12-22 15:40:46 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-12-22 15:40:46 +0100
commitd69e4541a4874208590a7387186f8929143fd2af (patch)
tree13f6ab2e1d93c0330ddb18ac48586fe2faed8c70 /qa/spec
parent481f461380d4919077c543c51f58e37337167706 (diff)
downloadgitlab-ce-d69e4541a4874208590a7387186f8929143fd2af.tar.gz
Use composite pattern to return page view errors
Diffstat (limited to 'qa/spec')
-rw-r--r--qa/spec/page/base_spec.rb17
-rw-r--r--qa/spec/page/element_spec.rb34
-rw-r--r--qa/spec/page/view_spec.rb4
3 files changed, 54 insertions, 1 deletions
diff --git a/qa/spec/page/base_spec.rb b/qa/spec/page/base_spec.rb
index 31ff9e258a1..63445d8f7bf 100644
--- a/qa/spec/page/base_spec.rb
+++ b/qa/spec/page/base_spec.rb
@@ -5,7 +5,7 @@ describe QA::Page::Base do
end
end
- describe 'DSL for defining view partials', '.view' do
+ describe '.view', 'DSL for defining view partials' do
subject do
Class.new(described_class) do
view 'path/to/some/view.html.haml' do
@@ -32,4 +32,19 @@ describe QA::Page::Base do
end
end
end
+
+ describe '.errors' do
+ let(:view) { double('view') }
+
+ before do
+ allow(described_class).to receive(:views)
+ .and_return([view])
+
+ allow(view).to receive(:errors).and_return(['some error'])
+ end
+
+ it 'iterates views composite and returns errors' do
+ expect(described_class.errors).to eq ['some error']
+ end
+ end
end
diff --git a/qa/spec/page/element_spec.rb b/qa/spec/page/element_spec.rb
new file mode 100644
index 00000000000..238c4d1ac66
--- /dev/null
+++ b/qa/spec/page/element_spec.rb
@@ -0,0 +1,34 @@
+describe QA::Page::Element do
+ context 'when pattern is an expression' do
+ subject { described_class.new(:something, /button 'Sign in'/) }
+
+ it 'is correctly matches against a string' do
+ expect(subject.matches?("button 'Sign in'")).to be true
+ end
+
+ it 'does not match if string does not match against a pattern' do
+ expect(subject.matches?("button 'Sign out'")).to be false
+ end
+ end
+
+ context 'when pattern is a string' do
+ subject { described_class.new(:something, 'button') }
+
+ it 'is correctly matches against a string' do
+ expect(subject.matches?('some button in the view')).to be true
+ end
+
+ it 'does not match if string does not match against a pattern' do
+ expect(subject.matches?('text_field :name')).to be false
+ end
+ end
+
+ context 'when pattern is not supported' do
+ subject { described_class.new(:something, [/something/]) }
+
+ it 'raises an error' do
+ expect { subject.matches?('some line') }
+ .to raise_error ArgumentError
+ end
+ end
+end
diff --git a/qa/spec/page/view_spec.rb b/qa/spec/page/view_spec.rb
index 27e83d35de1..6a78e32db68 100644
--- a/qa/spec/page/view_spec.rb
+++ b/qa/spec/page/view_spec.rb
@@ -57,5 +57,9 @@ describe QA::Page::View do
.to match %r(Missing element `.*` in `.*/some/file.html` view)
end
end
+
+ context 'when view partial has not been found' do
+ pending
+ end
end
end