diff --git a/features/with_gametel_option.feature b/features/with_gametel_option.feature new file mode 100644 index 0000000..b3f0a1a --- /dev/null +++ b/features/with_gametel_option.feature @@ -0,0 +1,25 @@ +Feature: Adding the --with-gametel flag + + Scenario: Adding the require_all and gametel gems to Gemfile + When I run `testgen project sample --with-gametel` + Then a file named "sample/Gemfile" should exist + And the file "sample/Gemfile" should contain "gem 'require_all'" + And the file "sample/Gemfile" should contain "gem 'gametel'" + + Scenario: Adding page-object to env.rb + When I run `testgen project sample --with-gametel` + Then a file named "sample/features/support/env.rb" should exist + And the file "sample/features/support/env.rb" should contain "require 'gametel'" + And the file "sample/features/support/env.rb" should contain "World(Gametel::Navigation)" + + Scenario: Should not create the hooks file + When I run `testgen project sample --with-gametel` + Then a file named "sample/features/support/hooks.rb" should not exist + + Scenario: Creating the pages directory under support + When I run `testgen project sample --with-gametel` + Then a directory named "sample/features/support/screens" should exist + + Scenario: Creating the pages directory under lib when using --wth-lib + When I run `testgen project sample --with-gametel --with-lib` + Then a directory named "sample/lib/screens" should exist diff --git a/lib/testgen/cli.rb b/lib/testgen/cli.rb index ead2a40..0bc935b 100644 --- a/lib/testgen/cli.rb +++ b/lib/testgen/cli.rb @@ -7,11 +7,13 @@ class CLI < Thor desc "project ", "Create a new test project" method_option :pageobject_driver, :type => :string, :required => false, :desc => "Use the PageObject gem to drive browsers. Valid values are 'watir' and 'selenium'" method_option :with_lib, :type => :boolean, :desc => "Place shared objects under lib directory" + method_option :with_gametel, :type => :boolean, :desc => "Add support for gametel gem" def project(name) driver = options[:pageobject_driver].nil? ? 'none' : options[:pageobject_driver] - with_lib = options[:with_lib] == true ? 'true' : 'false' - TestGen::Generators::Project.start([name, driver, with_lib]) + with_lib = options[:with_lib] ? 'true' : 'false' + with_gametel = options[:with_gametel] ? 'true' : 'false' + TestGen::Generators::Project.start([name, driver, with_lib, with_gametel]) end end -end \ No newline at end of file +end diff --git a/lib/testgen/generators/project.rb b/lib/testgen/generators/project.rb index 78c8c4e..83f119b 100644 --- a/lib/testgen/generators/project.rb +++ b/lib/testgen/generators/project.rb @@ -9,6 +9,7 @@ class Project < Thor::Group argument :name, :type => :string, :desc => 'The name of the project' argument :pageobject_driver, :type => :string, :desc => 'Driver to use with PageObject' argument :with_lib, :type => :string, :desc => 'Place all shared objects in the lib directory' + argument :with_gametel, :type => :string, :desc => 'Add support for the gametel gem' desc "Generates a project structure for testing with Cucumber" def self.source_root @@ -52,8 +53,10 @@ def create_lib_directory def create_pages_directory if gen_lib empty_directory("#{name}/lib/pages") unless no_driver_selected + empty_directory("#{name}/lib/screens") if with_gametel == 'true' else empty_directory("#{name}/features/support/pages") unless no_driver_selected + empty_directory("#{name}/features/support/screens") if with_gametel == 'true' end end @@ -68,4 +71,4 @@ def gen_lib end end end -end \ No newline at end of file +end diff --git a/lib/testgen/generators/project/Gemfile.tt b/lib/testgen/generators/project/Gemfile.tt index 9ca7be6..5dc7f78 100644 --- a/lib/testgen/generators/project/Gemfile.tt +++ b/lib/testgen/generators/project/Gemfile.tt @@ -5,7 +5,10 @@ gem 'rspec' <% unless pageobject_driver.downcase == 'none' -%> gem 'page-object' <% end -%> -<% if with_lib == 'true' -%> +<% if with_lib == 'true' or with_gametel == 'true' -%> gem 'require_all' <% end -%> +<% if with_gametel == 'true' -%> +gem 'gametel' +<% end -%> diff --git a/lib/testgen/generators/project/env.rb.tt b/lib/testgen/generators/project/env.rb.tt index 7d1ab52..90fe3ef 100644 --- a/lib/testgen/generators/project/env.rb.tt +++ b/lib/testgen/generators/project/env.rb.tt @@ -6,14 +6,19 @@ require 'rspec-expectations' <% unless pageobject_driver.downcase == 'none' -%> require 'page-object' require 'page-object/page_factory' -<% end %> +<% end -%> <% if with_lib == 'true' -%> require 'require_all' require_all 'lib' <% end -%> +<% if with_gametel == 'true' -%> +require 'gametel' + +World(Gametel::Navigation) +<% end -%> <% unless pageobject_driver.downcase == 'none' -%> World(PageObject::PageFactory) -<% end %> +<% end -%>