test-factory 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,16 +13,32 @@ module DataFactory
13
13
  alias update_options set_options
14
14
 
15
15
  # Items passed to this method are checked to ensure that the associated class instance variable
16
- # is not nil. If it is, the script is aborted and an error is thrown.
16
+ # is not nil. If it is, the script is aborted and an error is thrown. Use symbols separated
17
+ # by commas with this method. The symbol(s) should exactly match the name of the instance
18
+ # variable that must not be empty.
19
+ #
20
+ # NOTE: Currently this is backwards compatible with prior versions, which took the instance
21
+ # variables directly in the parameter. This backwards compatibility will be removed in
22
+ # some future update of the gem.
23
+ #
17
24
  # @param elements [Array] the list of items that are required.
18
25
  #
19
26
  # @example
20
27
  #
21
- # requires @site, @assignment
28
+ # requires :site, :assignment, :document_id
22
29
  #
23
30
  def requires(*elements)
24
31
  elements.each do |inst_var|
25
- raise "You've neglected to define a required variable for the #{self}." if inst_var==nil
32
+ if inst_var.kind_of? Symbol
33
+ string="@#{inst_var.to_s}"
34
+ if instance_variable_get(string)==nil
35
+ raise "You've neglected to define a required variable for your #{self.class}.\n\nPlease ensure you always specify a value for #{string} when you create the data object."
36
+ end
37
+ elsif inst_var.kind_of? String
38
+ warn "<<<<WARNING!>>>>\n\nPlease update the requires method in your\n#{self.class} class to refer to symbols\ninstead of directly referencing the class'\ninstance variables.\n\n Example:\n\n This...\n requires @document_id\n Should be updated to...\n requires :document_id\n\nIn future versions of TestFactory the 'requires'\nmethod will only support symbolized references\nto the instance variables. The backwards\ncompatibility will be removed.\n\n<<<<WARNING!>>>>"
39
+ elsif inst_var==nil
40
+ raise "You've neglected to define a required variable for your #{self.class}.\n\n<<<<WARNING!>>>>\n\nPlease update the requires method in your #{self} class to refer to symbols\ninstead of directly referencing the class'\ninstance variables.\n\nIn future versions of TestFactory the 'requires' method\nwill only support symbolized references\nto the instance variables. The backwards\ncompatibility will be removed.\n\n<<<<WARNING!>>>>"
41
+ end
26
42
  end
27
43
  end
28
44
 
@@ -145,7 +145,9 @@ module Watir
145
145
  # setting the associated class instance variable
146
146
  # with it, like so...
147
147
  # @example
148
+ # @my_selection=:random
148
149
  # @my_selection=page.select_list.pick @my_selection
150
+ # puts @my_selection # => <Value of randomly selected item from list>
149
151
  #
150
152
  def pick(item)
151
153
  if item==:random
@@ -161,10 +163,10 @@ module Watir
161
163
  def select_at_random
162
164
  text_array = []
163
165
  options.each { |opt| text_array << opt.text }
164
- text_array.delete_if { |text| text=="select" }
165
- text_array.shuffle!
166
- select text_array[0]
167
- text_array[0]
166
+ text_array.delete_if { |text| text=="select" || text=="" }
167
+ item = text_array.sample
168
+ select item
169
+ item
168
170
  end
169
171
 
170
172
  end
@@ -119,6 +119,7 @@ class PageFactory
119
119
  action(damballa(button_text)) { |b| b.button(:value=>button_text).click }
120
120
  end
121
121
 
122
+ private
122
123
  # A helper method that converts the passed string into snake case. See the StringFactory
123
124
  # module for more info.
124
125
  #
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.1'
3
+ s.version = '0.2.2'
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.1
4
+ version: 0.2.2
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-02-08 00:00:00.000000000 Z
12
+ date: 2013-03-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: watir-webdriver