Append page validation error if view partial is missing
This commit is contained in:
parent
d69e4541a4
commit
d2c2f93fe6
|
@ -9,11 +9,15 @@ module QA
|
|||
end
|
||||
|
||||
def pathname
|
||||
Pathname.new(File.join( __dir__, '../../../', @path))
|
||||
@pathname ||= Pathname.new(File.join( __dir__, '../../../', @path))
|
||||
.cleanpath.expand_path
|
||||
end
|
||||
|
||||
def errors
|
||||
unless pathname.readable?
|
||||
return ["Missing view partial `#{pathname}`!"]
|
||||
end
|
||||
|
||||
##
|
||||
# Reduce required elements by streaming view and making assertions on
|
||||
# elements' existence.
|
||||
|
|
|
@ -30,6 +30,12 @@ describe QA::Page::View do
|
|||
allow(File).to receive(:new).and_return(file)
|
||||
end
|
||||
|
||||
context 'when view partial is present' do
|
||||
before do
|
||||
allow(subject.pathname).to receive(:readable?)
|
||||
.and_return(true)
|
||||
end
|
||||
|
||||
context 'when pattern is found' do
|
||||
before do
|
||||
allow(file).to receive(:foreach)
|
||||
|
@ -57,9 +63,14 @@ describe QA::Page::View do
|
|||
.to match %r(Missing element `.*` in `.*/some/file.html` view)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when view partial has not been found' do
|
||||
pending
|
||||
it 'returns an error when it is not able to find the partial' do
|
||||
expect(subject.errors).to be_one
|
||||
expect(subject.errors.first)
|
||||
.to match %r(Missing view partial `.*/some/file.html`!)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue