Commit 170c07ef authored by Grzegorz Bizon's avatar Grzegorz Bizon

Fix QA pages validation delegation and memoization

parent fa07d232
...@@ -53,7 +53,7 @@ module QA ...@@ -53,7 +53,7 @@ module QA
return ["#{name} class does not have views / elements defined!"] return ["#{name} class does not have views / elements defined!"]
end end
@errors ||= views.map(&:errors).flatten views.map(&:errors).flatten
end end
class DSL class DSL
......
...@@ -2,7 +2,7 @@ module QA ...@@ -2,7 +2,7 @@ module QA
module Page module Page
class Validator class Validator
ValidationError = Class.new(StandardError) ValidationError = Class.new(StandardError)
Error = Struct.new(:page, :view, :message) Error = Struct.new(:page, :message)
def initialize(constant) def initialize(constant)
@module = constant @module = constant
...@@ -28,12 +28,10 @@ module QA ...@@ -28,12 +28,10 @@ module QA
end end
def errors def errors
@errors ||= Array.new.tap do |errors| Array.new.tap do |errors|
descendants.each do |page| descendants.each do |page|
page.views.each do |view| page.errors.each do |message|
view.errors.each do |message| errors.push(Error.new(page.name, message))
errors.push(Error.new(page.name, view.path, message))
end
end end
end end
end end
......
...@@ -13,7 +13,6 @@ module QA ...@@ -13,7 +13,6 @@ module QA
end end
validators.map(&:errors).flatten.tap do |errors| validators.map(&:errors).flatten.tap do |errors|
end end
validators.each(&:validate!) validators.each(&:validate!)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment