intentmedia-capybara-webkit 0.7.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/.gitignore +17 -0
  2. data/.rspec +2 -0
  3. data/Appraisals +7 -0
  4. data/CONTRIBUTING.md +38 -0
  5. data/Gemfile +8 -0
  6. data/Gemfile.lock +65 -0
  7. data/LICENSE +19 -0
  8. data/README.md +67 -0
  9. data/Rakefile +78 -0
  10. data/bin/Info.plist +22 -0
  11. data/capybara-webkit.gemspec +24 -0
  12. data/extconf.rb +2 -0
  13. data/gemfiles/1.0.gemfile +7 -0
  14. data/gemfiles/1.0.gemfile.lock +65 -0
  15. data/gemfiles/1.1.gemfile +7 -0
  16. data/gemfiles/1.1.gemfile.lock +65 -0
  17. data/lib/capybara-webkit.rb +1 -0
  18. data/lib/capybara/driver/webkit.rb +113 -0
  19. data/lib/capybara/driver/webkit/browser.rb +216 -0
  20. data/lib/capybara/driver/webkit/node.rb +118 -0
  21. data/lib/capybara/driver/webkit/socket_debugger.rb +43 -0
  22. data/lib/capybara/webkit.rb +11 -0
  23. data/lib/capybara_webkit_builder.rb +40 -0
  24. data/spec/browser_spec.rb +178 -0
  25. data/spec/driver_rendering_spec.rb +80 -0
  26. data/spec/driver_spec.rb +1048 -0
  27. data/spec/integration/driver_spec.rb +20 -0
  28. data/spec/integration/session_spec.rb +137 -0
  29. data/spec/self_signed_ssl_cert.rb +42 -0
  30. data/spec/spec_helper.rb +25 -0
  31. data/src/Body.h +12 -0
  32. data/src/ClearCookies.cpp +18 -0
  33. data/src/ClearCookies.h +11 -0
  34. data/src/Command.cpp +15 -0
  35. data/src/Command.h +29 -0
  36. data/src/CommandFactory.cpp +29 -0
  37. data/src/CommandFactory.h +16 -0
  38. data/src/CommandParser.cpp +68 -0
  39. data/src/CommandParser.h +29 -0
  40. data/src/Connection.cpp +82 -0
  41. data/src/Connection.h +36 -0
  42. data/src/Evaluate.cpp +84 -0
  43. data/src/Evaluate.h +22 -0
  44. data/src/Execute.cpp +16 -0
  45. data/src/Execute.h +12 -0
  46. data/src/Find.cpp +19 -0
  47. data/src/Find.h +13 -0
  48. data/src/FrameFocus.cpp +66 -0
  49. data/src/FrameFocus.h +28 -0
  50. data/src/GetCookies.cpp +22 -0
  51. data/src/GetCookies.h +14 -0
  52. data/src/Header.cpp +18 -0
  53. data/src/Header.h +11 -0
  54. data/src/Headers.cpp +11 -0
  55. data/src/Headers.h +12 -0
  56. data/src/JavascriptInvocation.cpp +14 -0
  57. data/src/JavascriptInvocation.h +19 -0
  58. data/src/NetworkAccessManager.cpp +25 -0
  59. data/src/NetworkAccessManager.h +18 -0
  60. data/src/NetworkCookieJar.cpp +101 -0
  61. data/src/NetworkCookieJar.h +15 -0
  62. data/src/Node.cpp +14 -0
  63. data/src/Node.h +13 -0
  64. data/src/Render.cpp +19 -0
  65. data/src/Render.h +12 -0
  66. data/src/Reset.cpp +20 -0
  67. data/src/Reset.h +12 -0
  68. data/src/Response.cpp +19 -0
  69. data/src/Response.h +13 -0
  70. data/src/Server.cpp +25 -0
  71. data/src/Server.h +21 -0
  72. data/src/SetCookie.cpp +18 -0
  73. data/src/SetCookie.h +11 -0
  74. data/src/SetProxy.cpp +24 -0
  75. data/src/SetProxy.h +11 -0
  76. data/src/Source.cpp +20 -0
  77. data/src/Source.h +19 -0
  78. data/src/Status.cpp +13 -0
  79. data/src/Status.h +12 -0
  80. data/src/UnsupportedContentHandler.cpp +32 -0
  81. data/src/UnsupportedContentHandler.h +18 -0
  82. data/src/Url.cpp +15 -0
  83. data/src/Url.h +12 -0
  84. data/src/Visit.cpp +21 -0
  85. data/src/Visit.h +15 -0
  86. data/src/WebPage.cpp +226 -0
  87. data/src/WebPage.h +54 -0
  88. data/src/body.cpp +11 -0
  89. data/src/capybara.js +205 -0
  90. data/src/find_command.h +24 -0
  91. data/src/main.cpp +34 -0
  92. data/src/webkit_server.pro +71 -0
  93. data/src/webkit_server.qrc +5 -0
  94. data/templates/Command.cpp +10 -0
  95. data/templates/Command.h +12 -0
  96. data/webkit_server.pro +4 -0
  97. metadata +246 -0
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.swp
2
+ bin/webkit_server
3
+ *.swo
4
+ *~
5
+ *.o
6
+ *.moc
7
+ Makefile*
8
+ qrc_*
9
+ *.xcodeproj
10
+ *.app
11
+ moc_*.cpp
12
+ .bundle
13
+ pkg
14
+ src/webkit_server
15
+ .DS_Store
16
+ tmp
17
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Appraisals ADDED
@@ -0,0 +1,7 @@
1
+ appraise "1.0" do
2
+ gem "capybara", "~> 1.0.0"
3
+ end
4
+
5
+ appraise "1.1" do
6
+ gem "capybara", "~> 1.1.0"
7
+ end
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,38 @@
1
+ We love pull requests. Here's a quick guide:
2
+
3
+ 1. Fork the repo.
4
+
5
+ 2. Run the tests. We only take pull requests with passing tests, and it's great
6
+ to know that you have a clean slate: `bundle && rake`
7
+
8
+ 3. Add a test for your change. Only refactoring and documentation changes
9
+ require no new tests. If you are adding functionality or fixing a bug, we need
10
+ a test!
11
+
12
+ 4. Make the test pass.
13
+
14
+ 5. Push to your fork and submit a pull request.
15
+
16
+
17
+ At this point you're waiting on us. We like to at least comment on, if not
18
+ accept, pull requests within three business days (and, typically, one business
19
+ day). We may suggest some changes or improvements or alternatives.
20
+
21
+ Some things that will increase the chance that your pull request is accepted,
22
+ taken straight from the Ruby on Rails guide:
23
+
24
+ * Use Rails idioms and helpers
25
+ * Include tests that fail without your code, and pass with it
26
+ * Update the documentation, the surrounding one, examples elsewhere, guides,
27
+ whatever is affected by your contribution
28
+
29
+ Syntax:
30
+
31
+ * Two spaces, no tabs.
32
+ * No trailing whitespace. Blank lines should not have any space.
33
+ * Prefer &&/|| over and/or.
34
+ * MyClass.my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
35
+ * a = b and not a=b.
36
+ * Follow the conventions you see used in the source already.
37
+
38
+ And in case we didn't emphasize it enough: we love tests!
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+ gemspec
3
+ # gem "appraisal"
4
+ # gem "rspec", '~> 2.6.0', :require => false
5
+ # gem "capybara"
6
+ # gem "sinatra", :require => false
7
+ # gem "mini_magick", :require => false
8
+ # gem 'rake'
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ intentmedia-capybara-webkit (0.7.2.1)
5
+ capybara (>= 1.0.0, < 1.2)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ appraisal (0.3.8)
11
+ bundler
12
+ rake
13
+ capybara (1.1.1)
14
+ mime-types (>= 1.16)
15
+ nokogiri (>= 1.3.3)
16
+ rack (>= 1.0.0)
17
+ rack-test (>= 0.5.4)
18
+ selenium-webdriver (~> 2.0)
19
+ xpath (~> 0.1.4)
20
+ childprocess (0.2.2)
21
+ ffi (~> 1.0.6)
22
+ diff-lcs (1.1.2)
23
+ ffi (1.0.10)
24
+ json_pure (1.6.1)
25
+ mime-types (1.16)
26
+ mini_magick (3.2.1)
27
+ subexec (~> 0.0.4)
28
+ nokogiri (1.5.0-java)
29
+ rack (1.3.2)
30
+ rack-test (0.6.1)
31
+ rack (>= 1.0)
32
+ rake (0.9.2)
33
+ rspec (2.6.0)
34
+ rspec-core (~> 2.6.0)
35
+ rspec-expectations (~> 2.6.0)
36
+ rspec-mocks (~> 2.6.0)
37
+ rspec-core (2.6.4)
38
+ rspec-expectations (2.6.0)
39
+ diff-lcs (~> 1.1.2)
40
+ rspec-mocks (2.6.0)
41
+ rubyzip (0.9.4)
42
+ selenium-webdriver (2.8.0)
43
+ childprocess (>= 0.2.1)
44
+ ffi (>= 1.0.7)
45
+ json_pure
46
+ rubyzip
47
+ sinatra (1.1.2)
48
+ rack (~> 1.1)
49
+ tilt (~> 1.2)
50
+ subexec (0.0.4)
51
+ tilt (1.2.2)
52
+ xpath (0.1.4)
53
+ nokogiri (~> 1.3)
54
+
55
+ PLATFORMS
56
+ java
57
+ ruby
58
+
59
+ DEPENDENCIES
60
+ appraisal
61
+ intentmedia-capybara-webkit!
62
+ mini_magick
63
+ rake
64
+ rspec (~> 2.6.0)
65
+ sinatra
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2011 thoughtbot, inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ capybara-webkit
2
+ ===============
3
+
4
+ A [capybara](https://github.com/jnicklas/capybara) driver that uses [WebKit](http://webkit.org) via [QtWebKit](http://doc.qt.nokia.com/4.7/qtwebkit.html).
5
+
6
+ Qt Dependency
7
+ -------------
8
+
9
+ capybara-webkit depends on a WebKit implementation from Qt, a cross-platform
10
+ development toolkit. You'll need to download the Qt libraries to build and
11
+ install the gem. You can find instructions for downloading and installing QT on
12
+ the [capybara-webkit wiki](https://github.com/thoughtbot/capybara-webkit/wiki/Installing-QT)
13
+
14
+ Reporting Issues
15
+ ----------------
16
+
17
+ Without access to your application code we can't easily debug most crashes or
18
+ generic failures, so we've included a debug version of the driver that prints a
19
+ log of what happened during each test. Before filing a crash bug, please see
20
+ [Reporting Crashes](https://github.com/thoughtbot/capybara-webkit/wiki/Reporting-Crashes).
21
+ You're much more likely to get a fix if you follow those instructions.
22
+
23
+ CI
24
+ --
25
+
26
+ If you're like us, you'll be using capybara-webkit on CI.
27
+
28
+ On Linux platforms, capybara-webkit requires an X server to run, although it doesn't create any visible windows. Xvfb works fine for this. You can setup Xvfb yourself and set a DISPLAY variable, or try out the [headless gem](https://github.com/leonid-shevtsov/headless).
29
+
30
+ Usage
31
+ -----
32
+
33
+ Add the capybara-webkit gem to your Gemfile:
34
+
35
+ gem "capybara-webkit"
36
+
37
+ Set your Capybara Javascript driver to webkit:
38
+
39
+ Capybara.javascript_driver = :webkit
40
+
41
+ Tag scenarios with @javascript to run them using a headless WebKit browser.
42
+
43
+ Contributing
44
+ ------------
45
+
46
+ See the CONTRIBUTING document.
47
+
48
+ About
49
+ -----
50
+
51
+ The capybara WebKit driver was written by Joe Ferris, Tristan Dunn, and Jason Morrison from [thoughtbot, inc](http://thoughtbot.com/community).
52
+
53
+ Code for rendering the current webpage to a PNG is borrowed from Phantom.js' implementation.
54
+
55
+ ![thoughtbot](http://thoughtbot.com/images/tm/logo.png)
56
+
57
+ The names and logos for thoughtbot are trademarks of thoughtbot, inc.
58
+
59
+ Notes
60
+ -----
61
+
62
+ capybara-webkit will listen on port 8200. This may conflict with other services.
63
+
64
+ License
65
+ -------
66
+
67
+ capybara-webkit is Copyright (c) 2011 thoughtbot, inc. It is free software, and may be redistributed under the terms specified in the LICENSE file.
data/Rakefile ADDED
@@ -0,0 +1,78 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rspec/core/rake_task'
4
+ require 'rake/gempackagetask'
5
+ require 'capybara_webkit_builder'
6
+ require 'appraisal'
7
+
8
+ desc "Generate a Makefile using qmake"
9
+ file 'Makefile' do
10
+ CapybaraWebkitBuilder.makefile or exit(1)
11
+ end
12
+
13
+ desc "Regenerate dependencies using qmake"
14
+ task :qmake => 'Makefile' do
15
+ CapybaraWebkitBuilder.qmake or exit(1)
16
+ end
17
+
18
+ desc "Build the webkit server"
19
+ task :build => :qmake do
20
+ CapybaraWebkitBuilder.build or exit(1)
21
+ end
22
+
23
+ file 'bin/webkit_server' => :build
24
+
25
+ RSpec::Core::RakeTask.new do |t|
26
+ t.pattern = "spec/**/*_spec.rb"
27
+ t.rspec_opts = "--format progress"
28
+ end
29
+
30
+ desc "Default: build and run all specs"
31
+ task :default => [:build, :spec]
32
+
33
+ eval("$specification = begin; #{IO.read('capybara-webkit.gemspec')}; end")
34
+ Rake::GemPackageTask.new($specification) do |package|
35
+ package.need_zip = true
36
+ package.need_tar = true
37
+ end
38
+
39
+ gem_file = "pkg/#{$specification.name}-#{$specification.version}.gem"
40
+
41
+ desc "Build and install the latest gem"
42
+ task :install => :gem do
43
+ sh("gem install --local #{gem_file}")
44
+ end
45
+
46
+ desc "Build and release the latest gem"
47
+ task :release => :gem do
48
+ sh("gem push #{gem_file}")
49
+ end
50
+
51
+ desc "Generate a new command called NAME"
52
+ task :generate_command do
53
+ name = ENV['NAME'] or raise "Provide a name with NAME="
54
+
55
+ header = "src/#{name}.h"
56
+ source = "src/#{name}.cpp"
57
+
58
+ %w(h cpp).each do |extension|
59
+ File.open("templates/Command.#{extension}", "r") do |source_file|
60
+ contents = source_file.read
61
+ contents.gsub!("NAME", name)
62
+ File.open("src/#{name}.#{extension}", "w") do |target_file|
63
+ target_file.write(contents)
64
+ end
65
+ end
66
+ end
67
+
68
+ Dir.glob("src/*.pro").each do |project_file_name|
69
+ project = IO.read(project_file_name)
70
+ project.gsub!(/^(HEADERS = .*)/, "\\1 #{name}.h")
71
+ project.gsub!(/^(SOURCES = .*)/, "\\1 #{name}.cpp")
72
+ File.open(project_file_name, "w") { |file| file.write(project) }
73
+ end
74
+
75
+ File.open("src/find_command.h", "a") do |file|
76
+ file.write("CHECK_COMMAND(#{name})")
77
+ end
78
+ end
data/bin/Info.plist ADDED
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
3
+ <plist version="0.9">
4
+ <dict>
5
+ <key>CFBundleIconFile</key>
6
+ <string></string>
7
+ <key>CFBundlePackageType</key>
8
+ <string>APPL</string>
9
+ <key>CFBundleGetInfoString</key>
10
+ <string>Created by Qt/QMake</string>
11
+ <key>CFBundleSignature</key>
12
+ <string>????</string>
13
+ <key>CFBundleExecutable</key>
14
+ <string>webkit_server</string>
15
+ <key>CFBundleIdentifier</key>
16
+ <string>com.yourcompany.webkit_server</string>
17
+ <key>NOTE</key>
18
+ <string>This file was generated by Qt/QMake.</string>
19
+ <key>LSUIElement</key>
20
+ <string>1</string>
21
+ </dict>
22
+ </plist>
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "intentmedia-capybara-webkit"
3
+ s.version = "0.7.2.1"
4
+ s.authors = ["thoughtbot", "Joe Ferris", "Jason Morrison", "Tristan Dunn",
5
+ "Joshua Clayton", "Yuichi Tateno", "Aaron Gibralter",
6
+ "Vasily Reys", "petrushka", "John Bintz", "Chad Pytel",
7
+ "Christopher Meiklejohn", "John Barker", "Jeremy Wells",
8
+ "Chris Griego", "Shigeya Suzuki"]
9
+ s.email = "support@thoughtbot.com"
10
+ s.files = `git ls-files`.split("\n")
11
+ s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
12
+ s.homepage = "http://github.com/thoughtbot/capybara-webkit"
13
+ s.require_path = "lib"
14
+ s.rubygems_version = "1.3.5"
15
+ s.summary = "Headless Webkit driver for Capybara"
16
+ s.add_runtime_dependency "capybara", [">= 1.0.0", "< 1.2"]
17
+ s.add_development_dependency "rspec", "~> 2.6.0"
18
+ s.add_development_dependency "sinatra"
19
+ s.add_development_dependency "mini_magick"
20
+ s.add_development_dependency "rake"
21
+ s.add_development_dependency "appraisal"
22
+ s.extensions = "extconf.rb"
23
+ end
24
+
data/extconf.rb ADDED
@@ -0,0 +1,2 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), "lib", "capybara_webkit_builder")
2
+ CapybaraWebkitBuilder.build_all
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "capybara", "~> 1.0.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: /Users/jferris/Source/capybara-webkit
3
+ specs:
4
+ capybara-webkit (0.6.1)
5
+ capybara (< 1.2, >= 1.0.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ appraisal (0.3.8)
11
+ bundler
12
+ rake
13
+ capybara (1.0.1)
14
+ mime-types (>= 1.16)
15
+ nokogiri (>= 1.3.3)
16
+ rack (>= 1.0.0)
17
+ rack-test (>= 0.5.4)
18
+ selenium-webdriver (~> 2.0)
19
+ xpath (~> 0.1.4)
20
+ childprocess (0.2.2)
21
+ ffi (~> 1.0.6)
22
+ diff-lcs (1.1.3)
23
+ ffi (1.0.9)
24
+ json_pure (1.6.1)
25
+ mime-types (1.16)
26
+ mini_magick (3.3)
27
+ subexec (~> 0.1.0)
28
+ nokogiri (1.5.0)
29
+ rack (1.3.3)
30
+ rack-test (0.6.1)
31
+ rack (>= 1.0)
32
+ rake (0.9.2)
33
+ rspec (2.6.0)
34
+ rspec-core (~> 2.6.0)
35
+ rspec-expectations (~> 2.6.0)
36
+ rspec-mocks (~> 2.6.0)
37
+ rspec-core (2.6.4)
38
+ rspec-expectations (2.6.0)
39
+ diff-lcs (~> 1.1.2)
40
+ rspec-mocks (2.6.0)
41
+ rubyzip (0.9.4)
42
+ selenium-webdriver (2.7.0)
43
+ childprocess (>= 0.2.1)
44
+ ffi (>= 1.0.7)
45
+ json_pure
46
+ rubyzip
47
+ sinatra (1.2.6)
48
+ rack (~> 1.1)
49
+ tilt (< 2.0, >= 1.2.2)
50
+ subexec (0.1.0)
51
+ tilt (1.3.3)
52
+ xpath (0.1.4)
53
+ nokogiri (~> 1.3)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ appraisal
60
+ capybara (~> 1.0.0)
61
+ capybara-webkit!
62
+ mini_magick
63
+ rake
64
+ rspec (~> 2.6.0)
65
+ sinatra