Skip to content

Commit

Permalink
Spinner functionality, version bump, documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Clewell committed May 24, 2013
1 parent 3a522aa commit 337fdfe
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 10 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
== Version 0.6
== Version 0.6 / 2013-5-24
* Enhancements
* New functionality from Page Object
* Added in Slider functionality
* Added in Spinner functionality
* Additional documentation for all widgets

== Version 0.5 / 2013-3-29
Expand Down
16 changes: 10 additions & 6 deletions features/spinner.feature
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@

Feature: Using the JQueryUI Spinner Widget

Background:
Given I am on the spinner page

@focus
Scenario: Spinner enable and disable toggle
When I click the "Toggle disable/enable" button
Then the Spinner widget should be disabled
When I click the "Toggle disable/enable" button
Then the Spinner widget should be enabled
Scenario: Adjust the spinner value with arrows
When I click the increment button
Then the Spinner Widget should read "1"
When I click the decrement button
Then the Spinner Widget should read "0"

Scenario: Manually set the spinner value
When I set the spinner value to "10"
Then the Spinner Widget should read "10"
16 changes: 16 additions & 0 deletions features/step_definitions/spinner_steps.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
Given /^I am on the spinner page$/ do
visit SpinnerPage
end

When(/^I click the increment button$/) do
on(SpinnerPage).increment_the_spinner
end

Then(/^the Spinner Widget should read "([^"]*)"$/) do |value|
on(SpinnerPage).the_spinner.should == value
end

When(/^I click the decrement button$/) do
on(SpinnerPage).decrement_the_spinner
end

When(/^I set the spinner value to "([^"]*)"$/) do |value|
on(SpinnerPage).the_spinner = value
end
7 changes: 7 additions & 0 deletions features/support/pages/spinner_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@ class SpinnerPage
include PageObject

page_url "file://#{File.expand_path(File.dirname(__FILE__) + '/../../html/spinner.html')}"

jqueryui_spinner(:the_spinner, :class => 'ui-spinner')


def spinner
the_spinner_element
end
end
53 changes: 51 additions & 2 deletions lib/jqueryui_widgets/spinner.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
require 'jqueryui_widgets/core_ext/string'
#
# The Spinner Class will serve as a wrapper for the JQuery UI Spinner
# widget, allowing the user to interact with the spinner, setting
# the value either through manual entry, or the up or down arrows attached
# to the widget.
#
# NOTE: The code for the Spinner widget will be kept as basic as possible
# in order to allow the user to tailor the class to suit their own
# needs in case customization of the spinner has been exercised.
#
class JQueryUIWidgets::Spinner < PageObject::Elements::Span

class JQueryUIWidgets::Spinner < PageObject::Elements::Paragraph
#
# Generates four methods.
#
# The increment_{NAME} method allows the user to click the
# up arrow and increment the value of the widget by 1.
#
# The decrement_{NAME} method allows the user to click the
# down arrow and decrement the value of the widget by 1.
#
# The {NAME} method allows the user to return the current
# value of the widget.
#
# The {NAME}_set method allows the user to set the value
# of the widget.
#
# @example
# the_spinner = 15
#
# Will set the spinner to 15.
#
def self.accessor_methods(accessor, name)
accessor.send :define_method, "increment_#{name}" do
spinner = self.send "#{name}_element"
spinner.link_element(:class => 'ui-spinner-up').click
end

accessor.send :define_method, "decrement_#{name}" do
spinner = self.send "#{name}_element"
spinner.link_element(:class => 'ui-spinner-down').click
end

accessor.send :define_method, "#{name}" do
spinner = self.send "#{name}_element"
spinner.text_field_element(:id => 'spinner').value
end

accessor.send :define_method, "#{name}=" do |value|
spinner = self.send "#{name}_element"
spinner.text_field_element(:id => 'spinner').value = value
end
end
end
2 changes: 1 addition & 1 deletion lib/jqueryui_widgets/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module JQueryUIWidgets
VERSION = "0.5"
VERSION = "0.6"
end

0 comments on commit 337fdfe

Please sign in to comment.