cwtestgen 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-1.9.3-p392
1
+ ruby-2.0.0-p0
data/Gemfile CHANGED
@@ -7,6 +7,9 @@ gem 'rb-fsevent', '~> 0.9.1'
7
7
  gem 'growl'
8
8
  gem 'guard-rspec'
9
9
  gem 'guard-cucumber'
10
+ gem 'page-object'
11
+ gem 'watir-webdriver'
12
+ gem 'watir-webdriver-performance'
10
13
 
11
14
  # Specify your gem's dependencies in testgen.gemspec
12
15
  gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012, Clockwork Active Media Systems
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included
12
+ in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CwTestGen
2
2
 
3
- Based on cheezy's Testgen gem, but modified for specific Clockwork test setup. All thanks go to cheezy / Jeff Morgan!
3
+ Based on Jeff Morgan's Testgen gem, but hacked for specific Clockwork test setup.
4
4
 
5
5
  A gem that contains generators that create things Clockwork testers need.
6
6
 
data/cwtestgen.gemspec CHANGED
@@ -5,11 +5,12 @@ require "cwtestgen/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "cwtestgen"
7
7
  s.version = CwTestGen::VERSION
8
- s.authors = ["Jeffrey S. Morgan", "Chris Smalley"]
9
- s.email = ["chris@clockwork.net"]
10
- s.homepage = "http://github.com/jonsie/cwtestgen"
8
+ s.authors = ["Jeffrey S. Morgan", "Chris Smalley", "Andrew Leaf"]
9
+ s.email = ["chris@clockwork.net", "andrew@clockwork.net"]
10
+ s.homepage = "https://github.com/ClockworkNet/cwtestgen"
11
11
  s.summary = %q{Generators for Clockwork testers using Cucumber}
12
12
  s.description = %q{Generates the Clockwork specific Cucumber testing environment}
13
+ s.license = 'MIT'
13
14
 
14
15
  s.rubyforge_project = "cwtestgen"
15
16
 
@@ -22,6 +23,8 @@ Gem::Specification.new do |s|
22
23
  s.add_dependency 'cucumber', '>=1.2.0'
23
24
  s.add_dependency 'rspec', '>=2.13.0'
24
25
  s.add_dependency 'require_all'
26
+ s.add_dependency 'watir-webdriver'
27
+ s.add_dependency 'watir-webdriver-performance'
25
28
 
26
29
  s.add_development_dependency 'aruba'
27
30
  end
data/lib/cwtestgen/cli.rb CHANGED
@@ -3,9 +3,13 @@ require 'cwtestgen/generators/project'
3
3
 
4
4
  module CwTestGen
5
5
  class CLI < Thor
6
+
6
7
  desc "project <project_name>", "Create a new test project"
8
+ method_option :with_page_templates, :type => :boolean, :desc => "Copy page templates to features/support/pages/"
9
+
7
10
  def project(name)
8
- CwTestGen::Generators::Project.start([name])
11
+ with_page_templates = options[:with_page_templates] ? 'true' : 'false'
12
+ CwTestGen::Generators::Project.start([name, with_page_templates])
9
13
  end
10
14
  end
11
15
  end
@@ -0,0 +1,23 @@
1
+ class ClockworkPage
2
+ include PageObject
3
+
4
+ # Common Page
5
+ # Identify common links here that will be found on most/all pages
6
+ # Each Page should inherit from ClockworkPage
7
+
8
+ # Common Header links
9
+ link(:header_home, :href => "/")
10
+
11
+ # Common Utility Navigation
12
+ link(:log_in, :href => "/log_in/")
13
+
14
+ # Common Footer Navigation
15
+ link(:footer_contact_us, :href => "/contact_us/")
16
+
17
+ # Common Social Links
18
+ link(:social_youtube, :id => "")
19
+ link(:social_facebook, :id => "")
20
+ link(:social_twitter, :id => "")
21
+ link(:social_google_plus, :id => "")
22
+
23
+ end
@@ -3,11 +3,14 @@ require 'page-object/page_factory'
3
3
  require 'faker'
4
4
  require 'require_all'
5
5
  require 'rspec-expectations'
6
+ require 'watir-webdriver'
7
+ require "watir-webdriver-performance"
8
+
6
9
  World(PageObject::PageFactory)
7
10
 
8
11
  # Global variables
9
12
  $live_url = ""
10
- $amm_url = ""
13
+ $admin_url = ""
11
14
  $default_email = ""
12
15
  $default_password = ""
13
16
 
@@ -16,7 +19,12 @@ $log.level = Logger::DEBUG
16
19
 
17
20
  PageObject.javascript_framework = :jquery
18
21
 
19
- browser = Watir::Browser.new :ff
22
+ case ENV['BROWSER']
23
+ when 'chrome'
24
+ browser = Watir::Browser.new :chrome
25
+ else
26
+ browser = Watir::Browser.new :ff
27
+ end
20
28
 
21
29
  Before do
22
30
  @browser = browser
@@ -25,4 +33,5 @@ end
25
33
 
26
34
  at_exit do
27
35
  browser.close
28
- end
36
+ end
37
+
@@ -0,0 +1,43 @@
1
+ class HomePage < ClockworkPage
2
+
3
+ #############################################################################
4
+ # HomePage inherits from ClockworkPage
5
+ # All links or elements defined in ClockworkPage are available to HomePage
6
+ # Defining the page_url. This assists with `visit_page` and `on_page` methods
7
+ # that are granted via PageObject/PageFactory.
8
+ # page_url accepts a string. Use $live_url + "/path_to_page/" for other pages
9
+ #############################################################################
10
+ page_url($live_url)
11
+
12
+ #############################################################################
13
+ # Elements
14
+ #
15
+ # Define your elements below using the following format:
16
+ # link(:link_name, :href => "/how_to_identify_link/")
17
+ # Elements can be identified a number of ways.
18
+ # :href, :id, :class, :data_varname are the common methods of identification
19
+ #############################################################################
20
+ link(:demo_link, :class => "demo_link_class")
21
+
22
+ #############################################################################
23
+ # Methods
24
+ #
25
+ # Define methods that will help your page below.
26
+ # Note: You may need to use `self` to set something inside a page method.
27
+ #
28
+ # Example, with two new text_fields, and a button declared.
29
+ # These elements can be declared above.
30
+ #
31
+ # text_field(:member_email, :id => "member_email")
32
+ # text_field(:member_password, :id => "member_password")
33
+ # button(:submit_login, :id => "log_in_btn")
34
+ #
35
+ # def submit_member_login(email_address, password)
36
+ # self.member_email=(email_address)
37
+ # self.member_password=(password)
38
+ # self.submit_login
39
+ # end
40
+ #############################################################################
41
+
42
+
43
+ end
@@ -0,0 +1,15 @@
1
+ # All Features start with a Feature
2
+ Feature: In Order to run a Cucumber Test
3
+ A tester must have a feature file
4
+
5
+ # This is what Tags look like. Add as many as you want to any Feature or Scenario
6
+ @tag_example
7
+ Scenario: Example Cucumber File
8
+ Given I am on the Home Page
9
+ Then the page title should include "Home"
10
+
11
+ Scenario: You can have multiple scenarios in one file
12
+ Given I am on the Home Page
13
+ When I click Contact Us
14
+ Then I should be on the Contact Us page
15
+
@@ -0,0 +1,10 @@
1
+ # These are sample step definitions. You can cram them all into one file
2
+ # or have multiple *_steps.rb files.
3
+
4
+ # Go run the following command to find out what to put in here:
5
+ # cucumber features/sample_cucumber.feature
6
+ # You'll see some output that shows how to start.
7
+
8
+ When(/^I do something$/) do
9
+ pending # put your code in here
10
+ end
@@ -6,6 +6,7 @@ module CwTestGen
6
6
  include Thor::Actions
7
7
 
8
8
  argument :name, :type => :string, :desc => 'The name of the project'
9
+ argument :with_page_templates, :type => :string, :desc => 'Place Page Templates into features/support/pages/'
9
10
  desc "Generates a project structure for testing with Cucumber"
10
11
 
11
12
  def self.source_root
@@ -37,9 +38,22 @@ module CwTestGen
37
38
  def create_pages_directory
38
39
  empty_directory("#{name}/features/support/pages")
39
40
  end
41
+
42
+ def copy_page_templates
43
+ if gen_page_templates
44
+ template "clockwork_page.rb.tt", "#{name}/features/support/pages/clockwork_page.rb"
45
+ template "home_page.rb.tt", "#{name}/features/support/pages/home_page.rb"
46
+ template "sample_cucumber.feature.tt", "#{name}/features/sample_cucumber.feature"
47
+ template "sample_steps.rb.tt", "#{name}/features/support/step_definitions/#{name}_steps.rb"
48
+ end
49
+ end
40
50
 
41
51
  private
42
52
 
53
+ def gen_page_templates
54
+ with_page_templates == 'true'
55
+ end
56
+
43
57
  end
44
58
  end
45
59
  end
@@ -1,3 +1,3 @@
1
1
  module CwTestGen
2
- VERSION = "0.1"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cwtestgen
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jeffrey S. Morgan
9
9
  - Chris Smalley
10
+ - Andrew Leaf
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2013-04-17 00:00:00.000000000 Z
14
+ date: 2013-04-19 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: thor
@@ -76,6 +77,38 @@ dependencies:
76
77
  - - ! '>='
77
78
  - !ruby/object:Gem::Version
78
79
  version: '0'
80
+ - !ruby/object:Gem::Dependency
81
+ name: watir-webdriver
82
+ requirement: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: watir-webdriver-performance
98
+ requirement: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
79
112
  - !ruby/object:Gem::Dependency
80
113
  name: aruba
81
114
  requirement: !ruby/object:Gem::Requirement
@@ -95,6 +128,7 @@ dependencies:
95
128
  description: Generates the Clockwork specific Cucumber testing environment
96
129
  email:
97
130
  - chris@clockwork.net
131
+ - andrew@clockwork.net
98
132
  executables:
99
133
  - cwtestgen
100
134
  extensions: []
@@ -106,6 +140,7 @@ files:
106
140
  - .ruby-version
107
141
  - Gemfile
108
142
  - Guardfile
143
+ - LICENSE
109
144
  - Rakefile
110
145
  - Readme.md
111
146
  - bin/cwtestgen
@@ -122,11 +157,16 @@ files:
122
157
  - lib/cwtestgen/cli.rb
123
158
  - lib/cwtestgen/generators/project.rb
124
159
  - lib/cwtestgen/generators/project/Rakefile
160
+ - lib/cwtestgen/generators/project/clockwork_page.rb.tt
125
161
  - lib/cwtestgen/generators/project/cucumber.yml.tt
126
162
  - lib/cwtestgen/generators/project/env.rb.tt
163
+ - lib/cwtestgen/generators/project/home_page.rb.tt
164
+ - lib/cwtestgen/generators/project/sample_cucumber.feature.tt
165
+ - lib/cwtestgen/generators/project/sample_steps.rb.tt
127
166
  - lib/cwtestgen/version.rb
128
- homepage: http://github.com/jonsie/cwtestgen
129
- licenses: []
167
+ homepage: https://github.com/ClockworkNet/cwtestgen
168
+ licenses:
169
+ - MIT
130
170
  post_install_message:
131
171
  rdoc_options: []
132
172
  require_paths:
@@ -145,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
185
  version: '0'
146
186
  requirements: []
147
187
  rubyforge_project: cwtestgen
148
- rubygems_version: 1.8.25
188
+ rubygems_version: 1.8.24
149
189
  signing_key:
150
190
  specification_version: 3
151
191
  summary: Generators for Clockwork testers using Cucumber