test-factory 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +16 -12
- data/lib/test-factory/string_factory.rb +1 -1
- data/test-factory.gemspec +1 -1
- metadata +1 -1
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -92,26 +92,30 @@ class YourDataObject
|
|
92
92
|
# These are some example attributes...
|
93
93
|
attr_accessor :title, :id, :link, :status, :description
|
94
94
|
|
95
|
+
# Put any attributes here that you don't want to always have to define explicitly...
|
96
|
+
DEFAULTS = {
|
97
|
+
:title=>"My Data Title",
|
98
|
+
:description=>"My Data's Description"
|
99
|
+
# ...
|
100
|
+
}
|
101
|
+
|
95
102
|
# Your data object has to know about Watir's browser object, so it's passed to it here, along
|
96
103
|
# with a hash containing all the attributes you want the data object to have
|
97
104
|
def initialize(browser, opts={})
|
98
105
|
@browser = browser
|
99
106
|
|
100
|
-
#
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
# with any options you passed explicitly
|
107
|
-
set_options(options) # This line turns all the contents of the options
|
108
|
-
# Hash into YourDataObject's class instance variables
|
107
|
+
# The set_options line combines the DEFAULTS
|
108
|
+
# with any options you passed explicitly,
|
109
|
+
# then turns all the contents of the options
|
110
|
+
# Hash into YourDataObject's class instance variables
|
111
|
+
set_options(DEFAULTS.merge(opts))
|
112
|
+
|
109
113
|
requires @id # This line allows you to specify any class instance variables that must
|
110
114
|
# be explicitly defined for the data object
|
111
115
|
end
|
112
116
|
|
113
117
|
# Now define a bunch of methods that are relevant to your data object.
|
114
|
-
# In general these methods will follow the CRUD pattern
|
118
|
+
# In general these methods will follow the CRUD design pattern
|
115
119
|
|
116
120
|
def create
|
117
121
|
# Your code here...
|
@@ -123,8 +127,8 @@ class YourDataObject
|
|
123
127
|
|
124
128
|
def edit opts={}
|
125
129
|
# Your code here...
|
126
|
-
|
127
|
-
|
130
|
+
update_options(opts) # This updates all your class instance variables
|
131
|
+
# with any new values specified by the opts Hash.
|
128
132
|
end
|
129
133
|
|
130
134
|
def remove
|
@@ -45,7 +45,7 @@ module StringFactory
|
|
45
45
|
# @param length [Integer] The count of characters in the string
|
46
46
|
# @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
|
47
47
|
def random_alphanums_plus(length=10, s="")
|
48
|
-
chars = %w{ a b c d e f g h j k m n p q r s t u v w x y z A B C D E F G H J K L M N P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ` ~ ! @ # $ % ^ & * ( ) _ + - = { } [ ]
|
48
|
+
chars = %w{ a b c d e f g h j k m n p q r s t u v w x y z A B C D E F G H J K L M N P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ` ~ ! @ # $ % ^ & * ( ) _ + - = { } [ ] \\ : " ; ' < > ? , . / }
|
49
49
|
length.times { s << chars[rand(chars.size)] }
|
50
50
|
s.to_s
|
51
51
|
end
|
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.1.
|
3
|
+
s.version = '0.1.3'
|
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("**/**/**")
|