testgen 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,6 @@
1
+ === Version 0.2 / 2011-09-29
2
+ * Added ability to generate artifacts necessary to use page-object
3
+
1
4
  === Version 0.1 / 2011-09-27
2
5
  * Initial release that contains a simple project generator
3
6
 
data/Rakefile CHANGED
@@ -3,11 +3,6 @@ require 'rspec/core/rake_task'
3
3
  require 'cucumber'
4
4
  require 'cucumber/rake/task'
5
5
 
6
- RSpec::Core::RakeTask.new(:spec) do |spec|
7
- spec.ruby_opts = "-I lib:spec"
8
- spec.pattern = 'spec/**/*_spec.rb'
9
- end
10
- task :spec
11
6
 
12
7
  Cucumber::Rake::Task.new(:features, "Run features") do |t|
13
8
  t.profile = 'default'
@@ -17,7 +12,4 @@ task :lib do
17
12
  $LOAD_PATH.unshift(File.expand_path("lib", File.dirname(__FILE__)))
18
13
  end
19
14
 
20
- desc 'Run all specs and cukes'
21
- task :test => ['spec', 'features']
22
-
23
- task :default => :test
15
+ task :default => :features
@@ -0,0 +1,27 @@
1
+ Feature: Adding support for the --pageobject-driver option
2
+
3
+
4
+ Scenario: Adding page-object to the Gemfile
5
+ When I run `testgen project sample --pageobject-driver=watir`
6
+ Then a file named "sample/Gemfile" should exist
7
+ And the file "sample/Gemfile" should contain "gem 'page-object'"
8
+
9
+ Scenario: Adding page-object to env.rb
10
+ When I run `testgen project sample --pageobject-driver=watir`
11
+ Then a file named "sample/features/support/env.rb" should exist
12
+ And the file "sample/features/support/env.rb" should contain "require 'page-object'"
13
+ And the file "sample/features/support/env.rb" should contain "require 'page-object/page_factory'"
14
+ And the file "sample/features/support/env.rb" should contain "World(PageObject::PageFactory)"
15
+
16
+ Scenario: Adding the hook file for Watir
17
+ When I run `testgen project sample --pageobject-driver=watir`
18
+ Then a file named "sample/features/support/hooks.rb" should exist
19
+ And the file "sample/features/support/hooks.rb" should contain "require 'watir-webdriver'"
20
+ And the file "sample/features/support/hooks.rb" should contain "@browser = Watir::Browser.new :firefox"
21
+
22
+ Scenario: Adding the hook file for Selenium
23
+ When I run `testgen project sample --pageobject-driver=selenium`
24
+ Then a file named "sample/features/support/hooks.rb" should exist
25
+ And the file "sample/features/support/hooks.rb" should contain "require 'selenium-webdriver'"
26
+ And the file "sample/features/support/hooks.rb" should contain "@browser = Selenium::Webdriver.for :firefox"
27
+
@@ -3,9 +3,13 @@ require 'testgen/generators/project'
3
3
 
4
4
  module TestGen
5
5
  class CLI < Thor
6
+
6
7
  desc "project <project_name>", "Create a new test project"
8
+ method_option :pageobject_driver, :type => :string, :required => false, :desc => "Use the PageObject gem to drive browsers. Valid values are 'watir' and 'selenium'"
7
9
  def project(name)
8
- TestGen::Generators::Project.start([name])
10
+ driver = options[:pageobject_driver].nil? ? 'none' : options[:pageobject_driver]
11
+ TestGen::Generators::Project.start([name, driver])
9
12
  end
13
+
10
14
  end
11
15
  end
@@ -7,6 +7,7 @@ module TestGen
7
7
  include Thor::Actions
8
8
 
9
9
  argument :name, :type => :string, :desc => 'The name of the project'
10
+ argument :pageobject_driver, :type => :string, :desc => 'Driver to use with PageObject'
10
11
  desc "Generates a project structure for testing with Cucumber"
11
12
 
12
13
  def self.source_root
@@ -18,11 +19,11 @@ module TestGen
18
19
  end
19
20
 
20
21
  def copy_cucumber_yml
21
- template("cucumber.yml", "#{name}/cucumber.yml")
22
+ template "cucumber.yml.tt", "#{name}/cucumber.yml"
22
23
  end
23
24
 
24
25
  def copy_gemfile
25
- copy_file "Gemfile", "#{name}/Gemfile"
26
+ template "Gemfile.tt", "#{name}/Gemfile"
26
27
  end
27
28
 
28
29
  def copy_rakefile
@@ -36,7 +37,11 @@ module TestGen
36
37
  end
37
38
 
38
39
  def copy_env
39
- copy_file "env.rb", "#{name}/features/support/env.rb"
40
+ template "env.rb.tt", "#{name}/features/support/env.rb"
41
+ end
42
+
43
+ def copy_hooks
44
+ template "hooks.rb.tt", "#{name}/features/support/hooks.rb" unless pageobject_driver.downcase == 'none'
40
45
  end
41
46
  end
42
47
  end
@@ -0,0 +1,5 @@
1
+ gem 'cucumber'
2
+ gem 'rspec'
3
+ <% unless pageobject_driver.downcase == 'none' -%>
4
+ gem 'page-object'
5
+ <% end -%>
@@ -0,0 +1,10 @@
1
+ require 'rspec-expectations'
2
+ <% unless pageobject_driver.downcase == 'none' -%>
3
+ require 'page-object'
4
+ require 'page-object/page_factory'
5
+ <% end %>
6
+
7
+
8
+ <% unless pageobject_driver.downcase == 'none' -%>
9
+ World(PageObject::PageFactory)
10
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <% if pageobject_driver.downcase == 'watir' -%>
2
+ require 'watir-webdriver'
3
+ <% end %>
4
+ <% if pageobject_driver.downcase == 'selenium' -%>
5
+ require 'selenium-webdriver'
6
+ <% end %>
7
+
8
+ Before do
9
+ <% if pageobject_driver.downcase == 'watir' -%>
10
+ @browser = Watir::Browser.new :firefox
11
+ <% end %>
12
+ <% if pageobject_driver.downcase == 'selenium' -%>
13
+ @browser = Selenium::Webdriver.for :firefox
14
+ <% end %>
15
+ end
16
+
17
+
18
+ After do
19
+ @browser.close
20
+ end
@@ -1,3 +1,3 @@
1
1
  module TestGen
2
- VERSION = "0.1"
2
+ VERSION = "0.2"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: testgen
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "0.1"
5
+ version: "0.2"
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jeffrey S. Morgan
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-09-27 00:00:00 Z
13
+ date: 2011-09-29 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -88,13 +88,15 @@ files:
88
88
  - features/support/env.rb
89
89
  - features/support/hooks.rb
90
90
  - features/testgen_project.feature
91
+ - features/testgen_with_pageobject.feature
91
92
  - lib/testgen.rb
92
93
  - lib/testgen/cli.rb
93
94
  - lib/testgen/generators/project.rb
94
- - lib/testgen/generators/project/Gemfile
95
+ - lib/testgen/generators/project/Gemfile.tt
95
96
  - lib/testgen/generators/project/Rakefile
96
- - lib/testgen/generators/project/cucumber.yml
97
- - lib/testgen/generators/project/env.rb
97
+ - lib/testgen/generators/project/cucumber.yml.tt
98
+ - lib/testgen/generators/project/env.rb.tt
99
+ - lib/testgen/generators/project/hooks.rb.tt
98
100
  - lib/testgen/version.rb
99
101
  - testgen.gemspec
100
102
  homepage: http://github.com/cheezy/testgen
@@ -128,3 +130,4 @@ test_files:
128
130
  - features/support/env.rb
129
131
  - features/support/hooks.rb
130
132
  - features/testgen_project.feature
133
+ - features/testgen_with_pageobject.feature
@@ -1,2 +0,0 @@
1
- gem 'cucumber'
2
- gem 'rspec'
@@ -1 +0,0 @@
1
- require 'rspec-expectations'