Merge pull request #4934 from pathawks/features

Merge pull request 4934
This commit is contained in:
jekyllbot 2016-05-26 10:20:42 -07:00
commit f73b2d0a01
2 changed files with 41 additions and 31 deletions

View File

@ -1,7 +1,7 @@
require 'fileutils' require "fileutils"
require 'colorator' require "colorator"
require 'cucumber/formatter/console' require "cucumber/formatter/console"
require 'cucumber/formatter/io' require "cucumber/formatter/io"
module Jekyll module Jekyll
module Cucumber module Cucumber
@ -17,7 +17,7 @@ module Jekyll
:undefined => "\u2718".red, :undefined => "\u2718".red,
:passed => "\u2714".green, :passed => "\u2714".green,
:skipped => "\u203D".blue :skipped => "\u203D".blue
} }.freeze
# #
@ -34,7 +34,7 @@ module Jekyll
# #
def before_features(features) def before_features(_features)
print_profile_information print_profile_information
end end
@ -47,7 +47,7 @@ module Jekyll
# #
def before_feature(feature) def before_feature(_feature)
@exceptions = [] @exceptions = []
@indent = 0 @indent = 0
end end
@ -55,20 +55,23 @@ module Jekyll
# #
def tag_name(tag_name); end def tag_name(tag_name); end
def comment_line(comment_line); end def comment_line(comment_line); end
def after_feature_element(feature_element); end def after_feature_element(feature_element); end
def after_tags(tags); end def after_tags(tags); end
# #
def before_feature_element(feature_element) def before_feature_element(_feature_element)
@indent = 2 @indent = 2
@scenario_indent = 2 @scenario_indent = 2
end end
# #
def before_background(background) def before_background(_background)
@scenario_indent = 2 @scenario_indent = 2
@in_background = true @in_background = true
@indent = 2 @indent = 2
@ -76,7 +79,7 @@ module Jekyll
# #
def after_background(background) def after_background(_background)
@in_background = nil @in_background = nil
end end
@ -104,8 +107,9 @@ module Jekyll
# #
def before_step_result(keyword, step_match, multiline_arg, status, exception, \ # rubocop:disable Metrics/ParameterLists
source_indent, background, file_colon_line) def before_step_result(_keyword, _step_match, _multiline_arg, status, exception, \
_source_indent, background, _file_colon_line)
@hide_this_step = false @hide_this_step = false
if exception if exception
@ -127,10 +131,11 @@ module Jekyll
# #
def step_name(keyword, step_match, status, source_indent, background, file_colon_line) def step_name(_keyword, _step_match, status, _source_indent, _background, _file_colon_line)
@io.print CHARS[status] @io.print CHARS[status]
@io.print " " @io.print " "
end end
# rubocop:enable Metrics/ParameterLists
# #
@ -153,7 +158,7 @@ module Jekyll
# #
private private
def print_feature_element_name(keyword, name, source_line, indent) def print_feature_element_name(keyword, name, source_line, _indent)
@io.puts @io.puts
names = name.empty? ? [name] : name.each_line.to_a names = name.empty? ? [name] : name.each_line.to_a

View File

@ -7,25 +7,30 @@ require "safe_yaml/load"
class Paths class Paths
SOURCE_DIR = Pathname.new(File.expand_path("../..", __dir__)) SOURCE_DIR = Pathname.new(File.expand_path("../..", __dir__))
def self.test_dir; source_dir.join("tmp", "jekyll"); end def self.test_dir; source_dir.join("tmp", "jekyll"); end
def self.output_file; test_dir.join("jekyll_output.txt"); end def self.output_file; test_dir.join("jekyll_output.txt"); end
def self.status_file; test_dir.join("jekyll_status.txt"); end def self.status_file; test_dir.join("jekyll_status.txt"); end
def self.jekyll_bin; source_dir.join("bin", "jekyll"); end def self.jekyll_bin; source_dir.join("bin", "jekyll"); end
def self.source_dir; SOURCE_DIR; end def self.source_dir; SOURCE_DIR; end
end end
# #
def file_content_from_hash(input_hash) def file_content_from_hash(input_hash)
matter_hash = input_hash.reject { |k, v| k == "content" } matter_hash = input_hash.reject { |k, _v| k == "content" }
matter = matter_hash.map do |k, v| "#{k}: #{v}\n" matter = matter_hash.map do |k, v|
"#{k}: #{v}\n"
end end
matter = matter.join.chomp matter = matter.join.chomp
content = \ content = \
if !input_hash['input'] || !input_hash['filter'] if !input_hash["input"] || !input_hash["filter"]
then input_hash['content'] then input_hash["content"]
else "{{ #{input_hash['input']} | " \ else "{{ #{input_hash["input"]} | " \
"#{input_hash['filter']} }}" "#{input_hash["filter"]} }}"
end end
Jekyll::Utils.strip_heredoc(<<-EOF) Jekyll::Utils.strip_heredoc(<<-EOF)
@ -78,7 +83,7 @@ end
# #
def run_bundle(args) def run_bundle(args)
run_in_shell("bundle", *args.strip.split(' ')) run_in_shell("bundle", *args.strip.split(" "))
end end
# #
@ -91,14 +96,13 @@ end
# #
# rubocop:disable Metrics/AbcSize
def run_in_shell(*args) def run_in_shell(*args)
i, o, e, p = Open3.popen3(*args) i, o, e, p = Open3.popen3(*args)
out = o.read.strip out = o.read.strip
err = e.read.strip err = e.read.strip
[i, o, e].each do |m| [i, o, e].each(&:close)
m.close
end
File.write(Paths.status_file, p.value.exitstatus) File.write(Paths.status_file, p.value.exitstatus)
File.open(Paths.output_file, "wb") do |f| File.open(Paths.output_file, "wb") do |f|
@ -110,13 +114,14 @@ def run_in_shell(*args)
p.value p.value
end end
# rubocop:enable Metrics/AbcSize
# #
def slug(title = nil) def slug(title = nil)
if !title if !title
then Time.now.strftime("%s%9N") # nanoseconds since the Epoch then Time.now.strftime("%s%9N") # nanoseconds since the Epoch
else title.downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-') else title.downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, "-")
end end
end end
@ -128,8 +133,8 @@ def location(folder, direction)
after = folder if direction == "under" after = folder if direction == "under"
end end
[before || '.', [before || ".",
after || '.'] after || "."]
end end
# #
@ -156,6 +161,6 @@ end
def seconds_agnostic_time(time) def seconds_agnostic_time(time)
time = time.strftime("%H:%M:%S") if time.is_a?(Time) time = time.strftime("%H:%M:%S") if time.is_a?(Time)
hour, minutes, _ = time.split(":") hour, minutes, = time.split(":")
"#{hour}:#{minutes}" "#{hour}:#{minutes}"
end end