bermuda 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bermuda (0.0.1)
5
+ capybara (~> 0.4.0.rc)
6
+ cucumber (~> 0.9.2)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ builder (2.1.2)
12
+ capybara (0.4.0.rc)
13
+ celerity (>= 0.7.9)
14
+ culerity (>= 0.2.4)
15
+ mime-types (>= 1.16)
16
+ nokogiri (>= 1.3.3)
17
+ rack (>= 1.0.0)
18
+ rack-test (>= 0.5.4)
19
+ selenium-webdriver (>= 0.0.27)
20
+ xpath (~> 0.1.2)
21
+ celerity (0.8.2)
22
+ childprocess (0.1.0)
23
+ ffi (~> 0.6.3)
24
+ cucumber (0.9.2)
25
+ builder (~> 2.1.2)
26
+ diff-lcs (~> 1.1.2)
27
+ gherkin (~> 2.2.5)
28
+ json (~> 1.4.6)
29
+ term-ansicolor (~> 1.0.5)
30
+ culerity (0.2.12)
31
+ diff-lcs (1.1.2)
32
+ ffi (0.6.3)
33
+ rake (>= 0.8.7)
34
+ gherkin (2.2.9)
35
+ json (~> 1.4.6)
36
+ term-ansicolor (~> 1.0.5)
37
+ json (1.4.6)
38
+ json_pure (1.4.6)
39
+ mime-types (1.16)
40
+ nokogiri (1.4.3.1)
41
+ rack (1.2.1)
42
+ rack-test (0.5.6)
43
+ rack (>= 1.0)
44
+ rake (0.8.7)
45
+ rspec (2.0.0)
46
+ rspec-core (= 2.0.0)
47
+ rspec-expectations (= 2.0.0)
48
+ rspec-mocks (= 2.0.0)
49
+ rspec-core (2.0.0)
50
+ rspec-expectations (2.0.0)
51
+ diff-lcs (>= 1.1.2)
52
+ rspec-mocks (2.0.0)
53
+ rspec-core (= 2.0.0)
54
+ rspec-expectations (= 2.0.0)
55
+ rubyzip (0.9.4)
56
+ selenium-webdriver (0.0.29)
57
+ childprocess (>= 0.0.7)
58
+ ffi (~> 0.6.3)
59
+ json_pure
60
+ rubyzip
61
+ term-ansicolor (1.0.5)
62
+ xpath (0.1.2)
63
+ nokogiri (~> 1.3)
64
+
65
+ PLATFORMS
66
+ ruby
67
+
68
+ DEPENDENCIES
69
+ bermuda!
70
+ capybara (~> 0.4.0.rc)
71
+ cucumber (~> 0.9.2)
72
+ rspec (~> 2.0.0)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 John Firebaugh
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ = bermuda
2
+
3
+ Continuing in the naming tradition established by Aruba, Bermuda provides
4
+ cucumber steps for driving out web applications which use jQuery UI widgets.
5
+
6
+ == Usage
7
+
8
+ gem install bermuda
9
+
10
+ Then, just require the library in one of your ruby files under
11
+ <tt>features/support</tt>
12
+
13
+ require 'bermuda/cucumber'
14
+
15
+ You now have a bunch of step definitions that you can use in your features.
16
+ Look at aruba/cucumber.rb to see all the step definitions. Look at
17
+ features/*.feature for examples (which are also testing Bermuda itself).
18
+
19
+ == Selector Helpers
20
+
21
+ Bermuda provides some selector helpers that work in concert with Bodaniel Jeanes's
22
+ selector helpers extension to cucumber-rails:
23
+
24
+ http://github.com/aslakhellesoy/cucumber-rails/pull/63
25
+
26
+ First, make sure your web_steps.rb is set up to support selector helpers. Follow
27
+ the steps outlined in Bo's blog post:
28
+
29
+ http://bjeanes.com/2010/09/19/selector-free-cucumber-scenarios
30
+
31
+ Then add the following lines to your selectors.rb:
32
+
33
+ when /the "([^"]+)" accordion section/
34
+ [:xpath, Bermuda::XPath.accordion_content($1)]
35
+ when /the "([^"]+)" dialog/
36
+ [:xpath, Bermuda::XPath.dialog_content($1)]
37
+ when /the "([^"]+)" tab/
38
+ [:xpath, Bermuda::XPath.tab_content($1)]
39
+
40
+ Now you can write steps such `Then I should see "foo" within the "bar" accordion section`
41
+ and `When I click "Save" within the "Save Changes" dialog`.
42
+
43
+ == Copyright
44
+
45
+ Copyright (c) 2010 John Firebaugh. See LICENSE for details.
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ require 'cucumber/rake/task'
3
+
4
+ Bundler::GemHelper.install_tasks
5
+ Cucumber::Rake::Task.new
6
+
7
+ task :default => :cucumber
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "bermuda/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "bermuda"
7
+ s.version = Bermuda::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["John Firebaugh"]
10
+ s.email = ["john.firebaugh@gmail.com"]
11
+ s.homepage = "http://rubygems.org/gems/bermuda"
12
+ s.summary = %q{jQuery UI steps for cucumber and capybara}
13
+ s.description = %q{Provides cucumber step definitions for testing jQuery UI widget interactions with capybara}
14
+
15
+ s.rubyforge_project = "bermuda"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency "cucumber", "~> 0.9.2"
23
+ s.add_dependency "capybara", "~> 0.4.0.rc"
24
+
25
+ s.add_development_dependency "rspec", "~> 2.0.0"
26
+ end
@@ -0,0 +1,69 @@
1
+ Feature: Step definitions
2
+ As a developer
3
+ I want step definitions that allow me to interact with jQuery UI widgets
4
+
5
+ Scenario: Accordion steps
6
+ When I visit the accordion page
7
+ Then I should see the following accordion sections:
8
+ | Section 1 |
9
+ | Section 2 |
10
+ | Section 3 |
11
+ | Section 4 |
12
+ And the "Section 1" accordion section should be active
13
+ And the "Section 2" accordion section should not be active
14
+
15
+ When I activate the "Section 2" accordion section
16
+ And the "Section 1" accordion section should not be active
17
+ And the "Section 2" accordion section should be active
18
+ And I should see "Sed non urna" within the "Section 2" accordion section
19
+
20
+ Scenario: Autocomplete steps
21
+ When I visit the autocomplete page
22
+ And I fill in "Tags" with "R"
23
+ Then I should see the following completions:
24
+ | ActionScript |
25
+ | AppleScript |
26
+ | Clojure |
27
+ | Erlang |
28
+ | Fortran |
29
+ | Groovy |
30
+ | JavaScript |
31
+ | Perl |
32
+ | Ruby |
33
+
34
+ When I select the "Ruby" completion
35
+ Then the "Tags" field should contain "Ruby"
36
+
37
+ Scenario: Dialog steps
38
+ When I visit the dialog page
39
+ Then I should see the "Basic dialog" dialog
40
+ And I should see "This is the default dialog" within the "Basic dialog" dialog
41
+
42
+ When I close the "Basic dialog" dialog
43
+ Then I should not see the "Basic dialog" dialog
44
+
45
+ Scenario: Progressbar steps
46
+ When I visit the progressbar page
47
+ Then the progress bar should be at 37%
48
+ Then the progress bar should be at 37 percent
49
+
50
+ Scenario: Slider steps
51
+ When I visit the slider page
52
+ Then the slider should be at 0
53
+
54
+ When I set the slider to 37
55
+ Then the slider should be at 37
56
+
57
+ Scenario: Tabs steps
58
+ When I visit the tabs page
59
+ Then I should see the following tabs:
60
+ | Nunc tincidunt |
61
+ | Proin dolor |
62
+ | Aenean lacinia |
63
+ And the "Nunc tincidunt" tab should be active
64
+ And the "Proin dolor" tab should not be active
65
+
66
+ When I activate the "Proin dolor" tab
67
+ And the "Nunc tincidunt" tab should not be active
68
+ And the "Proin dolor" tab should be active
69
+ And I should see "Morbi tincidunt" within the "Proin dolor" tab
@@ -0,0 +1,34 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
2
+
3
+ module WithinHelpers
4
+ def with_scope(locator)
5
+ locator ? within(*selector_for(locator)) { yield } : yield
6
+ end
7
+ end
8
+ World(WithinHelpers)
9
+
10
+ # Single-line step scoper
11
+ When /^(.*) within ([^:]+)$/ do |step, parent|
12
+ with_scope(parent) { When step }
13
+ end
14
+
15
+ # Multi-line step scoper
16
+ When /^(.*) within ([^:]+):$/ do |step, parent, table_or_string|
17
+ with_scope(parent) { When "#{step}:", table_or_string }
18
+ end
19
+
20
+ When /^I visit the (.+) page$/ do |page|
21
+ visit("/#{page}.html")
22
+ end
23
+
24
+ Then /^I should see "([^"]+)"$/ do |text|
25
+ page.should have_content(text)
26
+ end
27
+
28
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
29
+ fill_in(field, :with => value)
30
+ end
31
+
32
+ Then /^the "([^"]*)" field should contain "([^"]*)"$/ do |field, value|
33
+ find_field(field).value.should == value
34
+ end
@@ -0,0 +1,16 @@
1
+ require 'bundler'
2
+ Bundler.require
3
+
4
+ require 'capybara/cucumber'
5
+ require 'bermuda/cucumber'
6
+
7
+ require 'rack/builder'
8
+ require 'rack/file'
9
+ require 'rack/directory'
10
+
11
+ Capybara.configure do |config|
12
+ config.default_driver = :selenium
13
+ config.app = Rack::Builder.app do
14
+ run Rack::Directory.new "features/support/public"
15
+ end
16
+ end
@@ -0,0 +1,62 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Accordion</title>
5
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
6
+ <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script>
7
+ <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/base/jquery-ui.css">
8
+ <script>
9
+ $(function() { $( "#accordion" ).accordion(); });
10
+ </script>
11
+ </head>
12
+ <body>
13
+ <div id="accordion">
14
+ <h3><a href="#">Section 1</a></h3>
15
+ <div>
16
+ <p>
17
+ Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
18
+ ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
19
+ amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
20
+ odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
21
+ </p>
22
+ </div>
23
+ <h3><a href="#">Section 2</a></h3>
24
+ <div>
25
+ <p>
26
+ Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
27
+ purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
28
+ velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
29
+ suscipit faucibus urna.
30
+ </p>
31
+ </div>
32
+ <h3><a href="#">Section 3</a></h3>
33
+ <div>
34
+ <p>
35
+ Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
36
+ Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
37
+ ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis
38
+ lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
39
+ </p>
40
+ <ul>
41
+ <li>List item one</li>
42
+ <li>List item two</li>
43
+ <li>List item three</li>
44
+ </ul>
45
+ </div>
46
+ <h3><a href="#">Section 4</a></h3>
47
+ <div>
48
+ <p>
49
+ Cras dictum. Pellentesque habitant morbi tristique senectus et netus
50
+ et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in
51
+ faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
52
+ mauris vel est.
53
+ </p>
54
+ <p>
55
+ Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
56
+ Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
57
+ inceptos himenaeos.
58
+ </p>
59
+ </div>
60
+ </div>
61
+ </body>
62
+ </html>
@@ -0,0 +1,46 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Autocomplete</title>
5
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
6
+ <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script>
7
+ <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/base/jquery-ui.css">
8
+ <script>
9
+ $(function() {
10
+ var availableTags = [
11
+ "ActionScript",
12
+ "AppleScript",
13
+ "Asp",
14
+ "BASIC",
15
+ "C",
16
+ "C++",
17
+ "Clojure",
18
+ "COBOL",
19
+ "ColdFusion",
20
+ "Erlang",
21
+ "Fortran",
22
+ "Groovy",
23
+ "Haskell",
24
+ "Java",
25
+ "JavaScript",
26
+ "Lisp",
27
+ "Perl",
28
+ "PHP",
29
+ "Python",
30
+ "Ruby",
31
+ "Scala",
32
+ "Scheme"
33
+ ];
34
+ $( "#tags" ).autocomplete({
35
+ source: availableTags
36
+ });
37
+ });
38
+ </script>
39
+ </head>
40
+ <body>
41
+ <div class="ui-widget">
42
+ <label for="tags">Tags: </label>
43
+ <input id="tags">
44
+ </div>
45
+ </body>
46
+ </html>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dialog</title>
5
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
6
+ <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script>
7
+ <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/base/jquery-ui.css">
8
+ <script>
9
+ $(function() { $( "#dialog" ).dialog(); });
10
+ </script>
11
+ </head>
12
+ <body>
13
+ <div id="dialog" title="Basic dialog">
14
+ <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
15
+ </div>
16
+ </body>
17
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Progress Bar</title>
5
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
6
+ <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script>
7
+ <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/base/jquery-ui.css">
8
+ <script>
9
+ $(function() { $( "#progressbar" ).progressbar({value: 37}); });
10
+ </script>
11
+ </head>
12
+ <body>
13
+ <div id="progressbar"></div>
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Slider</title>
5
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
6
+ <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script>
7
+ <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/base/jquery-ui.css">
8
+ <script>
9
+ $(function() { $( "#slider" ).slider(); });
10
+ </script>
11
+ </head>
12
+ <body>
13
+ <div id="slider"></div>
14
+ </body>
15
+ </html>
@@ -0,0 +1,31 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Tabs</title>
5
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
6
+ <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script>
7
+ <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/base/jquery-ui.css">
8
+ <script>
9
+ $(function() { $( "#tabs" ).tabs(); });
10
+ </script>
11
+ </head>
12
+ <body>
13
+ <div id="tabs">
14
+ <ul>
15
+ <li><a href="#tabs-1">Nunc tincidunt</a></li>
16
+ <li><a href="#tabs-2">Proin dolor</a></li>
17
+ <li><a href="#tabs-3">Aenean lacinia</a></li>
18
+ </ul>
19
+ <div id="tabs-1">
20
+ <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
21
+ </div>
22
+ <div id="tabs-2">
23
+ <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p>
24
+ </div>
25
+ <div id="tabs-3">
26
+ <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p>
27
+ <p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit.</p>
28
+ </div>
29
+ </div>
30
+ </body>
31
+ </html>
@@ -0,0 +1,25 @@
1
+ module HtmlSelectorsHelpers
2
+ # Maps a name to a selector. Used primarily by the
3
+ #
4
+ # When /^(.+) within (.+)$/ do |step, scope|
5
+ #
6
+ # step definitions in web_steps.rb
7
+ #
8
+ def selector_for(locator)
9
+ case locator
10
+
11
+ when /the "([^"]+)" accordion section/
12
+ [:xpath, Bermuda::XPath.accordion_content($1)]
13
+ when /the "([^"]+)" dialog/
14
+ [:xpath, Bermuda::XPath.dialog_content($1)]
15
+ when /the "([^"]+)" tab/
16
+ [:xpath, Bermuda::XPath.tab_content($1)]
17
+
18
+ else
19
+ raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
20
+ "Now, go and add a mapping in #{__FILE__}"
21
+ end
22
+ end
23
+ end
24
+
25
+ World(HtmlSelectorsHelpers)
@@ -0,0 +1,6 @@
1
+ # Nothing is required by default, so you can specify `gem :bermuda` in
2
+ # your Gemfile without actually loading any step definitions (which require
3
+ # the cucumber environment established by the 'cucumber' command).
4
+
5
+ # To load the step definitions, require 'bermuda/cucumber' within a
6
+ # file in features/support/ or features/step_definitions/.
@@ -0,0 +1,79 @@
1
+ require 'bermuda/xpath'
2
+
3
+ # Accordion
4
+
5
+ Then /^I should see the following accordion sections:$/ do |titles|
6
+ wait_until { page.has_xpath?(Bermuda::XPath.accordion_header) }
7
+ titles.diff!(all(:xpath, Bermuda::XPath.accordion_header).map {|node| [node.text]})
8
+ end
9
+
10
+ Then /^the "([^"]+)" accordion section should be active$/ do |title|
11
+ page.should have_xpath(Bermuda::XPath.accordion_header(title, :active => true))
12
+ end
13
+
14
+ Then /^the "([^"]+)" accordion section should not be active$/ do |title|
15
+ page.should have_xpath(Bermuda::XPath.accordion_header(title, :active => false))
16
+ end
17
+
18
+ When /^I activate the "([^"]+)" accordion section$/ do |title|
19
+ find(:xpath, Bermuda::XPath.accordion_header(title).child(:a)).click
20
+ end
21
+
22
+ # Autocomplete
23
+
24
+ Then /^I should see the following completions:$/ do |choices|
25
+ wait_until { page.has_xpath?(Bermuda::XPath.autocompletion) }
26
+ choices.diff!(all(:xpath, Bermuda::XPath.autocompletion).map {|node| [node.text]})
27
+ end
28
+
29
+ When /^I select the "([^"]+)" completion$/ do |text|
30
+ find(:xpath, Bermuda::XPath.autocompletion(text).child(:a)).click
31
+ end
32
+
33
+ # Dialog
34
+
35
+ Then /^I should see the "([^"]+)" dialog$/ do |title|
36
+ page.should have_xpath(Bermuda::XPath.dialog(title), :visible => true)
37
+ end
38
+
39
+ Then /^I should not see the "([^"]+)" dialog$/ do |title|
40
+ page.should_not have_xpath(Bermuda::XPath.dialog(title), :visible => true)
41
+ end
42
+
43
+ When /^I close the "([^"]+)" dialog$/ do |title|
44
+ find(:xpath, Bermuda::XPath.dialog(title), :visible => true).click_link('close')
45
+ end
46
+
47
+ # Progress bar
48
+
49
+ Then /^the progress bar should be at (\d+)(?: percent|%)$/ do |value|
50
+ page.should have_xpath(Bermuda::XPath.progressbar(:value => value))
51
+ end
52
+
53
+ # Slider
54
+
55
+ Then /^the slider should be at (\d+)$/ do |value|
56
+ pending
57
+ end
58
+
59
+ When /^I set the slider to (\d+)$/ do |value|
60
+ pending
61
+ end
62
+
63
+ # Tabs
64
+
65
+ Then /^I should see the following tabs:$/ do |titles|
66
+ titles.diff!(all(:xpath, Bermuda::XPath.tab_header).map {|node| [node.text]})
67
+ end
68
+
69
+ Then /^the "([^"]+)" tab should be active$/ do |title|
70
+ page.should have_xpath(Bermuda::XPath.tab_header(title, :active => true))
71
+ end
72
+
73
+ Then /^the "([^"]+)" tab should not be active$/ do |title|
74
+ page.should have_xpath(Bermuda::XPath.tab_header(title, :active => false))
75
+ end
76
+
77
+ When /^I activate the "([^"]+)" tab$/ do |title|
78
+ find(:xpath, Bermuda::XPath.tab_header(title).child(:a)).click
79
+ end
@@ -0,0 +1,3 @@
1
+ module Bermuda
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,80 @@
1
+ require 'xpath'
2
+
3
+ module XPath
4
+ class Expression
5
+ class Includes < Binary
6
+ # http://pivotallabs.com/users/alex/blog/articles/427-xpath-css-class-matching
7
+ def to_xpath(predicate=nil)
8
+ "contains(concat(' ', normalize-space(#{@left.to_xpath(predicate)}), ' '), concat(' ', #{@right.to_xpath(predicate)}, ' '))"
9
+ end
10
+ end
11
+
12
+ def includes(expression)
13
+ Includes.new(current, expression)
14
+ end
15
+ end
16
+ end
17
+
18
+ module Bermuda
19
+ module XPath
20
+ include ::XPath
21
+ extend self
22
+
23
+ def accordion_header(title = nil, options = {})
24
+ xpath = descendant[attr(:class).includes('ui-accordion-header')]
25
+
26
+ if options.key?(:active)
27
+ state = attr(:class).includes('ui-state-active')
28
+ state = ~state unless options[:active]
29
+ xpath = xpath[state]
30
+ end
31
+
32
+ xpath = xpath[descendant(:a).text.is title] if title
33
+ xpath
34
+ end
35
+
36
+ def autocompletion(text = nil)
37
+ xpath = descendant[attr(:class).includes('ui-autocomplete')]
38
+ xpath = xpath.descendant[attr(:class).includes('ui-menu-item')]
39
+ xpath = xpath[descendant(:a).text.is text] if text
40
+ xpath
41
+ end
42
+
43
+ def accordion_content(title = nil, options = {})
44
+ accordion_header(title, options).next_sibling
45
+ end
46
+
47
+ def dialog(title = nil)
48
+ xpath = descendant[attr(:class).includes('ui-dialog')]
49
+ xpath = xpath[descendant[attr(:class).includes('ui-dialog-title')].text.is title] if title
50
+ xpath
51
+ end
52
+
53
+ def dialog_content(title = nil)
54
+ dialog(title).descendant[attr(:class).includes('ui-dialog-content')]
55
+ end
56
+
57
+ def progressbar(options = {})
58
+ xpath = descendant[attr(:class).includes('ui-progressbar')]
59
+ xpath = xpath[attr(:'aria-valuenow') == options[:value]] if options[:value]
60
+ xpath
61
+ end
62
+
63
+ def tab_header(title = nil, options = {})
64
+ xpath = descendant[attr(:class).includes('ui-tabs-nav')].child
65
+
66
+ if options.key?(:active)
67
+ state = attr(:class).includes('ui-state-active')
68
+ state = ~state unless options[:active]
69
+ xpath = xpath[state]
70
+ end
71
+
72
+ xpath = xpath[descendant(:a).text.is title] if title
73
+ xpath
74
+ end
75
+
76
+ def tab_content(title = nil, options = {})
77
+ descendant[Expression::Literal.new("concat('#', @id)") == anywhere(tab_header(title, options)).descendant(:a).attr(:href)]
78
+ end
79
+ end
80
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bermuda
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - John Firebaugh
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-10-17 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: cucumber
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 9
31
+ - 2
32
+ version: 0.9.2
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: capybara
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 0
45
+ - 4
46
+ - 0
47
+ - rc
48
+ version: 0.4.0.rc
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: rspec
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ segments:
60
+ - 2
61
+ - 0
62
+ - 0
63
+ version: 2.0.0
64
+ type: :development
65
+ version_requirements: *id003
66
+ description: Provides cucumber step definitions for testing jQuery UI widget interactions with capybara
67
+ email:
68
+ - john.firebaugh@gmail.com
69
+ executables: []
70
+
71
+ extensions: []
72
+
73
+ extra_rdoc_files: []
74
+
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - LICENSE
80
+ - README.rdoc
81
+ - Rakefile
82
+ - bermuda.gemspec
83
+ - features/step_definitions.feature
84
+ - features/step_definitions/web_steps.rb
85
+ - features/support/env.rb
86
+ - features/support/public/accordion.html
87
+ - features/support/public/autocomplete.html
88
+ - features/support/public/dialog.html
89
+ - features/support/public/progressbar.html
90
+ - features/support/public/slider.html
91
+ - features/support/public/tabs.html
92
+ - features/support/selectors.rb
93
+ - lib/bermuda.rb
94
+ - lib/bermuda/cucumber.rb
95
+ - lib/bermuda/version.rb
96
+ - lib/bermuda/xpath.rb
97
+ has_rdoc: true
98
+ homepage: http://rubygems.org/gems/bermuda
99
+ licenses: []
100
+
101
+ post_install_message:
102
+ rdoc_options: []
103
+
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ segments:
112
+ - 0
113
+ version: "0"
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ segments:
120
+ - 0
121
+ version: "0"
122
+ requirements: []
123
+
124
+ rubyforge_project: bermuda
125
+ rubygems_version: 1.3.7
126
+ signing_key:
127
+ specification_version: 3
128
+ summary: jQuery UI steps for cucumber and capybara
129
+ test_files:
130
+ - features/step_definitions.feature
131
+ - features/step_definitions/web_steps.rb
132
+ - features/support/env.rb
133
+ - features/support/public/accordion.html
134
+ - features/support/public/autocomplete.html
135
+ - features/support/public/dialog.html
136
+ - features/support/public/progressbar.html
137
+ - features/support/public/slider.html
138
+ - features/support/public/tabs.html
139
+ - features/support/selectors.rb