From cbc67b485efff3f51e86131a0da5af5a38a59955 Mon Sep 17 00:00:00 2001 From: Richard Clamp Date: Mon, 16 Oct 2017 10:15:50 +0100 Subject: Move rspec cli handling logic into Specs::Runner Here we convert Specs::Runner#rspec to use keyword arguments[1] and pass named parameters rather than a pre-processed array of cli switches. This allows parameter to cli logic to live just in Specs::Runner. [1] https://robots.thoughtbot.com/ruby-2-keyword-arguments --- qa/qa/scenario/entrypoint.rb | 10 +++++++--- qa/qa/specs/runner.rb | 9 ++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'qa') diff --git a/qa/qa/scenario/entrypoint.rb b/qa/qa/scenario/entrypoint.rb index e58bb53f88a..33cb2696f8f 100644 --- a/qa/qa/scenario/entrypoint.rb +++ b/qa/qa/scenario/entrypoint.rb @@ -9,8 +9,8 @@ module QA @tags = tags end - def self.tag_switches - @tags.map { |tag| ['-t', tag.to_s] } + def self.get_tags + @tags end def perform(address, *files) @@ -24,7 +24,11 @@ module QA Runtime::Release.perform_before_hooks Specs::Runner.perform do |specs| - specs.rspec('--tty', self.class.tag_switches, files.any? ? files : 'qa/specs/features') + specs.rspec( + tty: true, + tags: self.class.get_tags, + files: files.any? ? files : 'qa/specs/features' + ) end end end diff --git a/qa/qa/specs/runner.rb b/qa/qa/specs/runner.rb index 83ae15d0995..2aa18d5d3a1 100644 --- a/qa/qa/specs/runner.rb +++ b/qa/qa/specs/runner.rb @@ -5,7 +5,14 @@ module QA class Runner include Scenario::Actable - def rspec(*args) + def rspec(tty: false, tags: [], files: ['qa/specs/features']) + args = [] + args << '--tty' if tty + tags.to_a.each do |tag| + args << ['-t', tag.to_s] + end + args << files + RSpec::Core::Runner.run(args.flatten, $stderr, $stdout).tap do |status| abort if status.nonzero? end -- cgit v1.2.1