capybara-webkit 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.travis.yml +2 -3
  4. data/Gemfile.lock +25 -27
  5. data/NEWS.md +12 -0
  6. data/README.md +1 -1
  7. data/Rakefile +9 -5
  8. data/capybara-webkit.gemspec +2 -1
  9. data/gemfiles/2.0.gemfile.lock +7 -7
  10. data/gemfiles/2.1.gemfile.lock +5 -5
  11. data/lib/capybara/webkit/connection.rb +1 -0
  12. data/lib/capybara/webkit/cookie_jar.rb +1 -1
  13. data/lib/capybara/webkit/node.rb +1 -5
  14. data/lib/capybara/webkit/version.rb +1 -1
  15. data/lib/capybara_webkit_builder.rb +2 -2
  16. data/spec/browser_spec.rb +18 -18
  17. data/spec/connection_spec.rb +4 -4
  18. data/spec/cookie_jar_spec.rb +9 -9
  19. data/spec/driver_rendering_spec.rb +9 -9
  20. data/spec/driver_spec.rb +242 -181
  21. data/spec/integration/session_spec.rb +86 -15
  22. data/spec/support/app_runner.rb +6 -0
  23. data/src/FindCss.cpp +1 -1
  24. data/src/FindXpath.cpp +1 -1
  25. data/src/IgnoreDebugOutput.cpp +36 -0
  26. data/src/IgnoreDebugOutput.h +1 -0
  27. data/src/InvocationResult.cpp +2 -0
  28. data/src/JavascriptInvocation.cpp +25 -18
  29. data/src/JavascriptInvocation.h +5 -2
  30. data/src/NetworkAccessManager.cpp +10 -0
  31. data/src/NetworkAccessManager.h +2 -0
  32. data/src/Node.cpp +2 -1
  33. data/src/Visit.cpp +1 -1
  34. data/src/WebPage.cpp +22 -4
  35. data/src/WebPage.h +5 -2
  36. data/src/WebPageManager.cpp +4 -3
  37. data/src/capybara.js +107 -52
  38. data/src/main.cpp +2 -1
  39. data/src/pointer.png +0 -0
  40. data/src/webkit_server.pro +9 -2
  41. data/src/webkit_server.qrc +1 -0
  42. data/test/testignoredebugoutput.cpp +45 -0
  43. data/test/testwebkitserver.pro +5 -0
  44. data/webkit_server.pro +3 -1
  45. metadata +86 -42
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 218ecbf884de71199261eb9e085c2e408313cd2c
4
+ data.tar.gz: 56d3b795bb714e25badb726b1a54fabaa84830ea
5
+ SHA512:
6
+ metadata.gz: 5aa4667fe8e68fb68d02bed0d8bedfa7fa9bf0d24cbcbb95f8acc0aa8b468d9e7c27d1ca14b3b963bf98e62d75c6acf1dbc0d8aa991566a71303fba8f6ece68a
7
+ data.tar.gz: cc658b8ae059a0d9cbb3a3b2c4e047981c7eab045362dbfc1c840ac054d5ad30aba177886434b165e9fc2c11194e18b5b3d2c2ae453d7d35df249ec810e81e0b
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.swp
2
2
  bin/webkit_server*
3
+ test/testwebkitserver
3
4
  *.swo
4
5
  *~
5
6
  *.o
data/.travis.yml CHANGED
@@ -4,8 +4,6 @@ rvm:
4
4
  - 2.0.0
5
5
  - rbx-19mode
6
6
  matrix:
7
- allow_failures:
8
- - rvm: rbx-19mode
9
7
  exclude:
10
8
  - rvm: 1.9.3
11
9
  gemfile: gemfiles/2.0.gemfile
@@ -28,4 +26,5 @@ gemfile:
28
26
  before_install:
29
27
  - sudo apt-add-repository -y ppa:canonical-qt5-edgers/qt5-proper
30
28
  - sudo apt-get update
31
- - sudo apt-get install libqt5webkit5-dev qtdeclarative5-dev qtlocation5-dev qtsensors5-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
29
+ - sudo apt-get install libqt5webkit5-dev qtdeclarative5-dev qtlocation5-dev qtsensors5-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev qt4-default
30
+ install: bundle
data/Gemfile.lock CHANGED
@@ -1,64 +1,62 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capybara-webkit (1.0.0)
4
+ capybara-webkit (1.1.0)
5
5
  capybara (~> 2.0, >= 2.0.2)
6
6
  json
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.3.2)
12
11
  appraisal (0.4.0)
13
12
  bundler
14
13
  rake
15
- capybara (2.1.0)
14
+ capybara (2.2.0)
16
15
  mime-types (>= 1.16)
17
16
  nokogiri (>= 1.3.3)
18
17
  rack (>= 1.0.0)
19
18
  rack-test (>= 0.5.4)
20
19
  xpath (~> 2.0)
21
- childprocess (0.3.6)
22
- ffi (~> 1.0, >= 1.0.6)
23
- diff-lcs (1.1.2)
24
- ffi (1.2.0)
25
- ffi (1.2.0-x86-mingw32)
26
- json (1.8.0)
27
- libwebsocket (0.1.7.1)
28
- addressable
29
- websocket
30
- mime-types (1.22)
20
+ childprocess (0.3.9)
21
+ ffi (~> 1.0, >= 1.0.11)
22
+ diff-lcs (1.2.4)
23
+ ffi (1.9.0)
24
+ ffi (1.9.0-x86-mingw32)
25
+ json (1.8.1)
26
+ mime-types (2.0)
31
27
  mini_magick (3.2.1)
32
28
  subexec (~> 0.0.4)
33
- multi_json (1.5.0)
34
- nokogiri (1.5.9)
29
+ mini_portile (0.5.2)
30
+ multi_json (1.7.8)
31
+ nokogiri (1.6.0)
32
+ mini_portile (~> 0.5.0)
35
33
  rack (1.5.2)
36
34
  rack-protection (1.3.2)
37
35
  rack
38
36
  rack-test (0.6.2)
39
37
  rack (>= 1.0)
40
38
  rake (0.9.2)
41
- rspec (2.6.0)
42
- rspec-core (~> 2.6.0)
43
- rspec-expectations (~> 2.6.0)
44
- rspec-mocks (~> 2.6.0)
45
- rspec-core (2.6.4)
46
- rspec-expectations (2.6.0)
47
- diff-lcs (~> 1.1.2)
48
- rspec-mocks (2.6.0)
39
+ rspec (2.14.1)
40
+ rspec-core (~> 2.14.0)
41
+ rspec-expectations (~> 2.14.0)
42
+ rspec-mocks (~> 2.14.0)
43
+ rspec-core (2.14.4)
44
+ rspec-expectations (2.14.1)
45
+ diff-lcs (>= 1.1.3, < 2.0)
46
+ rspec-mocks (2.14.3)
49
47
  rubyzip (0.9.9)
50
- selenium-webdriver (2.27.2)
48
+ selenium-webdriver (2.33.0)
51
49
  childprocess (>= 0.2.5)
52
- libwebsocket (~> 0.1.3)
53
50
  multi_json (~> 1.0)
54
51
  rubyzip
52
+ websocket (~> 1.0.4)
55
53
  sinatra (1.3.5)
56
54
  rack (~> 1.4)
57
55
  rack-protection (~> 1.3)
58
56
  tilt (~> 1.3, >= 1.3.3)
59
57
  subexec (0.0.4)
60
58
  tilt (1.3.3)
61
- websocket (1.0.6)
59
+ websocket (1.0.7)
62
60
  xpath (2.0.0)
63
61
  nokogiri (~> 1.3)
64
62
 
@@ -71,6 +69,6 @@ DEPENDENCIES
71
69
  capybara-webkit!
72
70
  mini_magick
73
71
  rake
74
- rspec (~> 2.6.0)
72
+ rspec (~> 2.14.0)
75
73
  selenium-webdriver
76
74
  sinatra
data/NEWS.md CHANGED
@@ -1,3 +1,15 @@
1
+ New for 1.1.0:
2
+
3
+ * Improve messages for ClickFailed errors to aid debugging.
4
+ * Fix long load times on Ruby 2.0.0-p195.
5
+ * Automatically save screenshots on ClickFailed errors.
6
+ * Render a mouse pointer in screenshots for the current mouse location.
7
+ * Silent debug messages from Qt.
8
+ * Fix OS X keychain bug in Qt 5 related to basic authentication.
9
+ * Fix issues visiting URLs with square brackets.
10
+ * Fail immediately when trying to install with unsupported versions of Qt.
11
+ * Fix race condition leading to InvalidResponseErrors.
12
+
1
13
  New for 1.0.0:
2
14
 
3
15
  * Fix a memory leak in the logger.
data/README.md CHANGED
@@ -4,7 +4,7 @@ capybara-webkit
4
4
  [![Build Status](https://secure.travis-ci.org/thoughtbot/capybara-webkit.png?branch=master)](https://travis-ci.org/thoughtbot/capybara-webkit)
5
5
  [![Code Climate](https://codeclimate.com/github/thoughtbot/capybara-webkit.png)](https://codeclimate.com/github/thoughtbot/capybara-webkit)
6
6
 
7
- 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).
7
+ A [capybara](https://github.com/jnicklas/capybara) driver that uses [WebKit](http://webkit.org) via [QtWebKit](http://trac.webkit.org/wiki/QtWebKit).
8
8
 
9
9
  Qt Dependency and Installation Issues
10
10
  -------------------------------------
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ Bundler::GemHelper.install_tasks
7
7
 
8
8
  desc "Generate a Makefile using qmake"
9
9
  file 'Makefile' do
10
- CapybaraWebkitBuilder.makefile or exit(1)
10
+ CapybaraWebkitBuilder.makefile('CONFIG+=test') or exit(1)
11
11
  end
12
12
 
13
13
  desc "Regenerate dependencies using qmake"
@@ -20,6 +20,11 @@ task :build => :qmake do
20
20
  CapybaraWebkitBuilder.build or exit(1)
21
21
  end
22
22
 
23
+ desc "Run QtTest unit tests for webkit server"
24
+ task :check => :build do
25
+ sh("make check") or exit(1)
26
+ end
27
+
23
28
  file 'bin/webkit_server' => :build
24
29
 
25
30
  RSpec::Core::RakeTask.new do |t|
@@ -27,16 +32,15 @@ RSpec::Core::RakeTask.new do |t|
27
32
  t.rspec_opts = "--format progress"
28
33
  end
29
34
 
35
+ task :spec => :build
36
+
30
37
  desc "Default: build and run all specs"
31
- task :default => [:build, :spec]
38
+ task :default => [:check, :spec]
32
39
 
33
40
  desc "Generate a new command called NAME"
34
41
  task :generate_command do
35
42
  name = ENV['NAME'] or raise "Provide a name with NAME="
36
43
 
37
- header = "src/#{name}.h"
38
- source = "src/#{name}.cpp"
39
-
40
44
  %w(h cpp).each do |extension|
41
45
  File.open("templates/Command.#{extension}", "r") do |source_file|
42
46
  contents = source_file.read
@@ -9,6 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.email = "support@thoughtbot.com"
10
10
  s.homepage = "http://github.com/thoughtbot/capybara-webkit"
11
11
  s.summary = "Headless Webkit driver for Capybara"
12
+ s.license = 'MIT'
12
13
 
13
14
  s.files = `git ls-files`.split("\n")
14
15
  s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
@@ -21,7 +22,7 @@ Gem::Specification.new do |s|
21
22
  s.add_runtime_dependency("capybara", "~> 2.0", ">= 2.0.2")
22
23
  s.add_runtime_dependency("json")
23
24
 
24
- s.add_development_dependency("rspec", "~> 2.6.0")
25
+ s.add_development_dependency("rspec", "~> 2.14.0")
25
26
  # Sinatra is used by Capybara's TestApp
26
27
  s.add_development_dependency("sinatra")
27
28
  s.add_development_dependency("mini_magick")
@@ -11,23 +11,23 @@ GEM
11
11
  appraisal (0.4.1)
12
12
  bundler
13
13
  rake
14
- capybara (2.0.2)
14
+ capybara (2.0.3)
15
15
  mime-types (>= 1.16)
16
16
  nokogiri (>= 1.3.3)
17
17
  rack (>= 1.0.0)
18
18
  rack-test (>= 0.5.4)
19
19
  selenium-webdriver (~> 2.0)
20
20
  xpath (~> 1.0.0)
21
- childprocess (0.3.8)
21
+ childprocess (0.3.9)
22
22
  ffi (~> 1.0, >= 1.0.11)
23
23
  diff-lcs (1.1.3)
24
- ffi (1.4.0)
24
+ ffi (1.9.0)
25
25
  json (1.8.0)
26
- mime-types (1.21)
26
+ mime-types (1.23)
27
27
  mini_magick (3.5.0)
28
28
  subexec (~> 0.2.1)
29
- multi_json (1.6.1)
30
- nokogiri (1.5.6)
29
+ multi_json (1.7.8)
30
+ nokogiri (1.5.9)
31
31
  rack (1.5.2)
32
32
  rack-protection (1.3.2)
33
33
  rack
@@ -43,7 +43,7 @@ GEM
43
43
  diff-lcs (~> 1.1.2)
44
44
  rspec-mocks (2.6.0)
45
45
  rubyzip (0.9.9)
46
- selenium-webdriver (2.30.0)
46
+ selenium-webdriver (2.33.0)
47
47
  childprocess (>= 0.2.5)
48
48
  multi_json (~> 1.0)
49
49
  rubyzip
@@ -17,15 +17,15 @@ GEM
17
17
  rack (>= 1.0.0)
18
18
  rack-test (>= 0.5.4)
19
19
  xpath (~> 2.0)
20
- childprocess (0.3.8)
20
+ childprocess (0.3.9)
21
21
  ffi (~> 1.0, >= 1.0.11)
22
22
  diff-lcs (1.1.3)
23
- ffi (1.4.0)
23
+ ffi (1.9.0)
24
24
  json (1.8.0)
25
- mime-types (1.22)
25
+ mime-types (1.23)
26
26
  mini_magick (3.5.0)
27
27
  subexec (~> 0.2.1)
28
- multi_json (1.6.1)
28
+ multi_json (1.7.8)
29
29
  nokogiri (1.5.9)
30
30
  rack (1.5.2)
31
31
  rack-protection (1.3.2)
@@ -42,7 +42,7 @@ GEM
42
42
  diff-lcs (~> 1.1.2)
43
43
  rspec-mocks (2.6.0)
44
44
  rubyzip (0.9.9)
45
- selenium-webdriver (2.30.0)
45
+ selenium-webdriver (2.33.0)
46
46
  childprocess (>= 0.2.5)
47
47
  multi_json (~> 1.0)
48
48
  rubyzip
@@ -11,6 +11,7 @@ module Capybara::Webkit
11
11
  attr_reader :port
12
12
 
13
13
  def initialize(options = {})
14
+ @socket = nil
14
15
  @socket_class = options[:socket_class] || TCPSocket
15
16
  if options.has_key?(:stderr)
16
17
  @output_target = options[:stderr]
@@ -1,4 +1,4 @@
1
- require 'webrick'
1
+ require 'webrick/cookie'
2
2
 
3
3
  # A simple cookie jar implementation.
4
4
  # Does not take special cookie attributes
@@ -126,11 +126,7 @@ module Capybara::Webkit
126
126
  end
127
127
 
128
128
  def invoke(name, *args)
129
- if allow_unattached_nodes? || attached?
130
- browser.command "Node", name, native, *args
131
- else
132
- raise Capybara::Webkit::NodeNotAttachedError
133
- end
129
+ browser.command "Node", name, allow_unattached_nodes?, native, *args
134
130
  end
135
131
 
136
132
  def allow_unattached_nodes?
@@ -1,7 +1,7 @@
1
1
  module Capybara
2
2
  module Driver
3
3
  class Webkit
4
- VERSION = '1.0.0'.freeze
4
+ VERSION = '1.1.0'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -52,8 +52,8 @@ module CapybaraWebkitBuilder
52
52
  success
53
53
  end
54
54
 
55
- def makefile
56
- sh("#{qmake_bin} -spec #{spec}")
55
+ def makefile(config = '')
56
+ sh("#{qmake_bin} -spec #{spec} #{config}")
57
57
  end
58
58
 
59
59
  def qmake
data/spec/browser_spec.rb CHANGED
@@ -86,10 +86,10 @@ describe Capybara::Webkit::Browser do
86
86
 
87
87
  @server_thread = Thread.new do
88
88
  while conn = @server.accept
89
- Thread.new(conn) do |conn|
89
+ Thread.new(conn) do |thread_conn|
90
90
  # read request
91
91
  request = []
92
- until (line = conn.readline.strip).empty?
92
+ until (line = thread_conn.readline.strip).empty?
93
93
  request << line
94
94
  end
95
95
 
@@ -110,13 +110,13 @@ describe Capybara::Webkit::Browser do
110
110
  </body>
111
111
  </html>
112
112
  HTML
113
- conn.write "HTTP/1.1 200 OK\r\n"
114
- conn.write "Content-Type:text/html\r\n"
115
- conn.write "Content-Length: %i\r\n" % html.size
116
- conn.write "\r\n"
117
- conn.write html
118
- conn.write("\r\n\r\n")
119
- conn.close
113
+ thread_conn.write "HTTP/1.1 200 OK\r\n"
114
+ thread_conn.write "Content-Type:text/html\r\n"
115
+ thread_conn.write "Content-Length: %i\r\n" % html.size
116
+ thread_conn.write "\r\n"
117
+ thread_conn.write html
118
+ thread_conn.write("\r\n\r\n")
119
+ thread_conn.close
120
120
  end
121
121
  end
122
122
  end
@@ -202,7 +202,7 @@ describe Capybara::Webkit::Browser do
202
202
  :user => @user,
203
203
  :pass => @pass)
204
204
  browser.visit @url
205
- @proxy_requests.size.should == 2
205
+ @proxy_requests.size.should eq 2
206
206
  @request = @proxy_requests[-1]
207
207
  end
208
208
 
@@ -212,7 +212,7 @@ describe Capybara::Webkit::Browser do
212
212
  end
213
213
 
214
214
  it 'uses the HTTP proxy correctly' do
215
- @request[0].should match /^GET\s+http:\/\/example.org\/\s+HTTP/i
215
+ @request[0].should match(/^GET\s+http:\/\/example.org\/\s+HTTP/i)
216
216
  @request.find { |header|
217
217
  header =~ /^Host:\s+example.org$/i }.should_not be nil
218
218
  end
@@ -223,8 +223,8 @@ describe Capybara::Webkit::Browser do
223
223
  auth_header.should_not be nil
224
224
 
225
225
  user, pass = Base64.decode64(auth_header.split(/\s+/)[-1]).split(":")
226
- user.should == @user
227
- pass.should == @pass
226
+ user.should eq @user
227
+ pass.should eq @pass
228
228
  end
229
229
 
230
230
  it "uses the proxies' response" do
@@ -232,24 +232,24 @@ describe Capybara::Webkit::Browser do
232
232
  end
233
233
 
234
234
  it 'uses original URL' do
235
- browser.current_url.should == @url
235
+ browser.current_url.should eq @url
236
236
  end
237
237
 
238
238
  it 'uses URLs changed by javascript' do
239
239
  browser.execute_script "window.history.pushState('', '', '/blah')"
240
- browser.current_url.should == 'http://example.org/blah'
240
+ browser.current_url.should eq 'http://example.org/blah'
241
241
  end
242
242
 
243
243
  it 'is possible to disable proxy again' do
244
244
  @proxy_requests.clear
245
245
  browser.clear_proxy
246
246
  browser.visit "http://#{@host}:#{@port}/"
247
- @proxy_requests.size.should == 0
247
+ @proxy_requests.size.should eq 0
248
248
  end
249
249
  end
250
250
 
251
251
  it "doesn't try to read an empty response" do
252
- connection = stub("connection")
252
+ connection = double("connection")
253
253
  connection.stub(:puts)
254
254
  connection.stub(:print)
255
255
  connection.stub(:gets).and_return("ok\n", "0\n")
@@ -257,7 +257,7 @@ describe Capybara::Webkit::Browser do
257
257
 
258
258
  browser = Capybara::Webkit::Browser.new(connection)
259
259
 
260
- expect { browser.visit("/") }.not_to raise_error(/empty response/)
260
+ expect { browser.visit("/") }.not_to raise_error
261
261
  end
262
262
 
263
263
  describe '#command' do
@@ -8,11 +8,11 @@ describe Capybara::Webkit::Connection do
8
8
  connection.puts 1
9
9
  connection.puts url.to_s.bytesize
10
10
  connection.print url
11
- connection.gets.should == "ok\n"
12
- connection.gets.should == "0\n"
11
+ connection.gets.should eq "ok\n"
12
+ connection.gets.should eq "0\n"
13
13
  connection.puts "Body"
14
14
  connection.puts 0
15
- connection.gets.should == "ok\n"
15
+ connection.gets.should eq "ok\n"
16
16
  response_length = connection.gets.to_i
17
17
  response = connection.read(response_length)
18
18
  response.should include("Hey there")
@@ -53,7 +53,7 @@ describe Capybara::Webkit::Connection do
53
53
  end
54
54
 
55
55
  it 'sets appropriate options on its socket' do
56
- socket = stub('socket')
56
+ socket = double('socket')
57
57
  TCPSocket.stub(:open).and_return(socket)
58
58
  if defined?(Socket::TCP_NODELAY)
59
59
  socket.should_receive(:setsockopt).with(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true)