Skip to content
Browse files

added the --with-gametel option

  • Loading branch information...
1 parent e2bb4e5 commit 1c40d139b25004764d3aebd4cd617bf3ffb0cb09 @cheezy committed Aug 20, 2012
View
25 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
View
8 lib/testgen/cli.rb
@@ -7,11 +7,13 @@ class CLI < Thor
desc "project <project_name>", "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
+end
View
5 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
+end
View
5 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 -%>
View
9 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 -%>

0 comments on commit 1c40d13

Please sign in to comment.
Something went wrong with that request. Please try again.