testgen 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ === Version 0.2.4
2
+ * Enhancements
3
+ * added --with-lib option to store pages in a lib directory off the project root
4
+
1
5
  === Version 0.2.3 / 2011-09-30
2
6
  * Fixed problem with hooks file when using Selenium
3
7
 
@@ -1,3 +1,6 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'lib'))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'bin'))
2
3
 
3
- require 'aruba/cucumber'
4
+ require 'aruba/cucumber'
5
+
6
+ require 'testgen'
@@ -0,0 +1,24 @@
1
+ Feature: Adding the --with-lib flag
2
+
3
+ Background:
4
+ When I run `testgen project sample --with-lib --pageobject-driver=watir`
5
+
6
+ Scenario: Adding the require_all gem to Gemfile
7
+ Then a file named "sample/Gemfile" should exist
8
+ And the file "sample/Gemfile" should contain "gem 'require_all'"
9
+
10
+ Scenario: Creating the lib directory
11
+ Then a directory named "sample/lib" should exist
12
+
13
+ Scenario: Creating the pages directory in lib
14
+ Then a directory named "sample/lib/pages" should exist
15
+
16
+ Scenario: Adding lib to loadpath in env.rb
17
+ Then a file named "sample/features/support/env.rb" should exist
18
+ And the file "sample/features/support/env.rb" should contain "$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'lib'))"
19
+
20
+ Scenario: Adding require_all stuff to the env.rb
21
+ Then a file named "sample/features/support/env.rb" should exist
22
+ And the file "sample/features/support/env.rb" should contain "require 'require_all'"
23
+ And the file "sample/features/support/env.rb" should contain "require_all 'lib'"
24
+
data/lib/testgen/cli.rb CHANGED
@@ -6,9 +6,11 @@ module TestGen
6
6
 
7
7
  desc "project <project_name>", "Create a new test project"
8
8
  method_option :pageobject_driver, :type => :string, :required => false, :desc => "Use the PageObject gem to drive browsers. Valid values are 'watir' and 'selenium'"
9
+ method_option :with_lib, :type => :boolean, :desc => "Place shared objects under lib directory"
9
10
  def project(name)
10
11
  driver = options[:pageobject_driver].nil? ? 'none' : options[:pageobject_driver]
11
- TestGen::Generators::Project.start([name, driver])
12
+ with_lib = options[:with_lib] == true ? 'true' : 'false'
13
+ TestGen::Generators::Project.start([name, driver, with_lib])
12
14
  end
13
15
 
14
16
  end
@@ -8,6 +8,7 @@ module TestGen
8
8
 
9
9
  argument :name, :type => :string, :desc => 'The name of the project'
10
10
  argument :pageobject_driver, :type => :string, :desc => 'Driver to use with PageObject'
11
+ argument :with_lib, :type => :string, :desc => 'Place all shared objects in the lib directory'
11
12
  desc "Generates a project structure for testing with Cucumber"
12
13
 
13
14
  def self.source_root
@@ -44,8 +45,16 @@ module TestGen
44
45
  template "hooks.rb.tt", "#{name}/features/support/hooks.rb" unless no_driver_selected
45
46
  end
46
47
 
48
+ def create_lib_directory
49
+ empty_directory("#{name}/lib") if gen_lib
50
+ end
51
+
47
52
  def create_pages_directory
48
- empty_directory("#{name}/features/support/pages") unless no_driver_selected
53
+ if gen_lib
54
+ empty_directory("#{name}/lib/pages") unless no_driver_selected
55
+ else
56
+ empty_directory("#{name}/features/support/pages") unless no_driver_selected
57
+ end
49
58
  end
50
59
 
51
60
  private
@@ -53,6 +62,10 @@ module TestGen
53
62
  def no_driver_selected
54
63
  pageobject_driver.downcase == 'none'
55
64
  end
65
+
66
+ def gen_lib
67
+ with_lib == 'true'
68
+ end
56
69
  end
57
70
  end
58
71
  end
@@ -3,3 +3,7 @@ gem 'rspec'
3
3
  <% unless pageobject_driver.downcase == 'none' -%>
4
4
  gem 'page-object'
5
5
  <% end -%>
6
+ <% if with_lib == 'true' -%>
7
+ gem 'require_all'
8
+ <% end -%>
9
+
@@ -1,8 +1,17 @@
1
+ <% if with_lib == 'true' -%>
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'lib'))
3
+ <% end -%>
4
+
1
5
  require 'rspec-expectations'
2
6
  <% unless pageobject_driver.downcase == 'none' -%>
3
7
  require 'page-object'
4
8
  require 'page-object/page_factory'
5
9
  <% end %>
10
+ <% if with_lib == 'true' -%>
11
+ require 'require_all'
12
+
13
+ require_all 'lib'
14
+ <% end -%>
6
15
 
7
16
 
8
17
  <% unless pageobject_driver.downcase == 'none' -%>
@@ -1,3 +1,3 @@
1
1
  module TestGen
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
data/testgen.gemspec CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_dependency 'cucumber', '>=1.0.0'
23
23
  s.add_dependency 'rspec', '>=2.6.0'
24
24
  s.add_dependency 'sys-uname'
25
+ s.add_dependency 'require_all'
25
26
 
26
27
  s.add_development_dependency 'aruba'
27
28
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: testgen
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.3
5
+ version: 0.2.4
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-30 00:00:00 Z
13
+ date: 2011-10-28 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -57,7 +57,7 @@ dependencies:
57
57
  type: :runtime
58
58
  version_requirements: *id004
59
59
  - !ruby/object:Gem::Dependency
60
- name: aruba
60
+ name: require_all
61
61
  prerelease: false
62
62
  requirement: &id005 !ruby/object:Gem::Requirement
63
63
  none: false
@@ -65,8 +65,19 @@ dependencies:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: "0"
68
- type: :development
68
+ type: :runtime
69
69
  version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: aruba
72
+ prerelease: false
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ type: :development
80
+ version_requirements: *id006
70
81
  description: A collection of generators build things for testers using Cucumber
71
82
  email:
72
83
  - jeff.morgan@leandog.com
@@ -89,6 +100,7 @@ files:
89
100
  - features/support/hooks.rb
90
101
  - features/testgen_project.feature
91
102
  - features/testgen_with_pageobject.feature
103
+ - features/with_lib_option.feature
92
104
  - lib/testgen.rb
93
105
  - lib/testgen/cli.rb
94
106
  - lib/testgen/generators/project.rb
@@ -131,3 +143,4 @@ test_files:
131
143
  - features/support/hooks.rb
132
144
  - features/testgen_project.feature
133
145
  - features/testgen_with_pageobject.feature
146
+ - features/with_lib_option.feature