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
Léo-Paul Géneau
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
Show 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
...
@@ -49,6 +49,10 @@ module QA
end
end
def
self
.
errors
def
self
.
errors
if
views
.
empty?
return
[
"
#{
name
}
class does not have views / elements defined!"
]
end
@errors
||=
views
.
map
(
&
:errors
).
flatten
@errors
||=
views
.
map
(
&
:errors
).
flatten
end
end
...
...
qa/qa/page/validator.rb
View file @
fa07d232
...
@@ -31,8 +31,8 @@ module QA
...
@@ -31,8 +31,8 @@ module QA
@errors
||=
Array
.
new
.
tap
do
|
errors
|
@errors
||=
Array
.
new
.
tap
do
|
errors
|
descendants
.
each
do
|
page
|
descendants
.
each
do
|
page
|
page
.
views
.
each
do
|
view
|
page
.
views
.
each
do
|
view
|
view
.
errors
.
each
do
|
error
|
view
.
errors
.
each
do
|
message
|
errors
.
push
(
Error
.
new
(
page
,
view
,
error
))
errors
.
push
(
Error
.
new
(
page
.
name
,
view
.
path
,
message
))
end
end
end
end
end
end
...
@@ -40,11 +40,9 @@ module QA
...
@@ -40,11 +40,9 @@ module QA
end
end
def
validate!
def
validate!
message
=
<<~
EOS
return
if
errors
.
none?
We found validation errors!
EOS
raise
ValidationError
,
message
if
errors
.
any?
raise
ValidationError
,
'Page views / elements validation error!'
end
end
end
end
end
end
...
...
qa/qa/scenario/test/sanity/selectors.rb
View file @
fa07d232
...
@@ -5,7 +5,18 @@ module QA
...
@@ -5,7 +5,18 @@ module QA
class
Selectors
<
Scenario
::
Template
class
Selectors
<
Scenario
::
Template
include
Scenario
::
Bootable
include
Scenario
::
Bootable
PAGE_MODULES
=
[
QA
::
Page
]
def
perform
(
*
)
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
end
end
end
...
...
qa/spec/page/base_spec.rb
View file @
fa07d232
...
@@ -36,6 +36,7 @@ describe QA::Page::Base do
...
@@ -36,6 +36,7 @@ describe QA::Page::Base do
describe
'.errors'
do
describe
'.errors'
do
let
(
:view
)
{
double
(
'view'
)
}
let
(
:view
)
{
double
(
'view'
)
}
context
'when page has views and elements defined'
do
before
do
before
do
allow
(
described_class
).
to
receive
(
:views
)
allow
(
described_class
).
to
receive
(
:views
)
.
and_return
([
view
])
.
and_return
([
view
])
...
@@ -47,4 +48,16 @@ describe QA::Page::Base do
...
@@ -47,4 +48,16 @@ describe QA::Page::Base do
expect
(
described_class
.
errors
).
to
eq
[
'some error'
]
expect
(
described_class
.
errors
).
to
eq
[
'some error'
]
end
end
end
end
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
end
qa/spec/page/validator_spec.rb
View file @
fa07d232
...
@@ -69,13 +69,9 @@ describe QA::Page::Validator do
...
@@ -69,13 +69,9 @@ describe QA::Page::Validator do
end
end
describe
'#validate!'
do
describe
'#validate!'
do
it
'does raises an error with descriptive message'
do
it
'raises validation error'
do
message
=
<<~
EOS
We found validation errors!
EOS
expect
{
subject
.
validate!
}
expect
{
subject
.
validate!
}
.
to
raise_error
described_class
::
ValidationError
,
message
.
to
raise_error
described_class
::
ValidationError
end
end
end
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