katzil-capybara 0.3.8

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 (93) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +87 -0
  3. data/Manifest +89 -0
  4. data/README.rdoc +7 -0
  5. data/Rakefile +14 -0
  6. data/katzil-capybara.gemspec +32 -0
  7. data/lib/capybara.rb +52 -0
  8. data/lib/capybara/cucumber.rb +32 -0
  9. data/lib/capybara/driver/base.rb +48 -0
  10. data/lib/capybara/driver/celerity_driver.rb +143 -0
  11. data/lib/capybara/driver/culerity_driver.rb +25 -0
  12. data/lib/capybara/driver/rack_test_driver.rb +271 -0
  13. data/lib/capybara/driver/selenium_driver.rb +156 -0
  14. data/lib/capybara/dsl.rb +60 -0
  15. data/lib/capybara/node.rb +60 -0
  16. data/lib/capybara/rails.rb +17 -0
  17. data/lib/capybara/save_and_open_page.rb +33 -0
  18. data/lib/capybara/searchable.rb +54 -0
  19. data/lib/capybara/server.rb +114 -0
  20. data/lib/capybara/server.rb.orig +114 -0
  21. data/lib/capybara/session.rb +262 -0
  22. data/lib/capybara/spec/driver.rb +162 -0
  23. data/lib/capybara/spec/fixtures/capybara.jpg +0 -0
  24. data/lib/capybara/spec/fixtures/test_file.txt +1 -0
  25. data/lib/capybara/spec/public/jquery-ui.js +35 -0
  26. data/lib/capybara/spec/public/jquery.js +19 -0
  27. data/lib/capybara/spec/public/test.js +33 -0
  28. data/lib/capybara/spec/session.rb +81 -0
  29. data/lib/capybara/spec/session/all_spec.rb +69 -0
  30. data/lib/capybara/spec/session/attach_file_spec.rb +64 -0
  31. data/lib/capybara/spec/session/check_spec.rb +67 -0
  32. data/lib/capybara/spec/session/choose_spec.rb +26 -0
  33. data/lib/capybara/spec/session/click_button_spec.rb +236 -0
  34. data/lib/capybara/spec/session/click_link_spec.rb +108 -0
  35. data/lib/capybara/spec/session/click_spec.rb +24 -0
  36. data/lib/capybara/spec/session/current_url_spec.rb +8 -0
  37. data/lib/capybara/spec/session/fill_in_spec.rb +108 -0
  38. data/lib/capybara/spec/session/find_button_spec.rb +16 -0
  39. data/lib/capybara/spec/session/find_by_id_spec.rb +16 -0
  40. data/lib/capybara/spec/session/find_field_spec.rb +22 -0
  41. data/lib/capybara/spec/session/find_link_spec.rb +17 -0
  42. data/lib/capybara/spec/session/find_spec.rb +57 -0
  43. data/lib/capybara/spec/session/has_button_spec.rb +32 -0
  44. data/lib/capybara/spec/session/has_content_spec.rb +106 -0
  45. data/lib/capybara/spec/session/has_css_spec.rb +107 -0
  46. data/lib/capybara/spec/session/has_field_spec.rb +96 -0
  47. data/lib/capybara/spec/session/has_link_spec.rb +33 -0
  48. data/lib/capybara/spec/session/has_select_spec.rb +89 -0
  49. data/lib/capybara/spec/session/has_table_spec.rb +96 -0
  50. data/lib/capybara/spec/session/has_xpath_spec.rb +123 -0
  51. data/lib/capybara/spec/session/headers.rb +19 -0
  52. data/lib/capybara/spec/session/javascript.rb +204 -0
  53. data/lib/capybara/spec/session/locate_spec.rb +59 -0
  54. data/lib/capybara/spec/session/select_spec.rb +77 -0
  55. data/lib/capybara/spec/session/uncheck_spec.rb +21 -0
  56. data/lib/capybara/spec/session/unselect_spec.rb +54 -0
  57. data/lib/capybara/spec/session/within_spec.rb +153 -0
  58. data/lib/capybara/spec/test_app.rb +75 -0
  59. data/lib/capybara/spec/views/buttons.erb +4 -0
  60. data/lib/capybara/spec/views/fieldsets.erb +29 -0
  61. data/lib/capybara/spec/views/form.erb +234 -0
  62. data/lib/capybara/spec/views/frame_one.erb +8 -0
  63. data/lib/capybara/spec/views/frame_two.erb +8 -0
  64. data/lib/capybara/spec/views/postback.erb +13 -0
  65. data/lib/capybara/spec/views/tables.erb +122 -0
  66. data/lib/capybara/spec/views/with_html.erb +42 -0
  67. data/lib/capybara/spec/views/with_js.erb +39 -0
  68. data/lib/capybara/spec/views/with_scope.erb +36 -0
  69. data/lib/capybara/spec/views/with_simple_html.erb +1 -0
  70. data/lib/capybara/spec/views/within_frames.erb +10 -0
  71. data/lib/capybara/version.rb +3 -0
  72. data/lib/capybara/wait_until.rb +28 -0
  73. data/lib/capybara/xpath.rb +179 -0
  74. data/spec/capybara_spec.rb +18 -0
  75. data/spec/driver/celerity_driver_spec.rb +16 -0
  76. data/spec/driver/culerity_driver_spec.rb +12 -0
  77. data/spec/driver/rack_test_driver_spec.rb +11 -0
  78. data/spec/driver/remote_culerity_driver_spec.rb +23 -0
  79. data/spec/driver/remote_selenium_driver_spec.rb +18 -0
  80. data/spec/driver/selenium_driver_spec.rb +11 -0
  81. data/spec/dsl_spec.rb +140 -0
  82. data/spec/save_and_open_page_spec.rb +43 -0
  83. data/spec/searchable_spec.rb +66 -0
  84. data/spec/server_spec.rb +53 -0
  85. data/spec/session/celerity_session_spec.rb +27 -0
  86. data/spec/session/culerity_session_spec.rb +25 -0
  87. data/spec/session/rack_test_session_spec.rb +33 -0
  88. data/spec/session/selenium_session_spec.rb +25 -0
  89. data/spec/spec_helper.rb +19 -0
  90. data/spec/wait_until_spec.rb +28 -0
  91. data/spec/xpath_spec.rb +180 -0
  92. metadata +245 -0
  93. metadata.gz.sig +2 -0
data.tar.gz.sig ADDED
Binary file
data/History.txt ADDED
@@ -0,0 +1,87 @@
1
+ # Version 0.3.8
2
+
3
+ Release date: 2010-05-12
4
+
5
+ ### Added
6
+
7
+ * Within_frame method to execute a block of code within a particular iframe (Selenium only!)
8
+
9
+ ### Fixed
10
+
11
+ * Single quotes are properly escaped with `select` under rack-test and Selenium.
12
+ * The :text option for searches now escapes regexp special characters when a string is given.
13
+ * Selenium now correctly checks already checked checkboxes (same with uncheck)
14
+ * Timing issue which caused Selenium to hang under certain circumstances.
15
+ * Selenium now resolves attributes even if they are given as a Symbol
16
+
17
+ # Version 0.3.7
18
+
19
+ Release date: 2010-04-09
20
+
21
+ This is a drop in compatible maintainance release. It's mostly
22
+ important for driver authors.
23
+
24
+ ### Added
25
+
26
+ * RackTest scans for data-method which rails3 uses to change the request method
27
+
28
+ ### Fixed
29
+
30
+ * Don't hang when starting server on Windoze
31
+
32
+ ### Changed
33
+
34
+ * The driver and session specs are now located inside lib! Driver authors can simply require them.
35
+
36
+ # Version 0.3.6
37
+
38
+ Release date: 2010-03-22
39
+
40
+ This is a maintainance release with minor bug fixes, should be
41
+ drop in compatible.
42
+
43
+ ### Added
44
+
45
+ * It's now possible to load in external drivers
46
+
47
+ ### Fixed
48
+
49
+ * has_content? ignores whitespace
50
+ * Trigger events when choosing radios and checking checkboxes under Selenium
51
+ * Make Capybara.app totally optional when running without server
52
+ * Changed fallback host so it matches the one set up by Rails' integration tests
53
+
54
+ # Version 0.3.5
55
+
56
+ Release date: 2010-02-26
57
+
58
+ This is a mostly backwards compatible release, it does break
59
+ the API in some minor places, which should hopefully not affect
60
+ too many users, please read the release notes carefully!
61
+
62
+ ### Breaking
63
+
64
+ * Relative searching in a node (e.g. find('//p').all('//a')) will now follow XPath standard
65
+ this means that if you want to find descendant nodes only, you'll need to prefix a dot!
66
+ * `visit` now accepts fully qualified URLs for drivers that support it.
67
+ * Capybara will always try to run a rack server, unless you set Capybara.run_sever = false
68
+
69
+ ### Changed
70
+
71
+ * thin is preferred over mongrel and webrick, since it is Ruby 1.9 compatible
72
+ * click_button and click will find <input type="button">, clicking them does nothing in RackTest
73
+
74
+ ### Added
75
+
76
+ * Much improved error messages in a multitude of places
77
+ * More semantic page querying with has_link?, has_button?, etc...
78
+ * Option to ignore hidden elements when querying and interacting with the page
79
+ * Support for multiple selects
80
+
81
+ ### Fixed
82
+
83
+ * find_by_id is no longer broken
84
+ * clicking links where the image's alt attribute contains the text is now possible
85
+ * within_fieldset and within_table work when the default selector is CSS
86
+ * boolean attributes work the same across drivers (return true/false)
87
+
data/Manifest ADDED
@@ -0,0 +1,89 @@
1
+ History.txt
2
+ Manifest
3
+ README.rdoc
4
+ Rakefile
5
+ lib/capybara.rb
6
+ lib/capybara/cucumber.rb
7
+ lib/capybara/driver/base.rb
8
+ lib/capybara/driver/celerity_driver.rb
9
+ lib/capybara/driver/culerity_driver.rb
10
+ lib/capybara/driver/rack_test_driver.rb
11
+ lib/capybara/driver/selenium_driver.rb
12
+ lib/capybara/dsl.rb
13
+ lib/capybara/node.rb
14
+ lib/capybara/rails.rb
15
+ lib/capybara/save_and_open_page.rb
16
+ lib/capybara/searchable.rb
17
+ lib/capybara/server.rb
18
+ lib/capybara/server.rb.orig
19
+ lib/capybara/session.rb
20
+ lib/capybara/spec/driver.rb
21
+ lib/capybara/spec/fixtures/capybara.jpg
22
+ lib/capybara/spec/fixtures/test_file.txt
23
+ lib/capybara/spec/public/jquery-ui.js
24
+ lib/capybara/spec/public/jquery.js
25
+ lib/capybara/spec/public/test.js
26
+ lib/capybara/spec/session.rb
27
+ lib/capybara/spec/session/all_spec.rb
28
+ lib/capybara/spec/session/attach_file_spec.rb
29
+ lib/capybara/spec/session/check_spec.rb
30
+ lib/capybara/spec/session/choose_spec.rb
31
+ lib/capybara/spec/session/click_button_spec.rb
32
+ lib/capybara/spec/session/click_link_spec.rb
33
+ lib/capybara/spec/session/click_spec.rb
34
+ lib/capybara/spec/session/current_url_spec.rb
35
+ lib/capybara/spec/session/fill_in_spec.rb
36
+ lib/capybara/spec/session/find_button_spec.rb
37
+ lib/capybara/spec/session/find_by_id_spec.rb
38
+ lib/capybara/spec/session/find_field_spec.rb
39
+ lib/capybara/spec/session/find_link_spec.rb
40
+ lib/capybara/spec/session/find_spec.rb
41
+ lib/capybara/spec/session/has_button_spec.rb
42
+ lib/capybara/spec/session/has_content_spec.rb
43
+ lib/capybara/spec/session/has_css_spec.rb
44
+ lib/capybara/spec/session/has_field_spec.rb
45
+ lib/capybara/spec/session/has_link_spec.rb
46
+ lib/capybara/spec/session/has_select_spec.rb
47
+ lib/capybara/spec/session/has_table_spec.rb
48
+ lib/capybara/spec/session/has_xpath_spec.rb
49
+ lib/capybara/spec/session/headers.rb
50
+ lib/capybara/spec/session/javascript.rb
51
+ lib/capybara/spec/session/locate_spec.rb
52
+ lib/capybara/spec/session/select_spec.rb
53
+ lib/capybara/spec/session/uncheck_spec.rb
54
+ lib/capybara/spec/session/unselect_spec.rb
55
+ lib/capybara/spec/session/within_spec.rb
56
+ lib/capybara/spec/test_app.rb
57
+ lib/capybara/spec/views/buttons.erb
58
+ lib/capybara/spec/views/fieldsets.erb
59
+ lib/capybara/spec/views/form.erb
60
+ lib/capybara/spec/views/frame_one.erb
61
+ lib/capybara/spec/views/frame_two.erb
62
+ lib/capybara/spec/views/postback.erb
63
+ lib/capybara/spec/views/tables.erb
64
+ lib/capybara/spec/views/with_html.erb
65
+ lib/capybara/spec/views/with_js.erb
66
+ lib/capybara/spec/views/with_scope.erb
67
+ lib/capybara/spec/views/with_simple_html.erb
68
+ lib/capybara/spec/views/within_frames.erb
69
+ lib/capybara/version.rb
70
+ lib/capybara/wait_until.rb
71
+ lib/capybara/xpath.rb
72
+ spec/capybara_spec.rb
73
+ spec/driver/celerity_driver_spec.rb
74
+ spec/driver/culerity_driver_spec.rb
75
+ spec/driver/rack_test_driver_spec.rb
76
+ spec/driver/remote_culerity_driver_spec.rb
77
+ spec/driver/remote_selenium_driver_spec.rb
78
+ spec/driver/selenium_driver_spec.rb
79
+ spec/dsl_spec.rb
80
+ spec/save_and_open_page_spec.rb
81
+ spec/searchable_spec.rb
82
+ spec/server_spec.rb
83
+ spec/session/celerity_session_spec.rb
84
+ spec/session/culerity_session_spec.rb
85
+ spec/session/rack_test_session_spec.rb
86
+ spec/session/selenium_session_spec.rb
87
+ spec/spec_helper.rb
88
+ spec/wait_until_spec.rb
89
+ spec/xpath_spec.rb
data/README.rdoc ADDED
@@ -0,0 +1,7 @@
1
+ = capybara
2
+
3
+ * http://github.com/jnicklas/capybara
4
+
5
+ == Description:
6
+
7
+ This is a test fix for capybara problem with localhost. See http://github.com/jnicklas/capybara
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('katzil-capybara', '0.3.8') do |p|
6
+ p.description = "A fork for capybara project"
7
+ p.summary = "A fix to capybara gem"
8
+ p.url = "http://github.com/ilyakatz/tests"
9
+ p.author = "Ilya Katz"
10
+ p.email = "ilyakatz @nospam@ gmail dot com"
11
+ p.ignore_pattern = ["tmp/*", "script/*"]
12
+ p.development_dependencies = []
13
+ end
14
+
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{katzil-capybara}
5
+ s.version = "0.3.8"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Ilya Katz"]
9
+ s.cert_chain = ["/Users/ilyakatz/.ssh/gem-public_cert.pem"]
10
+ s.date = %q{2010-05-20}
11
+ s.description = %q{A fork for capybara project}
12
+ s.email = %q{ilyakatz @nospam@ gmail dot com}
13
+ s.extra_rdoc_files = ["README.rdoc", "lib/capybara.rb", "lib/capybara/cucumber.rb", "lib/capybara/driver/base.rb", "lib/capybara/driver/celerity_driver.rb", "lib/capybara/driver/culerity_driver.rb", "lib/capybara/driver/rack_test_driver.rb", "lib/capybara/driver/selenium_driver.rb", "lib/capybara/dsl.rb", "lib/capybara/node.rb", "lib/capybara/rails.rb", "lib/capybara/save_and_open_page.rb", "lib/capybara/searchable.rb", "lib/capybara/server.rb", "lib/capybara/server.rb.orig", "lib/capybara/session.rb", "lib/capybara/spec/driver.rb", "lib/capybara/spec/fixtures/capybara.jpg", "lib/capybara/spec/fixtures/test_file.txt", "lib/capybara/spec/public/jquery-ui.js", "lib/capybara/spec/public/jquery.js", "lib/capybara/spec/public/test.js", "lib/capybara/spec/session.rb", "lib/capybara/spec/session/all_spec.rb", "lib/capybara/spec/session/attach_file_spec.rb", "lib/capybara/spec/session/check_spec.rb", "lib/capybara/spec/session/choose_spec.rb", "lib/capybara/spec/session/click_button_spec.rb", "lib/capybara/spec/session/click_link_spec.rb", "lib/capybara/spec/session/click_spec.rb", "lib/capybara/spec/session/current_url_spec.rb", "lib/capybara/spec/session/fill_in_spec.rb", "lib/capybara/spec/session/find_button_spec.rb", "lib/capybara/spec/session/find_by_id_spec.rb", "lib/capybara/spec/session/find_field_spec.rb", "lib/capybara/spec/session/find_link_spec.rb", "lib/capybara/spec/session/find_spec.rb", "lib/capybara/spec/session/has_button_spec.rb", "lib/capybara/spec/session/has_content_spec.rb", "lib/capybara/spec/session/has_css_spec.rb", "lib/capybara/spec/session/has_field_spec.rb", "lib/capybara/spec/session/has_link_spec.rb", "lib/capybara/spec/session/has_select_spec.rb", "lib/capybara/spec/session/has_table_spec.rb", "lib/capybara/spec/session/has_xpath_spec.rb", "lib/capybara/spec/session/headers.rb", "lib/capybara/spec/session/javascript.rb", "lib/capybara/spec/session/locate_spec.rb", "lib/capybara/spec/session/select_spec.rb", "lib/capybara/spec/session/uncheck_spec.rb", "lib/capybara/spec/session/unselect_spec.rb", "lib/capybara/spec/session/within_spec.rb", "lib/capybara/spec/test_app.rb", "lib/capybara/spec/views/buttons.erb", "lib/capybara/spec/views/fieldsets.erb", "lib/capybara/spec/views/form.erb", "lib/capybara/spec/views/frame_one.erb", "lib/capybara/spec/views/frame_two.erb", "lib/capybara/spec/views/postback.erb", "lib/capybara/spec/views/tables.erb", "lib/capybara/spec/views/with_html.erb", "lib/capybara/spec/views/with_js.erb", "lib/capybara/spec/views/with_scope.erb", "lib/capybara/spec/views/with_simple_html.erb", "lib/capybara/spec/views/within_frames.erb", "lib/capybara/version.rb", "lib/capybara/wait_until.rb", "lib/capybara/xpath.rb"]
14
+ s.files = ["History.txt", "Manifest", "README.rdoc", "Rakefile", "lib/capybara.rb", "lib/capybara/cucumber.rb", "lib/capybara/driver/base.rb", "lib/capybara/driver/celerity_driver.rb", "lib/capybara/driver/culerity_driver.rb", "lib/capybara/driver/rack_test_driver.rb", "lib/capybara/driver/selenium_driver.rb", "lib/capybara/dsl.rb", "lib/capybara/node.rb", "lib/capybara/rails.rb", "lib/capybara/save_and_open_page.rb", "lib/capybara/searchable.rb", "lib/capybara/server.rb", "lib/capybara/server.rb.orig", "lib/capybara/session.rb", "lib/capybara/spec/driver.rb", "lib/capybara/spec/fixtures/capybara.jpg", "lib/capybara/spec/fixtures/test_file.txt", "lib/capybara/spec/public/jquery-ui.js", "lib/capybara/spec/public/jquery.js", "lib/capybara/spec/public/test.js", "lib/capybara/spec/session.rb", "lib/capybara/spec/session/all_spec.rb", "lib/capybara/spec/session/attach_file_spec.rb", "lib/capybara/spec/session/check_spec.rb", "lib/capybara/spec/session/choose_spec.rb", "lib/capybara/spec/session/click_button_spec.rb", "lib/capybara/spec/session/click_link_spec.rb", "lib/capybara/spec/session/click_spec.rb", "lib/capybara/spec/session/current_url_spec.rb", "lib/capybara/spec/session/fill_in_spec.rb", "lib/capybara/spec/session/find_button_spec.rb", "lib/capybara/spec/session/find_by_id_spec.rb", "lib/capybara/spec/session/find_field_spec.rb", "lib/capybara/spec/session/find_link_spec.rb", "lib/capybara/spec/session/find_spec.rb", "lib/capybara/spec/session/has_button_spec.rb", "lib/capybara/spec/session/has_content_spec.rb", "lib/capybara/spec/session/has_css_spec.rb", "lib/capybara/spec/session/has_field_spec.rb", "lib/capybara/spec/session/has_link_spec.rb", "lib/capybara/spec/session/has_select_spec.rb", "lib/capybara/spec/session/has_table_spec.rb", "lib/capybara/spec/session/has_xpath_spec.rb", "lib/capybara/spec/session/headers.rb", "lib/capybara/spec/session/javascript.rb", "lib/capybara/spec/session/locate_spec.rb", "lib/capybara/spec/session/select_spec.rb", "lib/capybara/spec/session/uncheck_spec.rb", "lib/capybara/spec/session/unselect_spec.rb", "lib/capybara/spec/session/within_spec.rb", "lib/capybara/spec/test_app.rb", "lib/capybara/spec/views/buttons.erb", "lib/capybara/spec/views/fieldsets.erb", "lib/capybara/spec/views/form.erb", "lib/capybara/spec/views/frame_one.erb", "lib/capybara/spec/views/frame_two.erb", "lib/capybara/spec/views/postback.erb", "lib/capybara/spec/views/tables.erb", "lib/capybara/spec/views/with_html.erb", "lib/capybara/spec/views/with_js.erb", "lib/capybara/spec/views/with_scope.erb", "lib/capybara/spec/views/with_simple_html.erb", "lib/capybara/spec/views/within_frames.erb", "lib/capybara/version.rb", "lib/capybara/wait_until.rb", "lib/capybara/xpath.rb", "spec/capybara_spec.rb", "spec/driver/celerity_driver_spec.rb", "spec/driver/culerity_driver_spec.rb", "spec/driver/rack_test_driver_spec.rb", "spec/driver/remote_culerity_driver_spec.rb", "spec/driver/remote_selenium_driver_spec.rb", "spec/driver/selenium_driver_spec.rb", "spec/dsl_spec.rb", "spec/save_and_open_page_spec.rb", "spec/searchable_spec.rb", "spec/server_spec.rb", "spec/session/celerity_session_spec.rb", "spec/session/culerity_session_spec.rb", "spec/session/rack_test_session_spec.rb", "spec/session/selenium_session_spec.rb", "spec/spec_helper.rb", "spec/wait_until_spec.rb", "spec/xpath_spec.rb", "katzil-capybara.gemspec"]
15
+ s.homepage = %q{http://github.com/ilyakatz/tests}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Katzil-capybara", "--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{katzil-capybara}
19
+ s.rubygems_version = %q{1.3.6}
20
+ s.signing_key = %q{/Users/ilyakatz/.ssh/gem-private_key.pem}
21
+ s.summary = %q{A fix to capybara gem}
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 3
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ else
29
+ end
30
+ else
31
+ end
32
+ end
data/lib/capybara.rb ADDED
@@ -0,0 +1,52 @@
1
+ require 'timeout'
2
+ require 'nokogiri'
3
+
4
+ module Capybara
5
+ class CapybaraError < StandardError; end
6
+ class DriverNotFoundError < CapybaraError; end
7
+ class ElementNotFound < CapybaraError; end
8
+ class OptionNotFound < ElementNotFound; end
9
+ class UnselectNotAllowed < CapybaraError; end
10
+ class NotSupportedByDriverError < CapybaraError; end
11
+ class TimeoutError < CapybaraError; end
12
+ class LocateHiddenElementError < CapybaraError; end
13
+ class InfiniteRedirectError < TimeoutError; end
14
+
15
+ class << self
16
+ attr_accessor :debug, :asset_root, :app_host, :run_server, :default_host
17
+ attr_accessor :default_selector, :default_wait_time, :ignore_hidden_elements
18
+
19
+ def default_selector
20
+ @default_selector ||= :xpath
21
+ end
22
+
23
+ def default_wait_time
24
+ @default_wait_time ||= 2
25
+ end
26
+
27
+ def log(message)
28
+ puts "[capybara] #{message}" if debug
29
+ true
30
+ end
31
+ end
32
+
33
+ autoload :Server, 'capybara/server'
34
+ autoload :Session, 'capybara/session'
35
+ autoload :Node, 'capybara/node'
36
+ autoload :XPath, 'capybara/xpath'
37
+ autoload :Searchable, 'capybara/searchable'
38
+ autoload :VERSION, 'capybara/version'
39
+
40
+ module Driver
41
+ autoload :Base, 'capybara/driver/base'
42
+ autoload :RackTest, 'capybara/driver/rack_test_driver'
43
+ autoload :Celerity, 'capybara/driver/celerity_driver'
44
+ autoload :Culerity, 'capybara/driver/culerity_driver'
45
+ autoload :Selenium, 'capybara/driver/selenium_driver'
46
+ end
47
+ end
48
+
49
+ Capybara.run_server = true
50
+ Capybara.default_selector = :xpath
51
+ Capybara.default_wait_time = 2
52
+ Capybara.ignore_hidden_elements = false
@@ -0,0 +1,32 @@
1
+ require 'capybara'
2
+ require 'capybara/dsl'
3
+
4
+ World(Capybara)
5
+
6
+ After do
7
+ Capybara.reset_sessions!
8
+ end
9
+
10
+ Before('@javascript') do
11
+ Capybara.current_driver = Capybara.javascript_driver
12
+ end
13
+
14
+ Before('@selenium') do
15
+ Capybara.current_driver = :selenium
16
+ end
17
+
18
+ Before('@celerity') do
19
+ Capybara.current_driver = :celerity
20
+ end
21
+
22
+ Before('@culerity') do
23
+ Capybara.current_driver = :culerity
24
+ end
25
+
26
+ Before('@rack_test') do
27
+ Capybara.current_driver = :rack_test
28
+ end
29
+
30
+ After do
31
+ Capybara.use_default_driver
32
+ end
@@ -0,0 +1,48 @@
1
+ class Capybara::Driver::Base
2
+ def current_url
3
+ raise NotImplementedError
4
+ end
5
+
6
+ def visit(path)
7
+ raise NotImplementedError
8
+ end
9
+
10
+ def find(query)
11
+ raise NotImplementedError
12
+ end
13
+
14
+ def evaluate_script(script)
15
+ raise Capybara::NotSupportedByDriverError
16
+ end
17
+
18
+ def wait?
19
+ false
20
+ end
21
+
22
+ def wait_until *args
23
+ end
24
+
25
+ def response_headers
26
+ raise Capybara::NotSupportedByDriverError
27
+ end
28
+
29
+ def body
30
+ raise NotImplementedError
31
+ end
32
+
33
+ def within_frame(frame_id)
34
+ raise Capybara::NotSupportedByDriverError
35
+ end
36
+
37
+ def source
38
+ raise NotImplementedError
39
+ end
40
+
41
+ def cleanup!
42
+ end
43
+
44
+ def has_shortcircuit_timeout?
45
+ false
46
+ end
47
+
48
+ end
@@ -0,0 +1,143 @@
1
+ class Capybara::Driver::Celerity < Capybara::Driver::Base
2
+ class Node < Capybara::Node
3
+ def text
4
+ node.text
5
+ end
6
+
7
+ def [](name)
8
+ value = if name.to_sym == :class
9
+ node.class_name
10
+ else
11
+ node.send(name.to_sym)
12
+ end
13
+ return value if value and not value.to_s.empty?
14
+ end
15
+
16
+ def value
17
+ if tag_name == "select" and node.multiple?
18
+ node.selected_options
19
+ else
20
+ super
21
+ end
22
+ end
23
+
24
+ def set(value)
25
+ node.set(value)
26
+ end
27
+
28
+ def select(option)
29
+ node.select(option)
30
+ rescue
31
+ options = all(:xpath, "//option").map { |o| "'#{o.text}'" }.join(', ')
32
+ raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: #{options}"
33
+ end
34
+
35
+ def unselect(option)
36
+ unless node.multiple?
37
+ raise Capybara::UnselectNotAllowed, "Cannot unselect option '#{option}' from single select box."
38
+ end
39
+
40
+ # FIXME: couldn't find a clean way to unselect, so clear and reselect
41
+ selected_options = node.selected_options
42
+ if unselect_option = selected_options.detect { |value| value == option } ||
43
+ selected_options.detect { |value| value.index(option) }
44
+ node.clear
45
+ (selected_options - [unselect_option]).each { |value| node.select_value(value) }
46
+ else
47
+ options = all(:xpath, "//option").map { |o| "'#{o.text}'" }.join(', ')
48
+ raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: #{options}"
49
+ end
50
+ end
51
+
52
+ def click
53
+ node.click
54
+ end
55
+
56
+ def drag_to(element)
57
+ node.fire_event('mousedown')
58
+ element.node.fire_event('mousemove')
59
+ element.node.fire_event('mouseup')
60
+ end
61
+
62
+ def tag_name
63
+ # FIXME: this might be the dumbest way ever of getting the tag name
64
+ # there has to be something better...
65
+ node.to_xml[/^\s*<([a-z0-9\-\:]+)/, 1]
66
+ end
67
+
68
+ def visible?
69
+ node.visible?
70
+ end
71
+
72
+ def path
73
+ node.xpath
74
+ end
75
+
76
+ def trigger(event)
77
+ node.fire_event(event.to_s)
78
+ end
79
+
80
+ private
81
+
82
+ def all_unfiltered(locator)
83
+ noko_node = Nokogiri::HTML(driver.body).xpath(node.xpath).first
84
+ all_nodes = noko_node.xpath(locator).map { |n| n.path }.join(' | ')
85
+ driver.find(all_nodes)
86
+ end
87
+
88
+ end
89
+
90
+ attr_reader :app, :rack_server
91
+
92
+ def initialize(app)
93
+ @app = app
94
+ @rack_server = Capybara::Server.new(@app)
95
+ @rack_server.boot if Capybara.run_server
96
+ end
97
+
98
+ def visit(path)
99
+ browser.goto(url(path))
100
+ end
101
+
102
+ def current_url
103
+ browser.url
104
+ end
105
+
106
+ def source
107
+ browser.html
108
+ end
109
+
110
+ def body
111
+ browser.document.as_xml
112
+ end
113
+
114
+ def response_headers
115
+ browser.response_headers
116
+ end
117
+
118
+ def find(selector)
119
+ browser.elements_by_xpath(selector).map { |node| Node.new(self, node) }
120
+ end
121
+
122
+ def wait?; true; end
123
+
124
+ def evaluate_script(script)
125
+ browser.execute_script "#{script}"
126
+ end
127
+
128
+ def browser
129
+ unless @_browser
130
+ require 'celerity'
131
+ @_browser = ::Celerity::Browser.new(:browser => :firefox, :log_level => :off)
132
+ end
133
+
134
+ @_browser
135
+ end
136
+
137
+ private
138
+
139
+ def url(path)
140
+ rack_server.url(path)
141
+ end
142
+
143
+ end