jqueryui_widgets 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,7 +1,13 @@
1
+ == Version 0.5 / 2013-3-29
2
+ * Enhancements
3
+ * Added in Accordion functionality
4
+ * Added documentation on tabs.
5
+ * Added documentation on accordion functionality.
6
+
1
7
  === Version 0.4 / 2013-3-20
2
8
  * Enhancements
3
9
  * Added Menus functionality
4
- * Added documentation on dialogs, menus, progress bar and tabs.
10
+ * Added documentation on dialogs, menus, progress bar.
5
11
  * Added in error handling for Menus.
6
12
 
7
13
  === Version 0.3 / 2013-2-23
@@ -15,7 +21,7 @@
15
21
 
16
22
 
17
23
  === Version 0.2 / 2013-2-20
18
- * Ehnahcements
24
+ * Enhancements
19
25
  * Added Tabs
20
26
 
21
27
  === Version 0.1 / 2013-2-2
@@ -0,0 +1,27 @@
1
+ @focus
2
+ Feature: Using the Accordion Widget
3
+
4
+ This feature will test using the accordion widget.
5
+
6
+ Background:
7
+ Given I am on the accordion page
8
+
9
+
10
+ Scenario: Getting information from the accordion
11
+ When I select the "Section 2" accordion element
12
+ Then I should see "Sed non urna."
13
+
14
+ Scenario: Selected accordion element
15
+ When I select the "Section 3" accordion element
16
+ Then the current accordion element should be "Section 3"
17
+
18
+ Scenario: Grabbing all scenario names
19
+ Then the accordion labels should include "Section 1"
20
+ And the accordion labels should include "Section 2"
21
+ And the accordion labels should include "Section 3"
22
+ And the accordion labels should include "Section 4"
23
+
24
+ Scenario: Asking if some tab is selected
25
+ When I select the "Section 3" accordion element
26
+ Then the "Section 3" element should be selected
27
+ And the "Section 2" element should not be selected
@@ -0,0 +1,70 @@
1
+ <!doctype html>
2
+
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="utf-8" />
6
+ <title>jQuery UI Accordion - Default functionality</title>
7
+ <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/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.2/jquery-ui.js"></script>
10
+ <link rel="stylesheet" href="/resources/demos/style.css" />
11
+ <script>
12
+ $(function() {
13
+ $( "#accordion" ).accordion();
14
+ });
15
+ </script>
16
+ </head>
17
+ <body>
18
+
19
+ <div id="accordion">
20
+ <h3>Section 1</h3>
21
+ <div>
22
+ <p>
23
+ Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
24
+ ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
25
+ amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
26
+ odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
27
+ </p>
28
+ </div>
29
+ <h3>Section 2</h3>
30
+ <div>
31
+ <p>
32
+ Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
33
+ purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
34
+ velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
35
+ suscipit faucibus urna.
36
+ </p>
37
+ </div>
38
+ <h3>Section 3</h3>
39
+ <div>
40
+ <p>
41
+ Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
42
+ Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
43
+ ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis
44
+ lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
45
+ </p>
46
+ <ul>
47
+ <li>List item one</li>
48
+ <li>List item two</li>
49
+ <li>List item three</li>
50
+ </ul>
51
+ </div>
52
+ <h3>Section 4</h3>
53
+ <div>
54
+ <p>
55
+ Cras dictum. Pellentesque habitant morbi tristique senectus et netus
56
+ et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in
57
+ faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
58
+ mauris vel est.
59
+ </p>
60
+ <p>
61
+ Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
62
+ Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
63
+ inceptos himenaeos.
64
+ </p>
65
+ </div>
66
+ </div>
67
+
68
+
69
+ </body>
70
+ </html>
@@ -15,6 +15,5 @@ Feature: Using the menus widget
15
15
  When I select "Salzburg" and "Delphi" and "Ada"
16
16
  Then I should see the "Salzburg", "Delphi", "Ada" option
17
17
 
18
- @focus
19
18
  Scenario: Should raise error when non-existing menu item is given
20
19
  Then I should have an error when I search for menu item "Taco"
@@ -0,0 +1,23 @@
1
+ Given /^I am on the accordion page$/ do
2
+ visit AccordionPage
3
+ end
4
+
5
+ When /^I select the "([^"]*)" accordion element$/ do |label|
6
+ on(AccordionPage).accordion.select label
7
+ end
8
+
9
+ Then /^the current accordion element should be "([^"]*)"$/ do |label|
10
+ on(AccordionPage).accordion.selected.should == label
11
+ end
12
+
13
+ Then /^the accordion labels should include "([^"]*)"$/ do |label|
14
+ on(AccordionPage).accordion.labels.should include label
15
+ end
16
+
17
+ Then /^the "([^"]*)" element should be selected$/ do |label|
18
+ on(AccordionPage).accordion.selected?(label).should be_true
19
+ end
20
+
21
+ When /^the "([^"]*)" element should not be selected$/ do |label|
22
+ on(AccordionPage).accordion.selected?(label).should be_false
23
+ end
@@ -0,0 +1,11 @@
1
+ class AccordionPage
2
+ include PageObject
3
+
4
+ page_url "file://#{File.expand_path(File.dirname(__FILE__) + '/../../html/accordion.html')}"
5
+
6
+ jqueryui_accordion(:accordion, :id => 'accordion')
7
+
8
+ def accordion
9
+ accordion_element
10
+ end
11
+ end
@@ -4,6 +4,7 @@ require 'jqueryui_widgets/basic_dialog'
4
4
  require 'jqueryui_widgets/tabs'
5
5
  require 'jqueryui_widgets/progress_bar'
6
6
  require 'jqueryui_widgets/menus'
7
+ require 'jqueryui_widgets/accordion'
7
8
 
8
9
  module JQueryUIWidgets
9
10
 
@@ -11,5 +12,6 @@ module JQueryUIWidgets
11
12
  PageObject.register_widget(:jqueryui_tabs, JQueryUIWidgets::Tabs, 'ul')
12
13
  PageObject.register_widget(:jqueryui_progress_bar, JQueryUIWidgets::ProgressBar, 'div')
13
14
  PageObject.register_widget(:jqueryui_menus, JQueryUIWidgets::Menus, 'ul')
15
+ PageObject.register_widget(:jqueryui_accordion, JQueryUIWidgets::Accordion, 'div')
14
16
 
15
17
  end
@@ -0,0 +1,76 @@
1
+
2
+ #
3
+ # Accordion class to make use of the Accordion widget.
4
+ #
5
+ class JQueryUIWidgets::Accordion < PageObject::Elements::Div
6
+
7
+ #
8
+ # Select method will take a single parameter
9
+ # and click on the h3 element to select it.
10
+ #
11
+ # @params [string] of the header you want to find
12
+ #
13
+ # @example
14
+ # select('Section 2') will click on the
15
+ # Section 2 header element and open it.
16
+ #
17
+ def select(item)
18
+ the_accordions = headers
19
+ index = the_accordions.find_index do |accordion|
20
+ accordion.text == item
21
+ end
22
+ the_accordions[index].click
23
+ wait_for_content(index)
24
+ end
25
+
26
+ #
27
+ # Selected method will check the currently selected
28
+ # accordion element by checking if the class
29
+ # 'ui-accordin-header-active' is present within
30
+ # the accordion element.
31
+ #
32
+ def selected
33
+ h3_element(:class => 'ui-accordion-header-active').text
34
+ end
35
+
36
+ #
37
+ # Selected? compares the passed in label
38
+ # with the current h3_element text and returns
39
+ # a boolean result.
40
+ #
41
+ # @params
42
+ # selected?[label] of the item you want to compare
43
+ #
44
+ # @example
45
+ # selected?('Section 3') will compare the
46
+ # currently selected header with the 'Section 3'
47
+ # variable, and return true or false.
48
+
49
+ def selected?(label)
50
+ selected == label
51
+ end
52
+
53
+ #
54
+ # labels method will map all of the
55
+ # headers in the accordion to an array
56
+ # to allow for comparison.
57
+ #
58
+ def labels
59
+ headers.map(&:text)
60
+ end
61
+
62
+ private
63
+
64
+ def wait_for_content(index)
65
+ the_content = div_elements(:class => 'ui-accordion-content')[index]
66
+ wait_until(1, "Content not visible within one second") do
67
+ puts the_content.style("display")
68
+ the_content.style("display") == "block"
69
+ end
70
+ end
71
+
72
+ def headers
73
+ h3_elements(:class => 'ui-accordion-header')
74
+ end
75
+
76
+ end
@@ -1,13 +1,39 @@
1
+
2
+ #
3
+ # Class that wraps the JQueryUI Tabs
4
+ #
5
+
1
6
  class JQueryUIWidgets::Tabs < PageObject::Elements::UnorderedList
2
7
 
8
+ #
9
+ # Select method allows you to find the link element of
10
+ # the tab you want to use, then clicks it.
11
+ #
12
+ # @param [Label] of the item you want to find.
13
+ #
14
+ # @example
15
+ # select('Nunc tincidunt')
16
+ # will click on the 'Nunc tincidunt'
17
+ # tab, selecting it.
18
+ #
3
19
  def select(label)
4
20
  link_element(:text => label).click
5
21
  end
6
22
 
23
+ #
24
+ # Selected method will check the list item,
25
+ # and the link_element of that list item,
26
+ # take the text, and return it.
27
+ #
7
28
  def selected
8
29
  list_item_element(:class => 'ui-tabs-active').link_element.text
9
30
  end
10
31
 
32
+ #
33
+ # Labels method will return all of the
34
+ # link elements of the tabs, and return
35
+ # them for use.
36
+ #
11
37
  def labels
12
38
  link_elements(:class => 'ui-tabs-anchor').map(&:text)
13
39
  end
@@ -1,3 +1,3 @@
1
1
  module JQueryUIWidgets
2
- VERSION = "0.4"
2
+ VERSION = "0.5"
3
3
  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.4'
4
+ version: '0.5'
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-03-20 00:00:00.000000000 Z
13
+ date: 2013-03-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: page-object
@@ -77,7 +77,9 @@ files:
77
77
  - README.md
78
78
  - Rakefile
79
79
  - cucumber.yml
80
+ - features/accordion.feature
80
81
  - features/basic_dialog.feature
82
+ - features/html/accordion.html
81
83
  - features/html/basic_dialog.html
82
84
  - features/html/jquery-1.9.1.js
83
85
  - features/html/jquery-ui.css
@@ -88,6 +90,7 @@ files:
88
90
  - features/html/tabs.html
89
91
  - features/menus.feature
90
92
  - features/progress_bar.feature
93
+ - features/step_definitions/accordion_steps.rb
91
94
  - features/step_definitions/basic_dialog_steps.rb
92
95
  - features/step_definitions/common_steps.rb
93
96
  - features/step_definitions/menu_steps.rb
@@ -95,6 +98,7 @@ files:
95
98
  - features/step_definitions/tab_steps.rb
96
99
  - features/support/env.rb
97
100
  - features/support/hooks.rb
101
+ - features/support/pages/accordion_page.rb
98
102
  - features/support/pages/basic_dialog_page.rb
99
103
  - features/support/pages/menu_page.rb
100
104
  - features/support/pages/progress_bar_page.rb
@@ -102,6 +106,7 @@ files:
102
106
  - features/tabs.feature
103
107
  - jqueryui_widgets.gemspec
104
108
  - lib/jqueryui_widgets.rb
109
+ - lib/jqueryui_widgets/accordion.rb
105
110
  - lib/jqueryui_widgets/basic_dialog.rb
106
111
  - lib/jqueryui_widgets/menus.rb
107
112
  - lib/jqueryui_widgets/progress_bar.rb
@@ -121,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
126
  version: '0'
122
127
  segments:
123
128
  - 0
124
- hash: -2992611760453298873
129
+ hash: -2549649224905780312
125
130
  required_rubygems_version: !ruby/object:Gem::Requirement
126
131
  none: false
127
132
  requirements:
@@ -130,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
135
  version: '0'
131
136
  segments:
132
137
  - 0
133
- hash: -2992611760453298873
138
+ hash: -2549649224905780312
134
139
  requirements: []
135
140
  rubyforge_project:
136
141
  rubygems_version: 1.8.25
@@ -138,7 +143,9 @@ signing_key:
138
143
  specification_version: 3
139
144
  summary: Wrapper around jQueryUI controls for use with page-object gem
140
145
  test_files:
146
+ - features/accordion.feature
141
147
  - features/basic_dialog.feature
148
+ - features/html/accordion.html
142
149
  - features/html/basic_dialog.html
143
150
  - features/html/jquery-1.9.1.js
144
151
  - features/html/jquery-ui.css
@@ -149,6 +156,7 @@ test_files:
149
156
  - features/html/tabs.html
150
157
  - features/menus.feature
151
158
  - features/progress_bar.feature
159
+ - features/step_definitions/accordion_steps.rb
152
160
  - features/step_definitions/basic_dialog_steps.rb
153
161
  - features/step_definitions/common_steps.rb
154
162
  - features/step_definitions/menu_steps.rb
@@ -156,6 +164,7 @@ test_files:
156
164
  - features/step_definitions/tab_steps.rb
157
165
  - features/support/env.rb
158
166
  - features/support/hooks.rb
167
+ - features/support/pages/accordion_page.rb
159
168
  - features/support/pages/basic_dialog_page.rb
160
169
  - features/support/pages/menu_page.rb
161
170
  - features/support/pages/progress_bar_page.rb