bjeanes-capybara 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +87 -0
  3. data/README.rdoc +404 -0
  4. data/Rakefile +29 -0
  5. data/config.ru +6 -0
  6. data/lib/capybara.rb +53 -0
  7. data/lib/capybara/cucumber.rb +32 -0
  8. data/lib/capybara/driver/base.rb +37 -0
  9. data/lib/capybara/driver/celerity_driver.rb +135 -0
  10. data/lib/capybara/driver/culerity_driver.rb +25 -0
  11. data/lib/capybara/driver/rack_test_driver.rb +244 -0
  12. data/lib/capybara/driver/selenium_driver.rb +137 -0
  13. data/lib/capybara/dsl.rb +60 -0
  14. data/lib/capybara/node.rb +69 -0
  15. data/lib/capybara/rails.rb +11 -0
  16. data/lib/capybara/save_and_open_page.rb +33 -0
  17. data/lib/capybara/searchable.rb +53 -0
  18. data/lib/capybara/server.rb +111 -0
  19. data/lib/capybara/session.rb +274 -0
  20. data/lib/capybara/wait_until.rb +23 -0
  21. data/lib/capybara/xpath.rb +176 -0
  22. data/script/console +10 -0
  23. data/script/destroy +14 -0
  24. data/script/generate +14 -0
  25. data/spec/capybara_spec.rb +18 -0
  26. data/spec/driver/celerity_driver_spec.rb +17 -0
  27. data/spec/driver/culerity_driver_spec.rb +13 -0
  28. data/spec/driver/rack_test_driver_spec.rb +12 -0
  29. data/spec/driver/remote_culerity_driver_spec.rb +26 -0
  30. data/spec/driver/remote_selenium_driver_spec.rb +18 -0
  31. data/spec/driver/selenium_driver_spec.rb +12 -0
  32. data/spec/drivers_spec.rb +139 -0
  33. data/spec/dsl/all_spec.rb +69 -0
  34. data/spec/dsl/attach_file_spec.rb +64 -0
  35. data/spec/dsl/check_spec.rb +39 -0
  36. data/spec/dsl/choose_spec.rb +26 -0
  37. data/spec/dsl/click_button_spec.rb +218 -0
  38. data/spec/dsl/click_link_spec.rb +108 -0
  39. data/spec/dsl/click_spec.rb +24 -0
  40. data/spec/dsl/current_url_spec.rb +8 -0
  41. data/spec/dsl/fill_in_spec.rb +91 -0
  42. data/spec/dsl/find_button_spec.rb +16 -0
  43. data/spec/dsl/find_by_id_spec.rb +16 -0
  44. data/spec/dsl/find_field_spec.rb +22 -0
  45. data/spec/dsl/find_link_spec.rb +17 -0
  46. data/spec/dsl/find_spec.rb +57 -0
  47. data/spec/dsl/has_button_spec.rb +32 -0
  48. data/spec/dsl/has_content_spec.rb +101 -0
  49. data/spec/dsl/has_css_spec.rb +107 -0
  50. data/spec/dsl/has_field_spec.rb +96 -0
  51. data/spec/dsl/has_link_spec.rb +33 -0
  52. data/spec/dsl/has_xpath_spec.rb +123 -0
  53. data/spec/dsl/locate_spec.rb +59 -0
  54. data/spec/dsl/select_spec.rb +71 -0
  55. data/spec/dsl/uncheck_spec.rb +21 -0
  56. data/spec/dsl/within_spec.rb +153 -0
  57. data/spec/dsl_spec.rb +140 -0
  58. data/spec/fixtures/capybara.jpg +0 -0
  59. data/spec/fixtures/test_file.txt +1 -0
  60. data/spec/public/jquery-ui.js +35 -0
  61. data/spec/public/jquery.js +19 -0
  62. data/spec/public/test.js +30 -0
  63. data/spec/save_and_open_page_spec.rb +43 -0
  64. data/spec/searchable_spec.rb +61 -0
  65. data/spec/server_spec.rb +47 -0
  66. data/spec/session/celerity_session_spec.rb +27 -0
  67. data/spec/session/culerity_session_spec.rb +25 -0
  68. data/spec/session/rack_test_session_spec.rb +25 -0
  69. data/spec/session/selenium_session_spec.rb +25 -0
  70. data/spec/session_spec.rb +77 -0
  71. data/spec/session_with_headers_support_spec.rb +13 -0
  72. data/spec/session_with_javascript_support_spec.rb +182 -0
  73. data/spec/session_without_headers_support_spec.rb +15 -0
  74. data/spec/session_without_javascript_support_spec.rb +15 -0
  75. data/spec/spec_helper.rb +27 -0
  76. data/spec/test_app.rb +71 -0
  77. data/spec/views/buttons.erb +4 -0
  78. data/spec/views/fieldsets.erb +29 -0
  79. data/spec/views/form.erb +226 -0
  80. data/spec/views/postback.erb +13 -0
  81. data/spec/views/tables.erb +122 -0
  82. data/spec/views/with_html.erb +38 -0
  83. data/spec/views/with_js.erb +34 -0
  84. data/spec/views/with_scope.erb +36 -0
  85. data/spec/views/with_simple_html.erb +1 -0
  86. data/spec/wait_until_spec.rb +28 -0
  87. data/spec/xpath_spec.rb +271 -0
  88. metadata +239 -0
@@ -0,0 +1,226 @@
1
+ <h1>Form</h1>
2
+
3
+ <form action="/form" method="post">
4
+
5
+ <p>
6
+ <label for="form_title">Title</label>
7
+ <select name="form[title]" id="form_title">
8
+ <option>Mrs</option>
9
+ <option>Mr</option>
10
+ <option>Miss</option>
11
+ </select>
12
+ </p>
13
+
14
+ <p>
15
+ <label for="form_first_name">
16
+ First Name
17
+ <input type="text" name="form[first_name]" value="John" id="form_first_name"/>
18
+ </label>
19
+ </p>
20
+
21
+ <p>
22
+ <label for="form_last_name">Last Name</label>
23
+ <input type="text" name="form[last_name]" value="Smith" id="form_last_name"/>
24
+ </p>
25
+
26
+ <p>
27
+ <label for="form_name_explanation">Explanation of Name</label>
28
+ <textarea name="form[name_explanation]" id="form_name_explanation"></textarea>
29
+ </p>
30
+
31
+ <p>
32
+ <label for="form_name">Name</label>
33
+ <input type="text" name="form[name]" value="John Smith" id="form_name"/>
34
+ </p>
35
+
36
+ <p>
37
+ <label>Street<br/>
38
+ <input type="text" name="form[street]" value="Sesame street 66"/>
39
+ </label>
40
+ </p>
41
+
42
+ <p>
43
+ <label for="form_phone">Phone</label>
44
+ <input type="text" name="form[phone]" value="+1 555 7021" id="form_phone"/>
45
+ </p>
46
+
47
+ <p>
48
+ <label for="form_password">Password</label>
49
+ <input type="password" name="form[password]" value="seeekrit" id="form_password"/>
50
+ </p>
51
+
52
+ <p>
53
+ <label for="form_terms_of_use">Terms of Use</label>
54
+ <input type="hidden" name="form[terms_of_use]" value="0" id="form_terms_of_use_default">
55
+ <input type="checkbox" name="form[terms_of_use]" value="1" id="form_terms_of_use">
56
+ </p>
57
+
58
+ <p>
59
+ <label for="form_image">Image</label>
60
+ <input type="file" name="form[image]" id="form_image"/>
61
+ </p>
62
+
63
+ <p>
64
+ <input type="hidden" name="form[token]" value="12345" id="form_token"/>
65
+ </p>
66
+
67
+ <p>
68
+ <label for="form_locale">Locale</label>
69
+ <select name="form[locale]" id="form_locale">
70
+ <option value="sv">Swedish</option>
71
+ <option selected="selected" value="en">English</option>
72
+ <option value="fi">Finish</option>
73
+ <option value="no">Norwegian</option>
74
+ </select>
75
+ </p>
76
+
77
+ <p>
78
+ <label for="form_region">Region</label>
79
+ <select name="form[region]" id="form_region">
80
+ <option>Sweden</option>
81
+ <option selected="selected">Norway</option>
82
+ <option>Finland</option>
83
+ </select>
84
+ </p>
85
+
86
+ <p>
87
+ <label for="form_city">City</label>
88
+ <select name="form[city]" id="form_city">
89
+ <option>London</option>
90
+ <option>Stockholm</option>
91
+ <option>Paris</option>
92
+ </select>
93
+ </p>
94
+
95
+ <p>
96
+ <label for="form_tendency">Tendency</label>
97
+ <select name="form[tendency]" id="form_tendency"></select>
98
+ </p>
99
+
100
+ <p>
101
+ <label for="form_description">Description</label></br>
102
+ <textarea name="form[description]" id="form_description">Descriptive text goes here</textarea>
103
+ <p>
104
+
105
+ <p>
106
+ <input type="radio" name="form[gender]" value="male" id="gender_male"/>
107
+ <label for="gender_male">Male</label>
108
+ <input type="radio" name="form[gender]" value="female" id="gender_female" checked="checked"/>
109
+ <label for="gender_female">Female</label>
110
+ <input type="radio" name="form[gender]" value="both" id="gender_both"/>
111
+ <label for="gender_both">Both</label>
112
+ </p>
113
+
114
+ <p>
115
+ <input type="checkbox" value="dog" name="form[pets][]" id="form_pets_dog" checked="checked"/>
116
+ <label for="form_pets_dog">Dog</label>
117
+ <input type="checkbox" value="cat" name="form[pets][]" id="form_pets_cat"/>
118
+ <label for="form_pets_cat">Cat</label>
119
+ <input type="checkbox" value="hamster" name="form[pets][]" id="form_pets_hamster" checked="checked"/>
120
+ <label for="form_pets_hamster">Hamster</label>
121
+ </p>
122
+
123
+ <p>
124
+ <label for="form_languages">Languages</label>
125
+ <select name="form[languages][]" id="form_languages" multiple="multiple">
126
+ <option>Ruby</option>
127
+ <option>SQL</option>
128
+ <option>HTML</option>
129
+ <option>Javascript</option>
130
+ </select>
131
+ </p>
132
+
133
+ <p>
134
+ <label for="form_underwear">Underwear</label>
135
+ <select name="form[underwear][]" id="form_underwear" multiple="multiple">
136
+ <option selected="selected">Boxer Briefs</option>
137
+ <option>Boxers</option>
138
+ <option selected="selected">Briefs</option>
139
+ <option selected="selected">Commando</option>
140
+ </select>
141
+ </p>
142
+
143
+ <div style="display:none;">
144
+ <label for="form_first_name_hidden">
145
+ Super Secret
146
+ <input type="text" name="form[super_secret]" value="test123" id="form_super_secret"/>
147
+ </label>
148
+ </div>
149
+
150
+ <p>
151
+ <input type="button" name="form[fresh]" id="fresh_btn" value="i am fresh"/>
152
+ <input type="submit" name="form[awesome]" id="awe123" value="awesome"/>
153
+ <input type="submit" name="form[crappy]" id="crap321" value="crappy"/>
154
+ <input type="image" name="form[okay]" id="okay556" value="okay"/>
155
+ <button type="submit" id="click_me_123" value="click_me">Click me!</button>
156
+ </p>
157
+ </form>
158
+
159
+ <form action="/form/get?foo=bar" method="get">
160
+ <p>
161
+ <label for="form_middle_name">Middle Name</label>
162
+ <input type="text" name="form[middle_name]" value="Darren" id="form_middle_name"/>
163
+ </p>
164
+
165
+ <p>
166
+ <input type="submit" name="form[mediocre]" id="mediocre" value="med"/>
167
+ <p>
168
+ </form>
169
+
170
+ <form action="/upload" method="post" enctype="multipart/form-data">
171
+ <p>
172
+ <label for="form_file_name">File Name</label>
173
+ <input type="file" name="form[file_name]" id="form_file_name"/>
174
+ </p>
175
+
176
+ <p>
177
+ <label for="form_document">Document</label>
178
+ <input type="file" name="form[document]" id="form_document"/>
179
+ </p>
180
+
181
+ <p>
182
+ <input type="submit" value="Upload"/>
183
+ <p>
184
+ </form>
185
+
186
+ <form action="/redirect" method="post">
187
+ <p>
188
+ <input type="submit" value="Go FAR"/>
189
+ </p>
190
+ </form>
191
+
192
+ <form action="/form" method="post">
193
+ <p>
194
+ <label for="html5_email">Html5 Email</label>
195
+ <input type="email" name="form[html5_email]" value="person@email.com" id="html5_email"/>
196
+ </p>
197
+ <p>
198
+ <label for="html5_url">Html5 Url</label>
199
+ <input type="url" name="form[html5_url]" value="http://www.example.com" id="html5_url"/>
200
+ </p>
201
+ <p>
202
+ <label for="html5_search">Html5 Search</label>
203
+ <input type="search" name="form[html5_search]" value="what are you looking for" id="html5_search"/>
204
+ </p>
205
+ <p>
206
+ <label for="html5_tel">Html5 Tel</label>
207
+ <input type="tel" name="form[html5_tel]" value="911" id="html5_tel"/>
208
+ </p>
209
+ <p>
210
+ <label for="html5_color">Html5 Color</label>
211
+ <input type="color" name="form[html5_color]" value="#FFF" id="html5_color"/>
212
+ </p>
213
+
214
+ <p>
215
+ <input type="submit" name="form[html5_submit]" value="html5_submit"/>
216
+ </p>
217
+ </form>
218
+
219
+ <form action="/form" method="post">
220
+ <p>
221
+ <button type="submit" name="form[button]" value="button_first">Just an input that came first</button>
222
+ <button type="submit" name="form[button]" value="button_second">Just an input</button>
223
+ <input type="submit" name="form[button]" value="Just a button that came first"/>
224
+ <input type="submit" name="form[button]" value="Just a button"/>
225
+ </p>
226
+ </form>
@@ -0,0 +1,13 @@
1
+ <h1>Postback</h1>
2
+
3
+ <form method="get">
4
+ <p>
5
+ <input type="submit" value="With no action">
6
+ </p>
7
+ </form>
8
+
9
+ <form action="" method="get">
10
+ <p>
11
+ <input type="submit" value="With blank action">
12
+ </p>
13
+ </form>
@@ -0,0 +1,122 @@
1
+ <form action="/form" method="post">
2
+ <table id="agent_table">
3
+ <caption>Agent</caption>
4
+
5
+ <tr>
6
+ <td>
7
+ <label for="form_agent_name">Name</label>
8
+ </td>
9
+ <td>
10
+ <input type="text" name="form[agent_name]" value="James" id="form_agent_name"/>
11
+ </td>
12
+ </tr>
13
+
14
+ <tr>
15
+ <td colspan="2">
16
+ <input type="submit" value="Create"/>
17
+ </td>
18
+ </tr>
19
+ </table>
20
+ </form>
21
+
22
+ <form action="/form" method="post">
23
+ <table id="girl_table">
24
+ <caption>Girl</caption>
25
+
26
+ <tr>
27
+ <td>
28
+ <label for="form_girl_name">Name</label>
29
+ </td>
30
+ <td>
31
+ <input type="text" name="form[girl_name]" value="Vesper" id="form_girl_name"/>
32
+ </td>
33
+ </tr>
34
+
35
+ <tr>
36
+ <td colspan="2">
37
+ <input type="submit" value="Create"/>
38
+ </td>
39
+ </tr>
40
+ </table>
41
+ </form>
42
+
43
+ <form action="/form" method="post">
44
+ <table id="villain_table">
45
+ <caption>Villain</caption>
46
+
47
+ <tr>
48
+ <td>
49
+ <label for="form_villain_name">Name</label>
50
+ </td>
51
+ <td>
52
+ <input type="text" name="form[villain_name]" value="Ernst" id="form_villain_name"/>
53
+ </td>
54
+ </tr>
55
+
56
+ <tr>
57
+ <td colspan="2">
58
+ <input type="submit" value="Create"/>
59
+ </td>
60
+ </tr>
61
+ </table>
62
+ </form>
63
+
64
+ <table>
65
+ <caption>Ransom</caption>
66
+
67
+ <thead>
68
+ <tr>
69
+ <th>Year</th>
70
+ <th>Governmental</th>
71
+ <th>Private</th>
72
+ </tr>
73
+ </thead>
74
+
75
+ <tbody>
76
+ <tr>
77
+ <th scope="row">2007</th>
78
+ <td>$300</td>
79
+ <td>$100</td>
80
+ </tr>
81
+ <tr>
82
+ <th scope="row">2008</th>
83
+ <td>$123</td>
84
+ <td>$897</td>
85
+ </tr>
86
+ <tr>
87
+ <th scope="row">2009</th>
88
+ <td>$543</td>
89
+ <td>$99</td>
90
+ </tr>
91
+ </tbody>
92
+ </table>
93
+
94
+ <table>
95
+ <caption>Deaths</caption>
96
+
97
+ <thead>
98
+ <tr>
99
+ <th>Year</th>
100
+ <th>Sharks with lasers</th>
101
+ <th>Flaming volcano</th>
102
+ </tr>
103
+ </thead>
104
+
105
+ <tbody>
106
+ <tr>
107
+ <th scope="row">2007</th>
108
+ <td>66</td>
109
+ <td>7</td>
110
+ </tr>
111
+ <tr>
112
+ <th scope="row">2008</th>
113
+ <td>123</td>
114
+ <td>12</td>
115
+ </tr>
116
+ <tr>
117
+ <th scope="row">2009</th>
118
+ <td>913</td>
119
+ <td>13</td>
120
+ </tr>
121
+ </tbody>
122
+ </table>
@@ -0,0 +1,38 @@
1
+ <h1>This is a test</h1>
2
+
3
+ <p id="first">
4
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
5
+ tempor incididunt ut <a href="/with_simple_html" title="awesome title" class="simple">labore</a>
6
+ et dolore magna aliqua. Ut enim ad minim veniam,
7
+ quis nostrud exercitation <a href="/foo" id="foo">ullamco</a> laboris nisi
8
+ ut aliquip ex ea commodo consequat.
9
+ <a href="/with_simple_html"><img src="http://www.foobar.sun/dummy_image.jpg" width="20" height="20" alt="awesome image" /></a>
10
+ </p>
11
+
12
+ <p id="second">
13
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
14
+ dolore eu fugiat <a href="/redirect" id="red">Redirect</a> pariatur. Excepteur sint occaecat cupidatat non proident,
15
+ sunt in culpa qui officia deserunt mollit anim id est laborum.
16
+ </p>
17
+
18
+ <p>
19
+ <input type="text" id="test_field" value="monkey"/>
20
+ <a href="/redirect_back">BackToMyself</a>
21
+ <a title="twas a fine link" href="/redirect">A link came first</a>
22
+ <a title="a fine link" href="/with_simple_html">A link</a>
23
+ <a>No Href</a>
24
+ <a href="">Blank Href</a>
25
+ <a href="#">Blank Anchor</a>
26
+ <a href="#anchor">Anchor</a>
27
+ <a href="/with_simple_html#anchor">Anchor on different page</a>
28
+ <a href="/with_html#anchor">Anchor on same page</a>
29
+ <input type="text" value="" id="test_field">
30
+ <input type="text" checked="checked" id="checked_field">
31
+ <a href="/redirect"><img src="http://www.foobar.sun/dummy_image.jpg" width="20" height="20" alt="very fine image" /></a>
32
+ <a href="/with_simple_html"><img src="http://www.foobar.sun/dummy_image.jpg" width="20" height="20" alt="fine image" /></a>
33
+ </p>
34
+
35
+ <div id="hidden" style="display: none;">
36
+ <div id="hidden_via_ancestor">Inside element with hidden ancestor</div>
37
+ <a href="/with_simple_html" title="awesome title" class="simple">hidden link</a>
38
+ </div>
@@ -0,0 +1,34 @@
1
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
2
+ <head>
3
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
4
+ <title>with_js</title>
5
+ <script src="/jquery.js" type="text/javascript" charset="utf-8"></script>
6
+ <script src="/jquery-ui.js" type="text/javascript" charset="utf-8"></script>
7
+ <script src="/test.js" type="text/javascript" charset="utf-8"></script>
8
+ </head>
9
+
10
+ <body id="with_js">
11
+ <h1>FooBar</h1>
12
+
13
+ <p id="change">This is text</p>
14
+ <div id="drag">
15
+ <p>This is a draggable element.</p>
16
+ </div>
17
+ <div id="drop">
18
+ <p>It should be dropped here.</p>
19
+ </div>
20
+
21
+ <p><a href="#" id="clickable">Click me</a></p>
22
+
23
+ <p>
24
+ <select id="waiter">
25
+ <option>Foo</option>
26
+ <option>My Waiting Option</option>
27
+ </select>
28
+ </p>
29
+
30
+ <p>
31
+ <input type="text" name="with_focus_event" value="" id="with_focus_event"/>
32
+ </p>
33
+ </body>
34
+ </html>
@@ -0,0 +1,36 @@
1
+ <h1>This page is used for testing various scopes</h1>
2
+
3
+ <p id="for_foo">
4
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
5
+ incididunt ut labore et dolore magna aliqua. Ut enim ad minim venia.
6
+ <a href="/redirect">Go</a>
7
+ </p>
8
+
9
+ <div id="for_bar">
10
+ <ul>
11
+ <li>With Simple HTML: <a href="/with_simple_html">Go</a>
12
+ <form action="/redirect" method="post" accept-charset="utf-8">
13
+ <p>
14
+ <label for="simple_first_name">First Name</label>
15
+ <input type="text" name="first_name" value="John" id="simple_first_name"/>
16
+ </p>
17
+ <p><input type="submit" value="Go"/></p>
18
+ </form>
19
+ </li>
20
+ <li>Bar: <a href="/foo">Go</a>
21
+ <form action="/form" method="post" accept-charset="utf-8">
22
+ <p>
23
+ <label for="bar_first_name">First Name</label>
24
+ <input type="text" name="form[first_name]" value="Peter" id="bar_first_name"/>
25
+ </p>
26
+ <p><input type="submit" value="Go"/></p>
27
+ </form>
28
+ </li>
29
+ </ul>
30
+ </div>
31
+
32
+ <div id="another_foo">
33
+ <ul>
34
+ <li>With Simple HTML: <a href="/">Go</a>
35
+ </ul>
36
+ </div>