You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

project_initializer.rb 1.0 kB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # frozen_string_literal: true
  2. module Cucumber
  3. # Generates generic file structure for a cucumber project
  4. class ProjectInitializer
  5. def run
  6. create_directory('features')
  7. create_directory('features/step_definitions')
  8. create_directory('features/support')
  9. create_file('features/support/env.rb')
  10. end
  11. private
  12. def create_directory(dir_name)
  13. create_directory_or_file dir_name, true
  14. end
  15. def create_file(file_name)
  16. create_directory_or_file file_name, false
  17. end
  18. def create_directory_or_file(file_name, directory)
  19. file_type = if directory
  20. :mkdir_p
  21. else
  22. :touch
  23. end
  24. report_exists(file_name) || return if File.exist?(file_name)
  25. report_creating(file_name)
  26. FileUtils.send file_type, file_name
  27. end
  28. def report_exists(file)
  29. puts " exist #{file}"
  30. end
  31. def report_creating(file)
  32. puts " create #{file}"
  33. end
  34. end
  35. end

No Description

Contributors (1)