lib/watirsplash/cli.rb in watirsplash-1.4.3 vs lib/watirsplash/cli.rb in watirsplash-2.0.0.rc1

- old
+ new

@@ -1,40 +1,36 @@ require "thor" require "thor/group" +require "watirsplash/generators/helper" require "watirsplash/generators/new_project" -require "watirsplash/generators/new_common_project" -require "watirsplash/generators/migrate_project" +require "watirsplash/generators/page" require "watirsplash/util" module WatirSplash class CLI < Thor - framework_option = proc do - method_option :framework, :default => WatirSplash::Util.send(:default_framework).to_s, :aliases => "-f", - :desc => "Framework to use. Possible values are watir, firewatir, watir-webdriver/ie, watir-webdriver/firefox, watir-webdriver/chrome." - end + extend Generators::Helper - desc "new [APPLICATION_NAME]", "Create a new WatirSplash project." - method_option :load_common, :type => :boolean, :default => false, :aliases => "-l", - :desc => "Load WatirSplash common project automatically." - method_option :url, :default => "about:blank", :aliases => "-u", - :desc => "URL to open in the browser before each test. May be relative if WatirSplash common project is loaded." - framework_option.call - def new(name = "Application") - WatirSplash::Generators::NewProject.start([Thor::Util.camel_case(name), options[:url], options[:framework], options.load_common?]) + unless Dir.entries(Dir.pwd).include? ".rspec" + desc "new [DIRECTORY_NAME]", "Create a new WatirSplash project." + method_option :url, :default => "about:blank", :aliases => "-u", + :desc => "URL for the application under test." + method_option :framework, :default => "default", :aliases => "-f", + :desc => "Framework to use. Possible values are #{supported_frameworks.join(", ")}." + def new(name = "ui-test") + WatirSplash::Generators::NewProject.start([name, options[:url], options[:framework]]) + end end - desc "new_common", "Create a new WatirSplash common project." - method_option :url, :default => "http://localhost", :aliases => "-u", - :desc => "URL for the application main page." - framework_option.call - def new_common - WatirSplash::Generators::NewCommonProject.start([options[:url], options[:framework]]) - end - - if File.basename(Dir.pwd) =~ /^ui-test(-common)?$/ - desc "migrate", "Migrates old WatirSplash generated project to new." - def migrate - WatirSplash::Generators::MigrateProject.start + if Dir.entries(Dir.pwd).include? ".rspec" + desc "page PAGE_NAME [element_name:element_type:locator_name:locator_value]", "Create a new WatirSplash page." + method_option :spec, :default => true, :aliases => "-s", :type => :boolean, + :desc => "Create spec file for page." + method_option :url, :default => nil, :aliases => "-u", + :desc => "URL for the page if directly accessible." + method_option :module, :default => "App", :aliases => "-m", + :desc => "Namespace module for the page." + def page(page_name = "Main", *elements) + WatirSplash::Generators::Page.start([page_name.gsub("-", "_"), elements, options[:module].gsub("-", "_"), options[:spec], options[:url]]) end end end end