test-factory 0.0.9.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- test-factory (0.0.9.1)
4
+ test-factory (0.1.0)
5
5
  watir-webdriver (>= 0.6.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -39,11 +39,11 @@ class BasePage < PageFactory
39
39
  class << self
40
40
 
41
41
  def header_elements
42
- element(:main_menu) { |b| b.link(title: "Main Menu") }
42
+ element(:main_menu_link) { |b| b.link(title: "Main Menu") }
43
43
  element(:logout) { |b| b.button(value: "Logout") }
44
44
  element(:administration) { |b| b.link(title: "Administration") }
45
45
 
46
- action(:main_menu) { |p| p.main_menu.click }
46
+ action(:main_menu) { |p| p.main_menu_link.click }
47
47
  action(:provide_feedback) { |b| b.link(title: "Provide Feedback").click }
48
48
  action(:administration) { |p| p.administration.click }
49
49
  end
@@ -43,6 +43,8 @@ module DataFactory
43
43
  # data object, it will get the value from the UI and set the data object's
44
44
  # variable to that value. Note that this only supports select lists that allow
45
45
  # a single selection.
46
+ # @param var [instance variable] The instance variable that will either be set or be used to update the page
47
+ # @param select_list [Watir::Select] The relevant select list element on the page
46
48
  #
47
49
  # @example
48
50
  #
@@ -14,6 +14,7 @@ module Foundry
14
14
  # method when you are already on the site page you want to interact with.
15
15
  # @param page_class [Class] the name of the page class that you want to instantiate
16
16
  # @param visit [TrueClass, FalseClass] Essentially you will never have to specify this explicitly
17
+ # @param &block [C] this is the block of code that you want to run while on the given page
17
18
  def on page_class, visit=false, &block
18
19
  @current_page = page_class.new @browser, visit
19
20
  block.call @current_page if block
@@ -22,7 +22,7 @@ class PageFactory
22
22
  class << self
23
23
 
24
24
  # Define this in a page class and when you use the "visit" method to instantiate the class
25
- # it will enter the URL the browser's address bar.
25
+ # it will enter the URL in the browser's address bar.
26
26
  def page_url url
27
27
  define_method 'goto' do
28
28
  @browser.goto url
@@ -31,6 +31,7 @@ class PageFactory
31
31
 
32
32
  # Define this in a page class and when that class is instantiated it will wait until that
33
33
  # element appears on the page before continuing with the script.
34
+ # @param element_name [Symbol] The method name of the element that must be present on the page
34
35
  def expected_element element_name, timeout=30
35
36
  define_method 'expected_element' do
36
37
  self.send(element_name).wait_until_present timeout
@@ -40,6 +41,7 @@ class PageFactory
40
41
  # Define this in a page class and when the class is instantiated it will verify that
41
42
  # the browser's title matches the expected title. If there isn't a match, it raises an
42
43
  # error and halts the script.
44
+ # @param expected_title [String] The exact text that is expected to appear in the Browser title when the page loads
43
45
  def expected_title expected_title
44
46
  define_method 'has_expected_title?' do
45
47
  has_expected_title = expected_title.kind_of?(Regexp) ? expected_title =~ @browser.title : expected_title == @browser.title
@@ -49,6 +51,7 @@ class PageFactory
49
51
 
50
52
  # The basic building block of the page object classes.
51
53
  # Use in conjunction with Watir to define all elements on a given page that are important to validate.
54
+ # @param element_name [Symbol] The name you're giving to the element on the page.
52
55
  #
53
56
  # @example
54
57
  # element(:title) { |b| b.text_field(:id=>"title-id") }
@@ -65,8 +68,8 @@ class PageFactory
65
68
  # Methods that take one or more parameters can be built with this as well.
66
69
  #
67
70
  # @example
68
- # action(:continue) { |b| b.frm.button(:value=>"Continue").click } #=> Creates a #continue method that clicks the Continue button
69
- # action(:select_style) { |stylename, b| b.div(:text=>/#{Regexp.escape(stylename)}/).link(:text=>"Select").click } #=> #select_style(stylename)
71
+ # action(:continue) { |b| b.frm.button(:value=>"Continue").click } => Creates a #continue method that clicks the Continue button
72
+ # action(:select_style) { |stylename, b| b.div(:text=>/#{Regexp.escape(stylename)}/).link(:text=>"Select").click } => #select_style(stylename)
70
73
  #
71
74
  def action method_name, &block
72
75
  define_method method_name.to_s do |*thing|
@@ -84,7 +87,7 @@ class PageFactory
84
87
  # And spaces and dashes are converted to underscores.
85
88
  #
86
89
  # @example
87
- # link("Click Me For Fun!") #=> Creates the methods #click_me_for_fun and #click_me_for_fun_link
90
+ # link("Click Me For Fun!") => Creates the methods #click_me_for_fun and #click_me_for_fun_link
88
91
  def link(link_text)
89
92
  element(damballa(link_text+"_link")) { |b| b.link(:text=>link_text) }
90
93
  action(damballa(link_text)) { |b| b.link(:text=>link_text).click }
@@ -98,9 +101,10 @@ class PageFactory
98
101
  # and the method for the button itself will have "_button" appended to it. Any special
99
102
  # characters are stripped from the string. Capital letters are made lower case.
100
103
  # And spaces and dashes are converted to underscores.
104
+ # @param button_text [String] The contents of the button's value tag in the HTML
101
105
  #
102
106
  # @example
103
- # button("Click Me For Fun!") #=> Creates the methods #click_me_for_fun and #click_me_for_fun_button
107
+ # button("Click Me For Fun!") => Creates the methods #click_me_for_fun and #click_me_for_fun_button
104
108
  def button(button_text)
105
109
  element(damballa(button_text+"_button")) { |b| b.button(:value=>button_text) }
106
110
  action(damballa(button_text)) { |b| b.button(:value=>button_text).click }
@@ -119,6 +119,7 @@ module StringFactory
119
119
  end
120
120
 
121
121
  # Converts a string to a symbol made up of snake case. Spaces and dashes are changed to underscore. Special characters are removed.
122
+ # @param text [String] The text to be converted to snake case.
122
123
  # @example
123
124
  # damballa("A String of Fun Stuff (for you)") => :a_string_of_fun_stuff_for_you
124
125
  def self.damballa(text)
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.0.9.1'
3
+ s.version = '0.1.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("**/**/**")
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.0.9.1
4
+ version: 0.1.0
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: 2012-12-13 00:00:00.000000000 Z
12
+ date: 2013-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: watir-webdriver