Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
fa07d232
Commit
fa07d232
authored
Jan 09, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add QA error when page class has no views defined
parent
a5cfd5a6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
18 deletions
+40
-18
qa/qa/page/base.rb
qa/qa/page/base.rb
+4
-0
qa/qa/page/validator.rb
qa/qa/page/validator.rb
+4
-6
qa/qa/scenario/test/sanity/selectors.rb
qa/qa/scenario/test/sanity/selectors.rb
+11
-0
qa/spec/page/base_spec.rb
qa/spec/page/base_spec.rb
+19
-6
qa/spec/page/validator_spec.rb
qa/spec/page/validator_spec.rb
+2
-6
No files found.
qa/qa/page/base.rb
View file @
fa07d232
...
...
@@ -49,6 +49,10 @@ module QA
end
def
self
.
errors
if
views
.
empty?
return
[
"
#{
name
}
class does not have views / elements defined!"
]
end
@errors
||=
views
.
map
(
&
:errors
).
flatten
end
...
...
qa/qa/page/validator.rb
View file @
fa07d232
...
...
@@ -31,8 +31,8 @@ module QA
@errors
||=
Array
.
new
.
tap
do
|
errors
|
descendants
.
each
do
|
page
|
page
.
views
.
each
do
|
view
|
view
.
errors
.
each
do
|
error
|
errors
.
push
(
Error
.
new
(
page
,
view
,
error
))
view
.
errors
.
each
do
|
message
|
errors
.
push
(
Error
.
new
(
page
.
name
,
view
.
path
,
message
))
end
end
end
...
...
@@ -40,11 +40,9 @@ module QA
end
def
validate!
message
=
<<~
EOS
We found validation errors!
EOS
return
if
errors
.
none?
raise
ValidationError
,
message
if
errors
.
any?
raise
ValidationError
,
'Page views / elements validation error!'
end
end
end
...
...
qa/qa/scenario/test/sanity/selectors.rb
View file @
fa07d232
...
...
@@ -5,7 +5,18 @@ module QA
class
Selectors
<
Scenario
::
Template
include
Scenario
::
Bootable
PAGE_MODULES
=
[
QA
::
Page
]
def
perform
(
*
)
validators
=
PAGE_MODULES
.
map
do
|
pages
|
Page
::
Validator
.
new
(
pages
)
end
validators
.
map
(
&
:errors
).
flatten
.
tap
do
|
errors
|
end
validators
.
each
(
&
:validate!
)
end
end
end
...
...
qa/spec/page/base_spec.rb
View file @
fa07d232
...
...
@@ -36,15 +36,28 @@ describe QA::Page::Base do
describe
'.errors'
do
let
(
:view
)
{
double
(
'view'
)
}
before
do
allow
(
described_class
).
to
receive
(
:views
)
.
and_return
([
view
])
context
'when page has views and elements defined'
do
before
do
allow
(
described_class
).
to
receive
(
:views
)
.
and_return
([
view
])
allow
(
view
).
to
receive
(
:errors
).
and_return
([
'some error'
])
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
it
'iterates views composite and returns errors'
do
expect
(
described_class
.
errors
).
to
eq
[
'some error'
]
context
'when page has no views and elements defined'
do
before
do
allow
(
described_class
).
to
receive
(
:views
).
and_return
([])
end
it
'appends an error about missing views / elements block'
do
expect
(
described_class
.
errors
)
.
to
include
'QA::Page::Base class does not have views / elements defined!'
end
end
end
end
qa/spec/page/validator_spec.rb
View file @
fa07d232
...
...
@@ -69,13 +69,9 @@ describe QA::Page::Validator do
end
describe
'#validate!'
do
it
'does raises an error with descriptive message'
do
message
=
<<~
EOS
We found validation errors!
EOS
it
'raises validation error'
do
expect
{
subject
.
validate!
}
.
to
raise_error
described_class
::
ValidationError
,
message
.
to
raise_error
described_class
::
ValidationError
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment