Sha256: 9b53d218a84cc313f460a0de24c0a9cb0957c68bde37e500da2a8b29ed10cd29

Contents?: true

Size: 990 Bytes

Versions: 2

Compression:

Stored size: 990 Bytes

Contents

Then(/^a file with a "([^"]*)" extension and today's date(?: with format "([^"]*)")?(?: with suffix "([^"]*)")? should exist(?: within "([^"]*)")?/) do |extension, date_format, suffix, directory|
  step "the file named \"#{filename(extension, date_format || "%d-%m-%Y", suffix || "", directory)}\" should exist"
end

Given(/^a file with a "([^"]*)" extension and today's date exists with content "([^"]*)"$/) do |extension, content|
  steps %Q{
   Given a file named "#{filename(extension)}" with:
     """
     #{content}
     """
  }
end

Then(/^the file with a "([^"]*)" extension and today's date sould have content "([^"]*)"$/) do |extension, content|
  step "the file \"#{filename(extension)}\" should contain \"#{content}\""
end

def filename(extension, date_format = '%d-%m-%Y', suffix = '', directory = nil)
  today = Date.today.strftime(date_format)
  filename = "#{today}#{suffix}.#{extension}"

  if directory
    filename.prepend("#{directory}/")
  else
    filename
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kmkr-0.0.2 features/step_definitions/kmkr_steps.rb
kmkr-0.0.1 features/step_definitions/kmkr_steps.rb