Sha256: bc82c8739348cd4a011c59f7102a6b5f079ce551e8b0f33e76c5c4affdb85ae5

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

require 'rainbow'
Sickill::Rainbow.enabled = true
CONTENTS = [
  'This is the first line',
  'This is the second line and %{keyword} it contains the search term',
  'This is the last line',
]
Given /^a file named "([^"]*)" with the word "([^"]*)" in it$/ do |filename, keyword|
  @contents_without_ansi = CONTENTS.map { |line| line.gsub('%{keyword}','>>=').split('>>=') }.flatten
  @contents = CONTENTS.map { |line| line % { :keyword => keyword } }
  File.open(filename,'w') { |file| @contents.each { |_| file.puts _ } }
end

Then /^the entire contents of "([^"]*)" should be output$/ do |file|
  @contents_without_ansi.each { |_| assert_partial_output(_,all_stdout) }
end

Then /^the word "([^"]*)" should be highlighted in (.*$)$/ do |keyword,color|
  if color == 'bright inverted underlined blue'
    expected = Rainbow(keyword).color(:blue).inverse.bright.underline
  else
    expected = Rainbow(keyword).color(color.to_sym)
  end
  assert_partial_output(expected,all_stdout)
end

Then /^the word "([^"]*)" should be highlighted both times in (.*$)$/ do |keyword,color|
  expected = Rainbow(keyword).color(color.to_sym)
  all_stdout.should match /#{Regexp.escape(expected)}.*#{Regexp.escape(expected)}/
end

Then /^I type some text containing "([^"]*)"$/ do |keyword|
  @contents_without_ansi = CONTENTS.map { |line| line.gsub('%{keyword}','>>=').split('>>=') }.flatten
  contents = CONTENTS.map { |line| line % { :keyword => keyword } }
  contents.each do |line|
    step %{I type "#{line}"}
  end
  @interactive.stdin.close
end

Then /^the contents of what I typed should be output$/ do
  @contents_without_ansi.each { |_| assert_partial_output(_,all_stdout) }
end

Then /^I should see the help output$/ do
  step %{the banner should be present}
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hl-1.2.0 features/step_definitions/hl_steps.rb