#!/usr/bin/env ruby # frozen_string_literal: true require 'thor' require 'English' $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib') # Executable for Generic Test class Exe < Thor def self.exit_on_failure? true end desc 'page page_url', 'Test web page' method_options all_subpages: false method_options spellcheck: true def page(page_url) ENV['PAGE_URL'] = page_url ENV['ALL_SUBPAGES'] ||= options.all_subpages?.to_s ENV['SPELLCHECK_ON'] = options.spellcheck?.to_s test_file_path = File.join(File.dirname(__FILE__), '..', 'spec', 'generic_test_spec.rb') raise "no file at #{test_file_path}" unless File.exist? test_file_path desc = ENV['PAGE_URL'].split('://').last.tr('/', '_') junit_format = "-f RspecJunitFormatter --out logs/page_#{desc}.xml" ENV['REPORT_PATH'] = "reports/#{desc}" html_format = '--format html --out logs/report.html' command = "rspec #{test_file_path} --format documentation --color #{junit_format} #{html_format}" raise $CHILD_STATUS.to_s unless system command end desc 'version', 'Version of generic_test' def version require 'generic_test' puts "GenericTest version #{GenericTest::VERSION}" end end Exe.start(ARGV)