Skip to content

Commit

Permalink
added the --with-gametel option
Browse files Browse the repository at this point in the history
  • Loading branch information
cheezy committed Aug 20, 2012
1 parent e2bb4e5 commit 1c40d13
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 7 deletions.
25 changes: 25 additions & 0 deletions features/with_gametel_option.feature
Original file line number Original file line Diff line number Diff line change
@@ -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
8 changes: 5 additions & 3 deletions lib/testgen/cli.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ class CLI < Thor
desc "project <project_name>", "Create a new test project" 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 :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_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) def project(name)
driver = options[:pageobject_driver].nil? ? 'none' : options[:pageobject_driver] driver = options[:pageobject_driver].nil? ? 'none' : options[:pageobject_driver]
with_lib = options[:with_lib] == true ? 'true' : 'false' with_lib = options[:with_lib] ? 'true' : 'false'
TestGen::Generators::Project.start([name, driver, with_lib]) with_gametel = options[:with_gametel] ? 'true' : 'false'
TestGen::Generators::Project.start([name, driver, with_lib, with_gametel])
end end


end end
end end
5 changes: 4 additions & 1 deletion lib/testgen/generators/project.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Project < Thor::Group
argument :name, :type => :string, :desc => 'The name of the project' argument :name, :type => :string, :desc => 'The name of the project'
argument :pageobject_driver, :type => :string, :desc => 'Driver to use with PageObject' 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_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" desc "Generates a project structure for testing with Cucumber"


def self.source_root def self.source_root
Expand Down Expand Up @@ -52,8 +53,10 @@ def create_lib_directory
def create_pages_directory def create_pages_directory
if gen_lib if gen_lib
empty_directory("#{name}/lib/pages") unless no_driver_selected empty_directory("#{name}/lib/pages") unless no_driver_selected
empty_directory("#{name}/lib/screens") if with_gametel == 'true'
else else
empty_directory("#{name}/features/support/pages") unless no_driver_selected empty_directory("#{name}/features/support/pages") unless no_driver_selected
empty_directory("#{name}/features/support/screens") if with_gametel == 'true'
end end
end end


Expand All @@ -68,4 +71,4 @@ def gen_lib
end end
end end
end end
end end
5 changes: 4 additions & 1 deletion lib/testgen/generators/project/Gemfile.tt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ gem 'rspec'
<% unless pageobject_driver.downcase == 'none' -%> <% unless pageobject_driver.downcase == 'none' -%>
gem 'page-object' gem 'page-object'
<% end -%> <% end -%>
<% if with_lib == 'true' -%> <% if with_lib == 'true' or with_gametel == 'true' -%>
gem 'require_all' gem 'require_all'
<% end -%> <% end -%>
<% if with_gametel == 'true' -%>
gem 'gametel'
<% end -%>


9 changes: 7 additions & 2 deletions lib/testgen/generators/project/env.rb.tt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ require 'rspec-expectations'
<% unless pageobject_driver.downcase == 'none' -%> <% unless pageobject_driver.downcase == 'none' -%>
require 'page-object' require 'page-object'
require 'page-object/page_factory' require 'page-object/page_factory'
<% end %> <% end -%>
<% if with_lib == 'true' -%> <% if with_lib == 'true' -%>
require 'require_all' require 'require_all'


require_all 'lib' require_all 'lib'
<% end -%> <% end -%>


<% if with_gametel == 'true' -%>
require 'gametel'

World(Gametel::Navigation)
<% end -%>


<% unless pageobject_driver.downcase == 'none' -%> <% unless pageobject_driver.downcase == 'none' -%>
World(PageObject::PageFactory) World(PageObject::PageFactory)
<% end %> <% end -%>

0 comments on commit 1c40d13

Please sign in to comment.