pr0d1r2-capybara 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. data/History.txt +71 -0
  2. data/README.rdoc +388 -0
  3. data/lib/capybara.rb +57 -0
  4. data/lib/capybara/cucumber.rb +32 -0
  5. data/lib/capybara/driver/base.rb +48 -0
  6. data/lib/capybara/driver/celerity_driver.rb +143 -0
  7. data/lib/capybara/driver/culerity_driver.rb +25 -0
  8. data/lib/capybara/driver/rack_test_driver.rb +271 -0
  9. data/lib/capybara/driver/selenium_driver.rb +161 -0
  10. data/lib/capybara/dsl.rb +60 -0
  11. data/lib/capybara/node.rb +60 -0
  12. data/lib/capybara/rails.rb +17 -0
  13. data/lib/capybara/save_and_open_page.rb +33 -0
  14. data/lib/capybara/searchable.rb +54 -0
  15. data/lib/capybara/server.rb +114 -0
  16. data/lib/capybara/session.rb +262 -0
  17. data/lib/capybara/spec/driver.rb +162 -0
  18. data/lib/capybara/spec/fixtures/capybara.jpg +0 -0
  19. data/lib/capybara/spec/fixtures/test_file.txt +1 -0
  20. data/lib/capybara/spec/public/jquery-ui.js +35 -0
  21. data/lib/capybara/spec/public/jquery.js +19 -0
  22. data/lib/capybara/spec/public/test.js +33 -0
  23. data/lib/capybara/spec/session.rb +81 -0
  24. data/lib/capybara/spec/session/all_spec.rb +69 -0
  25. data/lib/capybara/spec/session/attach_file_spec.rb +64 -0
  26. data/lib/capybara/spec/session/check_spec.rb +67 -0
  27. data/lib/capybara/spec/session/choose_spec.rb +26 -0
  28. data/lib/capybara/spec/session/click_button_spec.rb +236 -0
  29. data/lib/capybara/spec/session/click_link_spec.rb +108 -0
  30. data/lib/capybara/spec/session/click_spec.rb +24 -0
  31. data/lib/capybara/spec/session/current_url_spec.rb +8 -0
  32. data/lib/capybara/spec/session/fill_in_spec.rb +108 -0
  33. data/lib/capybara/spec/session/find_button_spec.rb +16 -0
  34. data/lib/capybara/spec/session/find_by_id_spec.rb +16 -0
  35. data/lib/capybara/spec/session/find_field_spec.rb +22 -0
  36. data/lib/capybara/spec/session/find_link_spec.rb +17 -0
  37. data/lib/capybara/spec/session/find_spec.rb +57 -0
  38. data/lib/capybara/spec/session/has_button_spec.rb +32 -0
  39. data/lib/capybara/spec/session/has_content_spec.rb +106 -0
  40. data/lib/capybara/spec/session/has_css_spec.rb +107 -0
  41. data/lib/capybara/spec/session/has_field_spec.rb +96 -0
  42. data/lib/capybara/spec/session/has_link_spec.rb +33 -0
  43. data/lib/capybara/spec/session/has_select_spec.rb +89 -0
  44. data/lib/capybara/spec/session/has_table_spec.rb +96 -0
  45. data/lib/capybara/spec/session/has_xpath_spec.rb +123 -0
  46. data/lib/capybara/spec/session/headers.rb +19 -0
  47. data/lib/capybara/spec/session/javascript.rb +204 -0
  48. data/lib/capybara/spec/session/locate_spec.rb +59 -0
  49. data/lib/capybara/spec/session/select_spec.rb +77 -0
  50. data/lib/capybara/spec/session/uncheck_spec.rb +21 -0
  51. data/lib/capybara/spec/session/unselect_spec.rb +54 -0
  52. data/lib/capybara/spec/session/within_spec.rb +153 -0
  53. data/lib/capybara/spec/test_app.rb +75 -0
  54. data/lib/capybara/spec/views/buttons.erb +4 -0
  55. data/lib/capybara/spec/views/fieldsets.erb +29 -0
  56. data/lib/capybara/spec/views/form.erb +234 -0
  57. data/lib/capybara/spec/views/frame_one.erb +8 -0
  58. data/lib/capybara/spec/views/frame_two.erb +8 -0
  59. data/lib/capybara/spec/views/postback.erb +13 -0
  60. data/lib/capybara/spec/views/tables.erb +122 -0
  61. data/lib/capybara/spec/views/with_html.erb +42 -0
  62. data/lib/capybara/spec/views/with_js.erb +39 -0
  63. data/lib/capybara/spec/views/with_scope.erb +36 -0
  64. data/lib/capybara/spec/views/with_simple_html.erb +1 -0
  65. data/lib/capybara/spec/views/within_frames.erb +10 -0
  66. data/lib/capybara/version.rb +3 -0
  67. data/lib/capybara/wait_until.rb +28 -0
  68. data/lib/capybara/xpath.rb +179 -0
  69. data/spec/capybara_spec.rb +18 -0
  70. data/spec/driver/celerity_driver_spec.rb +16 -0
  71. data/spec/driver/culerity_driver_spec.rb +12 -0
  72. data/spec/driver/rack_test_driver_spec.rb +11 -0
  73. data/spec/driver/remote_culerity_driver_spec.rb +23 -0
  74. data/spec/driver/remote_selenium_driver_spec.rb +18 -0
  75. data/spec/driver/selenium_driver_spec.rb +11 -0
  76. data/spec/dsl_spec.rb +140 -0
  77. data/spec/save_and_open_page_spec.rb +43 -0
  78. data/spec/searchable_spec.rb +66 -0
  79. data/spec/server_spec.rb +53 -0
  80. data/spec/session/celerity_session_spec.rb +27 -0
  81. data/spec/session/culerity_session_spec.rb +25 -0
  82. data/spec/session/rack_test_session_spec.rb +33 -0
  83. data/spec/session/selenium_session_spec.rb +25 -0
  84. data/spec/spec_helper.rb +19 -0
  85. data/spec/wait_until_spec.rb +28 -0
  86. data/spec/xpath_spec.rb +180 -0
  87. metadata +259 -0
@@ -0,0 +1,75 @@
1
+ require 'sinatra/base'
2
+ require 'rack'
3
+ require 'yaml'
4
+
5
+ class TestApp < Sinatra::Base
6
+ set :root, File.dirname(__FILE__)
7
+ set :static, true
8
+
9
+ get '/' do
10
+ 'Hello world!'
11
+ end
12
+
13
+ get '/foo' do
14
+ 'Another World'
15
+ end
16
+
17
+ get '/redirect' do
18
+ redirect '/redirect_again'
19
+ end
20
+
21
+ get '/redirect_again' do
22
+ redirect '/landed'
23
+ end
24
+
25
+ get '/landed' do
26
+ "You landed"
27
+ end
28
+
29
+ get '/with-quotes' do
30
+ %q{"No," he said, "you can't do that."}
31
+ end
32
+
33
+ get '/form/get' do
34
+ '<pre id="results">' + params[:form].to_yaml + '</pre>'
35
+ end
36
+
37
+ get '/favicon.ico' do
38
+ nil
39
+ end
40
+
41
+ post '/redirect' do
42
+ redirect '/redirect_again'
43
+ end
44
+
45
+ delete "/delete" do
46
+ "The requested object was deleted"
47
+ end
48
+
49
+ get '/redirect_back' do
50
+ redirect back
51
+ end
52
+
53
+ get '/:view' do |view|
54
+ erb view.to_sym
55
+ end
56
+
57
+ post '/form' do
58
+ '<pre id="results">' + params[:form].to_yaml + '</pre>'
59
+ end
60
+
61
+ post '/upload' do
62
+ begin
63
+ buffer = []
64
+ buffer << "Content-type: #{params[:form][:document][:type]}"
65
+ buffer << "File content: #{params[:form][:document][:tempfile].read}"
66
+ buffer.join(' | ')
67
+ rescue
68
+ 'No file uploaded'
69
+ end
70
+ end
71
+ end
72
+
73
+ if __FILE__ == $0
74
+ Rack::Handler::Mongrel.run TestApp, :Port => 8070
75
+ end
@@ -0,0 +1,4 @@
1
+ <h1>Buttons</h1>
2
+ <button>Click me!</button>
3
+ <button id="click_me_123">Click me by id!</button>
4
+ <button value="click_me">Click me by value!</button>
@@ -0,0 +1,29 @@
1
+ <form action="/form" method="post">
2
+ <fieldset id="agent_fieldset">
3
+ <legend>Agent</legend>
4
+
5
+ <p>
6
+ <label for="form_agent_name">Name</label>
7
+ <input type="text" name="form[agent_name]" value="James" id="form_agent_name"/>
8
+ </p>
9
+
10
+ <p>
11
+ <input type="submit" value="Create"/>
12
+ </p>
13
+ </fieldset>
14
+ </form>
15
+
16
+ <form action="/form" method="post">
17
+ <fieldset id="villain_fieldset">
18
+ <legend>Villain</legend>
19
+
20
+ <p>
21
+ <label for="form_villain_name">Name</label>
22
+ <input type="text" name="form[villain_name]" value="Ernst" id="form_villain_name"/>
23
+ </p>
24
+
25
+ <p>
26
+ <input type="submit" value="Create"/>
27
+ </p>
28
+ </fieldset>
29
+ </form>
@@ -0,0 +1,234 @@
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 for="form_schmooo">Schmooo</label>
38
+ <input type="schmooo" name="form[schmooo]" value="This is Schmooo!" id="form_schmooo"/>
39
+ </p>
40
+
41
+ <p>
42
+ <label>Street<br/>
43
+ <input type="text" name="form[street]" value="Sesame street 66"/>
44
+ </label>
45
+ </p>
46
+
47
+ <p>
48
+ <label for="form_phone">Phone</label>
49
+ <input type="text" name="form[phone]" value="+1 555 7021" id="form_phone"/>
50
+ </p>
51
+
52
+ <p>
53
+ <label for="form_password">Password</label>
54
+ <input type="password" name="form[password]" value="seeekrit" id="form_password"/>
55
+ </p>
56
+
57
+ <p>
58
+ <label for="form_terms_of_use">Terms of Use</label>
59
+ <input type="hidden" name="form[terms_of_use]" value="0" id="form_terms_of_use_default">
60
+ <input type="checkbox" name="form[terms_of_use]" value="1" id="form_terms_of_use">
61
+ </p>
62
+
63
+ <p>
64
+ <label for="form_image">Image</label>
65
+ <input type="file" name="form[image]" id="form_image"/>
66
+ </p>
67
+
68
+ <p>
69
+ <input type="hidden" name="form[token]" value="12345" id="form_token"/>
70
+ </p>
71
+
72
+ <p>
73
+ <label for="form_locale">Locale</label>
74
+ <select name="form[locale]" id="form_locale">
75
+ <option value="sv">Swedish</option>
76
+ <option selected="selected" value="en">English</option>
77
+ <option value="fi">Finish</option>
78
+ <option value="no">Norwegian</option>
79
+ <option value="jo">John's made-up language</option>
80
+ </select>
81
+ </p>
82
+
83
+ <p>
84
+ <label for="form_region">Region</label>
85
+ <select name="form[region]" id="form_region">
86
+ <option>Sweden</option>
87
+ <option selected="selected">Norway</option>
88
+ <option>Finland</option>
89
+ </select>
90
+ </p>
91
+
92
+ <p>
93
+ <label for="form_city">City</label>
94
+ <select name="form[city]" id="form_city">
95
+ <option>London</option>
96
+ <option>Stockholm</option>
97
+ <option>Paris</option>
98
+ </select>
99
+ </p>
100
+
101
+ <p>
102
+ <label for="form_tendency">Tendency</label>
103
+ <select name="form[tendency]" id="form_tendency"></select>
104
+ </p>
105
+
106
+ <p>
107
+ <label for="form_description">Description</label></br>
108
+ <textarea name="form[description]" id="form_description">Descriptive text goes here</textarea>
109
+ <p>
110
+
111
+ <p>
112
+ <input type="radio" name="form[gender]" value="male" id="gender_male"/>
113
+ <label for="gender_male">Male</label>
114
+ <input type="radio" name="form[gender]" value="female" id="gender_female" checked="checked"/>
115
+ <label for="gender_female">Female</label>
116
+ <input type="radio" name="form[gender]" value="both" id="gender_both"/>
117
+ <label for="gender_both">Both</label>
118
+ </p>
119
+
120
+ <p>
121
+ <input type="checkbox" value="dog" name="form[pets][]" id="form_pets_dog" checked="checked"/>
122
+ <label for="form_pets_dog">Dog</label>
123
+ <input type="checkbox" value="cat" name="form[pets][]" id="form_pets_cat"/>
124
+ <label for="form_pets_cat">Cat</label>
125
+ <input type="checkbox" value="hamster" name="form[pets][]" id="form_pets_hamster" checked="checked"/>
126
+ <label for="form_pets_hamster">Hamster</label>
127
+ </p>
128
+
129
+ <p>
130
+ <label for="form_languages">Languages</label>
131
+ <select name="form[languages][]" id="form_languages" multiple="multiple">
132
+ <option>Ruby</option>
133
+ <option>SQL</option>
134
+ <option>HTML</option>
135
+ <option>Javascript</option>
136
+ </select>
137
+ </p>
138
+
139
+ <p>
140
+ <label for="form_underwear">Underwear</label>
141
+ <select name="form[underwear][]" id="form_underwear" multiple="multiple">
142
+ <option selected="selected">Boxer Briefs</option>
143
+ <option>Boxers</option>
144
+ <option selected="selected">Briefs</option>
145
+ <option selected="selected">Commando</option>
146
+ <option selected="selected">Frenchman's Pantalons</option>
147
+ </select>
148
+ </p>
149
+
150
+ <div style="display:none;">
151
+ <label for="form_first_name_hidden">
152
+ Super Secret
153
+ <input type="text" name="form[super_secret]" value="test123" id="form_super_secret"/>
154
+ </label>
155
+ </div>
156
+
157
+ <p>
158
+ <input type="button" name="form[fresh]" id="fresh_btn" value="i am fresh"/>
159
+ <input type="submit" name="form[awesome]" id="awe123" value="awesome"/>
160
+ <input type="submit" name="form[crappy]" id="crap321" value="crappy"/>
161
+ <input type="image" name="form[okay]" id="okay556" value="okay" alt="oh hai thar"/>
162
+ <button type="submit" id="click_me_123" value="click_me">Click me!</button>
163
+ <button type="submit" name="form[no_value]">No Value!</button>
164
+ </p>
165
+ </form>
166
+
167
+ <form action="/form/get?foo=bar" method="get">
168
+ <p>
169
+ <label for="form_middle_name">Middle Name</label>
170
+ <input type="text" name="form[middle_name]" value="Darren" id="form_middle_name"/>
171
+ </p>
172
+
173
+ <p>
174
+ <input type="submit" name="form[mediocre]" id="mediocre" value="med"/>
175
+ <p>
176
+ </form>
177
+
178
+ <form action="/upload" method="post" enctype="multipart/form-data">
179
+ <p>
180
+ <label for="form_file_name">File Name</label>
181
+ <input type="file" name="form[file_name]" id="form_file_name"/>
182
+ </p>
183
+
184
+ <p>
185
+ <label for="form_document">Document</label>
186
+ <input type="file" name="form[document]" id="form_document"/>
187
+ </p>
188
+
189
+ <p>
190
+ <input type="submit" value="Upload"/>
191
+ <p>
192
+ </form>
193
+
194
+ <form action="/redirect" method="post">
195
+ <p>
196
+ <input type="submit" value="Go FAR"/>
197
+ </p>
198
+ </form>
199
+
200
+ <form action="/form" method="post">
201
+ <p>
202
+ <label for="html5_email">Html5 Email</label>
203
+ <input type="email" name="form[html5_email]" value="person@email.com" id="html5_email"/>
204
+ </p>
205
+ <p>
206
+ <label for="html5_url">Html5 Url</label>
207
+ <input type="url" name="form[html5_url]" value="http://www.example.com" id="html5_url"/>
208
+ </p>
209
+ <p>
210
+ <label for="html5_search">Html5 Search</label>
211
+ <input type="search" name="form[html5_search]" value="what are you looking for" id="html5_search"/>
212
+ </p>
213
+ <p>
214
+ <label for="html5_tel">Html5 Tel</label>
215
+ <input type="tel" name="form[html5_tel]" value="911" id="html5_tel"/>
216
+ </p>
217
+ <p>
218
+ <label for="html5_color">Html5 Color</label>
219
+ <input type="color" name="form[html5_color]" value="#FFF" id="html5_color"/>
220
+ </p>
221
+
222
+ <p>
223
+ <input type="submit" name="form[html5_submit]" value="html5_submit"/>
224
+ </p>
225
+ </form>
226
+
227
+ <form action="/form" method="post">
228
+ <p>
229
+ <button type="submit" name="form[button]" value="button_first">Just an input that came first</button>
230
+ <button type="submit" name="form[button]" value="button_second">Just an input</button>
231
+ <input type="submit" name="form[button]" value="Just a button that came first"/>
232
+ <input type="submit" name="form[button]" value="Just a button"/>
233
+ </p>
234
+ </form>
@@ -0,0 +1,8 @@
1
+ <html>
2
+ <head>
3
+ <title>This is the title of frame one</title>
4
+ </head>
5
+ <body>
6
+ <div id="divInFrameOne">This is the text of divInFrameOne</div>
7
+ </body>
8
+ </html>
@@ -0,0 +1,8 @@
1
+ <html>
2
+ <head>
3
+ <title>This is the title of frame two</title>
4
+ </head>
5
+ <body>
6
+ <div id="divInFrameTwo">This is the text of divInFrameTwo</div>
7
+ </body>
8
+ </html>
@@ -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>