require 'thor/group' module Venom module Generators class Workshop < Thor::Group include Thor::Actions argument :name, type: :string, desc: "Name of the workshop." argument :driver, type: :string, desc: "Driver to use with Symbiont." argument :library, type: :string, desc: "Use a shared library directory." argument :restart, type: :string, desc: "Restart browser with each scenario." desc "Generates a workshop structure." def self.source_root File.dirname(__FILE__) + "/workshop" end def spit_back_values puts "Create workshop '#{name}' using #{driver}." puts "Use a separate library." if use_library puts "Restart browser for each scenario." if restart_browser end def create_workshop_directory empty_directory(name) end def create_library_directory empty_directory("#{name}/lib") if use_library end def create_workshop_structure empty_directory("#{name}/specs") empty_directory("#{name}/specs/support") if use_library empty_directory("#{name}/lib/test_steps") empty_directory("#{name}/lib/test_data") empty_directory("#{name}/lib/test_helpers") else empty_directory("#{name}/specs/support/test_steps") empty_directory("#{name}/specs/support/test_data") empty_directory("#{name}/specs/support/test_helpers") end end def create_definitions_directory if use_library empty_directory("#{name}/lib/definitions") else empty_directory("#{name}/specs/definitions") end end def copy_dsl_runner copy_file "cucumber.yml", "#{name}/cucumber.yml" end def copy_rakefile copy_file "Rakefile", "#{name}/Rakefile" end def copy_gemfile template "Gemfile.tt", "#{name}/Gemfile" end def copy_driver template "driver.rb.tt", "#{name}/specs/support/driver.rb" end def copy_env template "env.rb.tt", "#{name}/specs/support/env.rb" end def copy_hooks template "hooks.rb.tt", "#{name}/specs/support/hooks.rb" end def copy_errors copy_file "errors.rb", "#{name}/specs/support/errors.rb" end def copy_base if use_library template "base.rb.tt", "#{name}/lib/definitions" else template "base.rb.tt", "#{name}/specs/definitions" end end private def use_library library == 'true' end def restart_browser restart == 'true' end end # class: Workshop end # module: Generators end # module: Venom