jqueryui_widgets 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1,2 +1,2 @@
1
- rvm --create use 1.9.3-p194@page-object
1
+ rvm --create use 1.9.3-p392@page-object
2
2
 
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ === Version 0.4 / 2013-3-20
2
+ * Enhancements
3
+ * Added Menus functionality
4
+ * Added documentation on dialogs, menus, progress bar and tabs.
5
+ * Added in error handling for Menus.
6
+
1
7
  === Version 0.3 / 2013-2-23
2
8
  * Enhancements
3
9
  * Added selected method to Tabs
data/Gemfile CHANGED
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
3
3
  gem 'rake'
4
4
  gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
5
5
  gem 'guard-cucumber'
6
+ gem 'growl'
6
7
 
7
8
  # Specify your gem's dependencies in jqueryui_widgets.gemspec
8
9
  gemspec
data/Guardfile CHANGED
@@ -1,4 +1,4 @@
1
- guard 'cucumber', :notification => false, :all_after_pass => false, :cli => '--profile focus' do
1
+ guard 'cucumber', :notification => true, :all_after_pass => false, :cli => '--profile focus' do
2
2
  watch(%r{^features/.+\.feature$})
3
3
  watch(%r{^features/support/.+$}) { 'features' }
4
4
  watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { 'features' }
@@ -0,0 +1,63 @@
1
+ <!doctype html>
2
+
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="utf-8" />
6
+ <title>jQuery UI Menu - Default functionality</title>
7
+ <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
8
+ <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
9
+ <script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
10
+ <link rel="stylesheet" href="/resources/demos/style.css" />
11
+ <script>
12
+ $(function() {
13
+ $( "#menu" ).menu();
14
+ });
15
+ </script>
16
+ <style>
17
+ .ui-menu { width: 150px; }
18
+ </style>
19
+ </head>
20
+ <body>
21
+
22
+ <ul id="menu">
23
+ <li class="ui-state-disabled"><a href="#">Aberdeen</a></li>
24
+ <li><a href="#">Ada</a></li>
25
+ <li><a href="#">Adamsville</a></li>
26
+ <li><a href="#">Addyston</a></li>
27
+ <li>
28
+ <a href="#">Delphi</a>
29
+ <ul>
30
+ <li class="ui-state-disabled"><a href="#">Ada</a></li>
31
+ <li><a href="#">Saarland</a></li>
32
+ <li><a href="#">Salzburg</a></li>
33
+ </ul>
34
+ </li>
35
+ <li><a href="#">Saarland</a></li>
36
+ <li>
37
+ <a href="#">Salzburg</a>
38
+ <ul>
39
+ <li>
40
+ <a href="#">Delphi</a>
41
+ <ul>
42
+ <li><a href="#">Ada</a></li>
43
+ <li><a href="#">Saarland</a></li>
44
+ <li><a href="#">Salzburg</a></li>
45
+ </ul>
46
+ </li>
47
+ <li>
48
+ <a href="#">Delphi</a>
49
+ <ul>
50
+ <li><a href="#">Ada</a></li>
51
+ <li><a href="#">Saarland</a></li>
52
+ <li><a href="#">Salzburg</a></li>
53
+ </ul>
54
+ </li>
55
+ <li><a href="#">Perch</a></li>
56
+ </ul>
57
+ </li>
58
+ <li class="ui-state-disabled"><a href="#">Amesville</a></li>
59
+ </ul>
60
+
61
+
62
+ </body>
63
+ </html>
@@ -0,0 +1,20 @@
1
+ Feature: Using the menus widget
2
+
3
+ This feature will test the ability to interact with menus and submenus.
4
+
5
+ Background:
6
+ Given I am on the menus page
7
+
8
+
9
+ Scenario: Using the menu widget
10
+ When I select the "Delphi" menu option
11
+ Then I should see the inactive option "Delphi", "Ada"
12
+ And I should see the "Delphi", "Saarland" option
13
+
14
+ Scenario: Selecting submenu items
15
+ When I select "Salzburg" and "Delphi" and "Ada"
16
+ Then I should see the "Salzburg", "Delphi", "Ada" option
17
+
18
+ @focus
19
+ Scenario: Should raise error when non-existing menu item is given
20
+ Then I should have an error when I search for menu item "Taco"
@@ -0,0 +1,30 @@
1
+ Given /^I am on the menus page$/ do
2
+ visit MenuPage
3
+ end
4
+
5
+ When /^I select the "(.+)" menu option$/ do |item|
6
+ on(MenuPage).menus.select item
7
+ end
8
+
9
+ Then /^I should see the inactive option "(.+)", "(.+)"$/ do |item1, item2|
10
+ item = on(MenuPage).menus.search_for(item1, item2)
11
+ item.attribute('class').should include 'ui-state-disabled'
12
+ end
13
+
14
+ When /^I should see the "(.+)", "(.+)", "(.+)" option$/ do |item1, item2, item3|
15
+ item = on(MenuPage).menus.search_for(item1, item2, item3)
16
+ item.should_not be_nil
17
+ end
18
+
19
+ When /^I select "(.+)" and "(.+)" and "(.+)"$/ do |item1, item2, item3|
20
+ on(MenuPage).menus.select item1, item2, item3
21
+ end
22
+
23
+ Then /^I should have an error when I search for menu item "([^"]*)"$/ do |item|
24
+ expect {on(MenuPage).menus.search_for(item)}.to raise_error("Unable to find menu item #{item}")
25
+ end
26
+
27
+ When /^I should see the "([^"]*)", "([^"]*)" option$/ do |item1, item2|
28
+ item = on(MenuPage).menus.search_for(item1, item2)
29
+ item.should_not be_nil
30
+ end
@@ -0,0 +1,11 @@
1
+ class MenuPage
2
+ include PageObject
3
+
4
+ page_url "file://#{File.expand_path(File.dirname(__FILE__) + '/../../html/menus.html')}"
5
+
6
+ jqueryui_menus(:menus, :class => 'ui-menu')
7
+
8
+ def menus
9
+ menus_element
10
+ end
11
+ end
@@ -1,13 +1,30 @@
1
+
2
+ #
3
+ # Basic Dialog allows JQuery UI Widgets to interact
4
+ # with the basic dialogs that JQueryUI pops up.
5
+ #
1
6
  class JQueryUIWidgets::BasicDialog < PageObject::Elements::Div
2
7
 
8
+ #
9
+ # The title function grabs the span element of the title
10
+ # bar in the UI dialog and returns the text.
11
+ #
3
12
  def title
4
13
  div_element(:class => 'ui-dialog-titlebar').span_element.text
5
14
  end
6
15
 
16
+ #
17
+ # Content function will return the entire text of
18
+ # the JQuery UI dialog box.
19
+ #
7
20
  def content
8
21
  div_element(:class => 'ui-dialog-content').text
9
22
  end
10
23
 
24
+ #
25
+ # Close function will, of course, click the button
26
+ # labeled close.
27
+ #
11
28
  def close
12
29
  button_element(:class => 'ui-dialog-titlebar-close').click
13
30
  end
@@ -0,0 +1,68 @@
1
+
2
+ #
3
+ # Class that wraps the jQueryUI menu.
4
+ #
5
+ class JQueryUIWidgets::Menus < PageObject::Elements::UnorderedList
6
+
7
+ #
8
+ # The select method allows you to pass in a theoretically
9
+ # infinite number of variables from the base source through the
10
+ # step definitions and into page to iterate through the top
11
+ # menu and into any submenus you encounter.
12
+ #
13
+ # @params [Array] the menu items to find. Items will be found
14
+ # in the order in which they were provided.
15
+ #
16
+ # @example
17
+ # select('Salzburg', 'Delphi', 'Ada')
18
+ # will click through the menu 'Salzburg'
19
+ # the sub menu 'Delphi'
20
+ # and click on 'Ada' in the final submenu
21
+ #
22
+ def select(*labels)
23
+ loop_through_menu_items(labels) do |list_item|
24
+ list_item.fire_event('onclick')
25
+ end
26
+ end
27
+
28
+ #
29
+ # Search_for allows the user to supplement the select method
30
+ # and search for a specific element within a menu or sub-menu.
31
+ #
32
+ # @params [Array] the menu items to search for. Items will
33
+ # be found in the order they are given.
34
+ #
35
+ # @example
36
+ # search_for('Delphi', 'Ada')
37
+ # will find 'Ada' in the sub-menu.
38
+ #
39
+ def search_for(*labels)
40
+ the_list_item = nil
41
+ loop_through_menu_items(labels) do |list_item|
42
+ the_list_item = list_item
43
+ end
44
+ the_list_item
45
+ end
46
+
47
+ private
48
+
49
+ def loop_through_menu_items(labels)
50
+ menu_container = self
51
+ labels.each do |label|
52
+ item_found = false
53
+ menu_items_for(menu_container).each do |list_item|
54
+ if list_item.text.slice!(label) == label
55
+ yield list_item
56
+ menu_container = list_item.unordered_list_element
57
+ item_found = true
58
+ break
59
+ end
60
+ end
61
+ raise("Unable to find menu item #{label}") unless item_found
62
+ end
63
+ end
64
+
65
+ def menu_items_for(menu)
66
+ menu.list_item_elements
67
+ end
68
+ end
@@ -1,13 +1,35 @@
1
+
2
+ #
3
+ # The progress bar class will interact with the
4
+ # JQuery UI Widget Progress Bar and allow for
5
+ # returning the Minimum value, Maximum Value and
6
+ # Current progress.
7
+ #
1
8
  class JQueryUIWidgets::ProgressBar < PageObject::Elements::Div
2
9
 
10
+ #
11
+ # The minimum function returns the minimum
12
+ # possible value of the progress bar by
13
+ # returning the 'aria-valuemin' attribute's
14
+ # value.
15
+ #
3
16
  def minimum
4
17
  convert_to_number attribute('aria-valuemin')
5
18
  end
6
19
 
20
+ #
21
+ # The maximum function returns the maximum
22
+ # value of the progress bar by returning
23
+ # the 'aria-valuemax' attribute's value.
7
24
  def maximum
8
25
  convert_to_number attribute('aria-valuemax')
9
26
  end
10
27
 
28
+ #
29
+ # The Current function returns the current
30
+ # value of the progress bar by returning the
31
+ # 'aria-valuenow' attribute's value.
32
+ #
11
33
  def current
12
34
  convert_to_number attribute('aria-valuenow')
13
35
  end
@@ -1,3 +1,3 @@
1
1
  module JQueryUIWidgets
2
- VERSION = "0.3"
2
+ VERSION = "0.4"
3
3
  end
@@ -3,11 +3,13 @@ require "jqueryui_widgets/version"
3
3
  require 'jqueryui_widgets/basic_dialog'
4
4
  require 'jqueryui_widgets/tabs'
5
5
  require 'jqueryui_widgets/progress_bar'
6
+ require 'jqueryui_widgets/menus'
6
7
 
7
8
  module JQueryUIWidgets
8
9
 
9
10
  PageObject.register_widget(:jqueryui_basic_dialog, JQueryUIWidgets::BasicDialog, 'div')
10
11
  PageObject.register_widget(:jqueryui_tabs, JQueryUIWidgets::Tabs, 'ul')
11
12
  PageObject.register_widget(:jqueryui_progress_bar, JQueryUIWidgets::ProgressBar, 'div')
13
+ PageObject.register_widget(:jqueryui_menus, JQueryUIWidgets::Menus, 'ul')
12
14
 
13
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jqueryui_widgets
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-23 00:00:00.000000000 Z
13
+ date: 2013-03-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: page-object
@@ -82,23 +82,28 @@ files:
82
82
  - features/html/jquery-1.9.1.js
83
83
  - features/html/jquery-ui.css
84
84
  - features/html/jquery-ui.js
85
+ - features/html/menus.html
85
86
  - features/html/progress_bar.html
86
87
  - features/html/style.css
87
88
  - features/html/tabs.html
89
+ - features/menus.feature
88
90
  - features/progress_bar.feature
89
91
  - features/step_definitions/basic_dialog_steps.rb
90
92
  - features/step_definitions/common_steps.rb
93
+ - features/step_definitions/menu_steps.rb
91
94
  - features/step_definitions/progress_bar_steps.rb
92
95
  - features/step_definitions/tab_steps.rb
93
96
  - features/support/env.rb
94
97
  - features/support/hooks.rb
95
98
  - features/support/pages/basic_dialog_page.rb
99
+ - features/support/pages/menu_page.rb
96
100
  - features/support/pages/progress_bar_page.rb
97
101
  - features/support/pages/tabs_page.rb
98
102
  - features/tabs.feature
99
103
  - jqueryui_widgets.gemspec
100
104
  - lib/jqueryui_widgets.rb
101
105
  - lib/jqueryui_widgets/basic_dialog.rb
106
+ - lib/jqueryui_widgets/menus.rb
102
107
  - lib/jqueryui_widgets/progress_bar.rb
103
108
  - lib/jqueryui_widgets/tabs.rb
104
109
  - lib/jqueryui_widgets/version.rb
@@ -116,7 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
121
  version: '0'
117
122
  segments:
118
123
  - 0
119
- hash: -2934056565885187705
124
+ hash: -2992611760453298873
120
125
  required_rubygems_version: !ruby/object:Gem::Requirement
121
126
  none: false
122
127
  requirements:
@@ -125,10 +130,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
130
  version: '0'
126
131
  segments:
127
132
  - 0
128
- hash: -2934056565885187705
133
+ hash: -2992611760453298873
129
134
  requirements: []
130
135
  rubyforge_project:
131
- rubygems_version: 1.8.24
136
+ rubygems_version: 1.8.25
132
137
  signing_key:
133
138
  specification_version: 3
134
139
  summary: Wrapper around jQueryUI controls for use with page-object gem
@@ -138,17 +143,21 @@ test_files:
138
143
  - features/html/jquery-1.9.1.js
139
144
  - features/html/jquery-ui.css
140
145
  - features/html/jquery-ui.js
146
+ - features/html/menus.html
141
147
  - features/html/progress_bar.html
142
148
  - features/html/style.css
143
149
  - features/html/tabs.html
150
+ - features/menus.feature
144
151
  - features/progress_bar.feature
145
152
  - features/step_definitions/basic_dialog_steps.rb
146
153
  - features/step_definitions/common_steps.rb
154
+ - features/step_definitions/menu_steps.rb
147
155
  - features/step_definitions/progress_bar_steps.rb
148
156
  - features/step_definitions/tab_steps.rb
149
157
  - features/support/env.rb
150
158
  - features/support/hooks.rb
151
159
  - features/support/pages/basic_dialog_page.rb
160
+ - features/support/pages/menu_page.rb
152
161
  - features/support/pages/progress_bar_page.rb
153
162
  - features/support/pages/tabs_page.rb
154
163
  - features/tabs.feature