QA: Prefer flat_map
over map
+ flatten
This commit is contained in:
parent
5595c9ded4
commit
510d03fec2
4 changed files with 7 additions and 9 deletions
|
@ -181,11 +181,11 @@ module QA
|
|||
return ["Page class does not have views / elements defined!"]
|
||||
end
|
||||
|
||||
views.map(&:errors).flatten
|
||||
views.flat_map(&:errors)
|
||||
end
|
||||
|
||||
def self.elements
|
||||
views.map(&:elements).flatten
|
||||
views.flat_map(&:elements)
|
||||
end
|
||||
|
||||
def send_keys_to_element(name, keys)
|
||||
|
|
|
@ -22,16 +22,14 @@ module QA
|
|||
end
|
||||
|
||||
def descendants
|
||||
@descendants ||= constants.map do |const|
|
||||
@descendants ||= constants.flat_map do |const|
|
||||
case const
|
||||
when Class
|
||||
const if const < Page::Base
|
||||
when Module
|
||||
Page::Validator.new(const).descendants
|
||||
end
|
||||
end
|
||||
|
||||
@descendants.flatten.compact
|
||||
end.compact
|
||||
end
|
||||
|
||||
def errors
|
||||
|
|
|
@ -14,7 +14,7 @@ module QA
|
|||
Page::Validator.new(pages)
|
||||
end
|
||||
|
||||
validators.map(&:errors).flatten.tap do |errors|
|
||||
validators.flat_map(&:errors).tap do |errors|
|
||||
break if errors.none?
|
||||
|
||||
warn <<~EOS
|
||||
|
|
|
@ -125,9 +125,9 @@ describe QA::Specs::Runner do
|
|||
end
|
||||
|
||||
def excluded_feature_tags_except(tag)
|
||||
QA::Runtime::Env.supported_features.except(tag).map do |tag, _|
|
||||
QA::Runtime::Env.supported_features.except(tag).flat_map do |tag, _|
|
||||
['--tag', "~requires_#{tag}"]
|
||||
end.flatten
|
||||
end
|
||||
end
|
||||
|
||||
def expect_rspec_runner_arguments(arguments)
|
||||
|
|
Loading…
Reference in a new issue