lib/venom/generators/workshop.rb in venom-0.0.2 vs lib/venom/generators/workshop.rb in venom-0.0.3

- old
+ new

@@ -5,37 +5,44 @@ 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 shared library directory." + 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") - empty_directory("#{name}/specs/support/test_steps") + if use_library + empty_directory("#{name}/lib/test_steps") + else + empty_directory("#{name}/specs/support/test_steps") + end empty_directory("#{name}/specs/support/test_data") end - - def create_library_directory - empty_directory("#{name}/lib") if use_library - end - + def create_definitions_directory if use_library empty_directory("#{name}/lib/definitions") else empty_directory("#{name}/specs/definitions") @@ -52,21 +59,29 @@ 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 - copy_file "hooks.rb", "#{name}/specs/support/hooks.rb" + template "hooks.rb.tt", "#{name}/specs/support/hooks.rb" end private def use_library library == 'true' + end + + def restart_browser + restart == 'true' end end # class: Workshop end # module: Generators end # module: Venom