test-factory 0.3.92 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/test-factory/collections_factory.rb +2 -3
- data/lib/test-factory/core_ext.rb +12 -2
- data/lib/test-factory/data_factory.rb +44 -7
- data/lib/test-factory/foundry.rb +3 -3
- data/lib/test-factory/page_factory.rb +14 -20
- data/test-factory.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODQ2MDNiODE1ZWVlMTEyNDBiNWYxMzUyOGU5ZjczNjM5MGNjNjExYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTc3YmZiMzBiY2E4ZDFiZmI0N2I4MjFjMTE5MDNkY2I3NTk2NzI0Mw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2M2NTBiNjYyM2U2ZTdkMWNlYTdjNDBlYjM3ODVmMjNiMTA2NWNlODQ3MzFi
|
10
|
+
NGFmNGE1Y2ZiNDI0ZjA1OGNjMzFiMjBkMmQxNWUxNTRlOTBmNDAwZDJmN2I4
|
11
|
+
YzJiYmU5ZjZiOTdjYTE2MDEwZTUwOTFlNmE3OTM5YzI4YzBiMjE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTBkZjAzN2I5ZDQwOWQ2ZDQ5ZDM2ZDkwMGExYmZkM2ViMGZhOWJhMDA1MmU1
|
14
|
+
NDc1NGFlNzZlNTMwMDc1OWJhYmVlYTIxYTllOWM1M2IwM2MzMGFlYjdjN2Uw
|
15
|
+
NDM0Mjc1NzcyMWNlNmIxMDQ0ZWIxMDU5ZDRjYjkxMDBiY2ZkOWE=
|
@@ -107,7 +107,6 @@ module Enumerable
|
|
107
107
|
|
108
108
|
end # Enumerable
|
109
109
|
|
110
|
-
|
111
110
|
class Numeric
|
112
111
|
|
113
112
|
# Converts a number object to a string containing commas every 3rd digit. Adds
|
@@ -120,4 +119,15 @@ class Numeric
|
|
120
119
|
int.reverse + dec
|
121
120
|
end
|
122
121
|
|
123
|
-
end # Numeric
|
122
|
+
end # Numeric
|
123
|
+
|
124
|
+
class String
|
125
|
+
|
126
|
+
# Used to remove commas from long number strings,
|
127
|
+
# then converting the result to a Float so that it
|
128
|
+
# can be used in calculations.
|
129
|
+
def groom
|
130
|
+
self.gsub(',','').to_f
|
131
|
+
end
|
132
|
+
|
133
|
+
end # String
|
@@ -100,7 +100,8 @@ module DataFactory
|
|
100
100
|
# 3) Since the listed fields get filled out in random order, be sure that
|
101
101
|
# this is okay in the context of your page--in other words, if field A
|
102
102
|
# needs to be specified before field B then having them both in your
|
103
|
-
# fill_out step would be inappropriate.
|
103
|
+
# fill_out step would be inappropriate. If you need a specific order,
|
104
|
+
# use #ordered_fill instead.
|
104
105
|
#
|
105
106
|
# 4) This method supports text fields, select lists, check boxes, and
|
106
107
|
# radio buttons, but only if their element definitions don't take a
|
@@ -113,7 +114,19 @@ module DataFactory
|
|
113
114
|
# end
|
114
115
|
#
|
115
116
|
def fill_out(page, *fields)
|
116
|
-
|
117
|
+
f_o_i true, nil, page, *fields
|
118
|
+
end
|
119
|
+
|
120
|
+
# Use when you need to specify the order that the fields should be
|
121
|
+
# updated.
|
122
|
+
#
|
123
|
+
# @example
|
124
|
+
# on PageClass do |page|
|
125
|
+
# ordered_fill page, :text_field_name, :radio_name, :select_list_name, :checkbox_name
|
126
|
+
# end
|
127
|
+
#
|
128
|
+
def ordered_fill(page, *fields)
|
129
|
+
f_o_i false, nil, page, *fields
|
117
130
|
end
|
118
131
|
|
119
132
|
# Same as #fill_out, but used with methods that take a
|
@@ -125,11 +138,20 @@ module DataFactory
|
|
125
138
|
# end
|
126
139
|
#
|
127
140
|
def fill_out_item(name, page, *fields)
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
141
|
+
f_o_i true, name, page, *fields
|
142
|
+
end
|
143
|
+
|
144
|
+
# Use instead of #fill_out_item when you need to
|
145
|
+
# specify the order that the fields should be
|
146
|
+
# updated.
|
147
|
+
#
|
148
|
+
# @example
|
149
|
+
# on PageClass do |page|
|
150
|
+
# ordered_item_fill 'Joe Schmoe', page, :text_field_name, :radio_name, :select_list_name, :checkbox_name
|
151
|
+
# end
|
152
|
+
#
|
153
|
+
def ordered_item_fill(name, page, *fields)
|
154
|
+
f_o_i false, name, page, *fields
|
133
155
|
end
|
134
156
|
|
135
157
|
# This is a specialized method for use with any select list boxes
|
@@ -203,4 +225,19 @@ module DataFactory
|
|
203
225
|
end
|
204
226
|
end
|
205
227
|
|
228
|
+
# =======
|
229
|
+
private
|
230
|
+
# =======
|
231
|
+
|
232
|
+
# Do not use this method directly.
|
233
|
+
#
|
234
|
+
def f_o_i(shuffle, name, page, *fields)
|
235
|
+
shuffle ? fields.shuffle! : fields
|
236
|
+
fields.each do |field|
|
237
|
+
lmnt = page.send(*[field, name].compact)
|
238
|
+
var = instance_variable_get "@#{field}"
|
239
|
+
lmnt.class.to_s == 'Watir::Select' ? lmnt.pick!(var) : lmnt.fit(var)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
206
243
|
end
|
data/lib/test-factory/foundry.rb
CHANGED
@@ -32,9 +32,9 @@ module Foundry
|
|
32
32
|
# @param &block [C] this is the block of code that you want to run while on the given page
|
33
33
|
#
|
34
34
|
def on page_class, visit=false, &block
|
35
|
-
current_page = page_class.new @browser, visit
|
36
|
-
block.call current_page if block
|
37
|
-
current_page
|
35
|
+
$current_page = page_class.new @browser, visit
|
36
|
+
block.call $current_page if block
|
37
|
+
$current_page
|
38
38
|
end
|
39
39
|
alias_method :on_page, :on
|
40
40
|
|
@@ -69,35 +69,29 @@ class PageFactory
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
# The basic building block
|
73
|
-
#
|
74
|
-
#
|
72
|
+
# The basic building block for defining and interacting with
|
73
|
+
# elements on a web page. # Use in conjunction with
|
74
|
+
# Watir to define all elements on a given page that are important to validate.
|
75
75
|
#
|
76
|
-
# @example
|
77
|
-
# element(:title) { |b| b.text_field(:id=>"title-id") }
|
78
|
-
# value(:page_header) { |b| b.h3(:class=>"page_header").text }
|
79
|
-
#
|
80
|
-
def element element_name
|
81
|
-
raise "#{element_name} is being defined twice in #{self}!" if self.instance_methods.include?(element_name.to_sym)
|
82
|
-
define_method element_name.to_s do
|
83
|
-
yield self
|
84
|
-
end
|
85
|
-
end
|
86
|
-
alias :value :element
|
87
|
-
|
88
|
-
# The basic building block for interacting with elements on a page, such as links and buttons.
|
89
76
|
# Methods that take one or more parameters can be built with this as well.
|
90
77
|
#
|
91
78
|
# @example
|
79
|
+
# element(:title) { |b| b.text_field(:id=>"title-id") }
|
80
|
+
# value(:page_header) { |b| b.h3(:class=>"page_header").text }
|
92
81
|
# action(:continue) { |b| b.frm.button(:value=>"Continue").click } => Creates a #continue method that clicks the Continue button
|
93
|
-
#
|
82
|
+
# p_element(:select_style) { |stylename, b| b.div(:text=>/#{Regexp.escape(stylename)}/).link(:text=>"Select").click } => #select_style(stylename)
|
94
83
|
#
|
95
|
-
def
|
96
|
-
raise "#{
|
97
|
-
define_method
|
84
|
+
def element name, &block
|
85
|
+
raise "#{name} is being defined twice in #{self}!" if self.instance_methods.include?(name.to_sym)
|
86
|
+
define_method name.to_s do |*thing|
|
98
87
|
Proc.new(&block).call *thing, self
|
99
88
|
end
|
100
89
|
end
|
90
|
+
alias_method :action, :element
|
91
|
+
alias_method :value, :element
|
92
|
+
alias_method :p_element, :element
|
93
|
+
alias_method :p_action, :element
|
94
|
+
alias_method :p_value, :element
|
101
95
|
|
102
96
|
# Use this for links that are safe to define by their text string.
|
103
97
|
# This method will return two methods for interacting with the link:
|
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.
|
3
|
+
s.version = '0.4.0'
|
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("**/**/**")
|
@@ -8,6 +8,6 @@ spec = Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Abraham Heward"]
|
9
9
|
s.email = %w{"aheward@rsmart.com"}
|
10
10
|
s.homepage = 'https://github.com/rSmart'
|
11
|
-
s.add_dependency 'watir-webdriver', '>= 0.6.
|
11
|
+
s.add_dependency 'watir-webdriver', '>= 0.6.4'
|
12
12
|
s.required_ruby_version = '>= 1.9.2'
|
13
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-factory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abraham Heward
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: watir-webdriver
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.6.
|
19
|
+
version: 0.6.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.6.
|
26
|
+
version: 0.6.4
|
27
27
|
description: This gem provides a set of modules and methods to help quickly and DRYly
|
28
28
|
create a test automation framework using Ruby and Watir (or watir-webdriver).
|
29
29
|
email:
|