test-factory 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -3
- data/lib/test-factory/page_factory.rb +6 -2
- data/lib/test-factory/string_factory.rb +2 -6
- data/test-factory.gemspec +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -35,6 +35,13 @@ Using the TestFactory properly involves three distinct steps:
|
|
35
35
|
level requires only basic skills with Ruby and Watir, but a strong command of your DSL
|
36
36
|
(the thing you're building with TestFactory).
|
37
37
|
|
38
|
+
These three steps can all be accomplished by a single person. However, ideally, they should be done by three or four people, as the design philosophy of TestFactory allows for specialization:
|
39
|
+
|
40
|
+
- A Watir specialist works on defining page elements and actions inside of page classes
|
41
|
+
- A Ruby specialist uses the output of the Watir specialist to build the data objects and their helper methods, creating the DSL for the project
|
42
|
+
- A non-programmer--say, a business analyst or a manual tester with domain expertise--writes test scenarios, in English
|
43
|
+
- A more junior automation engineer translates the English into Ruby code, via the DSL created by the Ruby specialist (if you're using Cucumber, these would be your step definitions)
|
44
|
+
|
38
45
|
How to Start
|
39
46
|
------------
|
40
47
|
|
@@ -120,7 +127,7 @@ class YourDataObject
|
|
120
127
|
# Hash into YourDataObject's class instance variables
|
121
128
|
set_options(defaults.merge(opts))
|
122
129
|
|
123
|
-
requires
|
130
|
+
requires :id # This line allows you to specify any class instance variables that must
|
124
131
|
# be explicitly defined for the data object
|
125
132
|
end
|
126
133
|
|
@@ -227,12 +234,12 @@ end
|
|
227
234
|
```
|
228
235
|
|
229
236
|
* The setting of random values for select lists in a data object is determined by passing
|
230
|
-
the
|
237
|
+
the string '::random::' in the instance variable, or as the value in the key/value pair
|
231
238
|
passed in an `#edit` method's `opts` parameter. The `#create` and `#edit` methods will
|
232
239
|
handle the necessary logic. The purpose is to prevent the need for custom randomizing
|
233
240
|
CRUD methods in the data object.
|
234
241
|
* See the gem_ext.rb file's discussion of the Watir `#fit` method for additional
|
235
|
-
design pattern rules to follow.
|
242
|
+
design pattern rules to follow (If you're reading this on rubydoc.info then click the Watir module link)
|
236
243
|
* Please make an effort to follow the [Ruby Style Guidelines](http://www.caliban.org/ruby/rubyguide.shtml#style).
|
237
244
|
|
238
245
|
Notice
|
@@ -79,6 +79,7 @@ class PageFactory
|
|
79
79
|
# action(:select_style) { |stylename, b| b.div(:text=>/#{Regexp.escape(stylename)}/).link(:text=>"Select").click } => #select_style(stylename)
|
80
80
|
#
|
81
81
|
def action method_name, &block
|
82
|
+
raise "#{method_name} is being defined twice in #{self}!" if self.instance_methods.include?(method_name.to_sym)
|
82
83
|
define_method method_name.to_s do |*thing|
|
83
84
|
Proc.new(&block).call *thing, self
|
84
85
|
end
|
@@ -98,7 +99,9 @@ class PageFactory
|
|
98
99
|
#
|
99
100
|
# The last parameter in the method is optional. Use it when
|
100
101
|
# you need the method name to be different from the text of
|
101
|
-
# the link--for example if the link text
|
102
|
+
# the link--for example if the link text is something unhelpful,
|
103
|
+
# like "here", or else the link text gets updated (e.g., what was
|
104
|
+
# "Log In" is now "Sign In", instead) and you don't
|
102
105
|
# want to have to go through all your data objects and step
|
103
106
|
# definitions to update them to the new method name.
|
104
107
|
#
|
@@ -124,7 +127,8 @@ class PageFactory
|
|
124
127
|
#
|
125
128
|
# The last parameter in the method is optional. Use it when
|
126
129
|
# you need the method name to be different from the text of
|
127
|
-
# the button--for example if the button text
|
130
|
+
# the button--for example if the button text is unhelpful, like "Go", or else
|
131
|
+
# it changes (e.g., from "Update" to "Edit") and you don't
|
128
132
|
# want to have to go through all your data objects and step
|
129
133
|
# definitions to update them to the new method name.
|
130
134
|
#
|
@@ -9,9 +9,7 @@ module StringFactory
|
|
9
9
|
# @param s [String] Typically this will be left blank, but if included, any string created will be prepended with s. Note that the string length will still be as specified
|
10
10
|
#
|
11
11
|
def random_string(length=10, s="")
|
12
|
-
length.enum_for(:times).inject(s)
|
13
|
-
s << rand(93) + 33
|
14
|
-
end
|
12
|
+
length.enum_for(:times).inject(s) { s << rand(93) + 33 }
|
15
13
|
end
|
16
14
|
|
17
15
|
# A random string creator that draws from all printable ASCII and High ASCII characters
|
@@ -20,9 +18,7 @@ module StringFactory
|
|
20
18
|
# @param s [String] Typically this will be left blank, but if included, any string created will be prepended with s. Note that the string length will still be as specified
|
21
19
|
#
|
22
20
|
def random_high_ascii(length=10, s="")
|
23
|
-
length.enum_for(:times).inject(s)
|
24
|
-
s << rand(223) + 33
|
25
|
-
end
|
21
|
+
length.enum_for(:times).inject(s) { s << rand(223) + 33 }
|
26
22
|
end
|
27
23
|
|
28
24
|
# A "friendlier" random string generator. No characters need to be escaped for valid URLs.
|
data/test-factory.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
spec = Gem::Specification.new do |s|
|
2
2
|
s.name = 'test-factory'
|
3
|
-
s.version = '0.2.
|
3
|
+
s.version = '0.2.5'
|
4
4
|
s.summary = %q{rSmart's framework for creating automated testing scripts}
|
5
5
|
s.description = %q{This gem provides a set of modules and methods to help quickly and DRYly create a test automation framework using Ruby and Watir (or watir-webdriver).}
|
6
6
|
s.files = Dir.glob("**/**/**")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-factory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: watir-webdriver
|