Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: thoughtbot/capybara-webkit
...
head fork: ni-ka/capybara-webkit
Checking mergeability… Don't worry, you can still create the pull request.
  • 15 commits
  • 6 files changed
  • 0 commit comments
  • 2 contributors
View
4 .gitignore
@@ -1,5 +1,5 @@
*.swp
-bin/webkit_server
+bin/webkit_server*
*.swo
*~
*.o
@@ -12,6 +12,8 @@ moc_*.cpp
.bundle
pkg
src/webkit_server
+src/webkit_server.exe
.DS_Store
tmp
.rvmrc
+src/debug
View
3  Gemfile.lock
@@ -21,11 +21,13 @@ GEM
ffi (~> 1.0.6)
diff-lcs (1.1.2)
ffi (1.0.9)
+ ffi (1.0.9-x86-mingw32)
json_pure (1.6.1)
mime-types (1.16)
mini_magick (3.2.1)
subexec (~> 0.0.4)
nokogiri (1.5.0)
+ nokogiri (1.5.0-x86-mingw32)
rack (1.3.2)
rack-test (0.6.1)
rack (>= 1.0)
@@ -54,6 +56,7 @@ GEM
PLATFORMS
ruby
+ x86-mingw32
DEPENDENCIES
appraisal (~> 0.4.0)
View
29 lib/capybara/driver/webkit/browser.rb
@@ -2,6 +2,7 @@
require 'thread'
require 'capybara/util/timeout'
require 'json'
+require 'rbconfig'
class Capybara::Driver::Webkit
class Browser
@@ -9,9 +10,9 @@ class Browser
def initialize(options = {})
@socket_class = options[:socket_class] || TCPSocket
- @stdout = options.has_key?(:stdout) ?
- options[:stdout] :
- $stdout
+ @stdout = options.has_key?(:stdout) ?
+ options[:stdout] :
+ $stdout
@ignore_ssl_errors = options[:ignore_ssl_errors]
start_server
connect
@@ -113,7 +114,7 @@ def clear_cookies
end
def get_cookies
- command("GetCookies").lines.map{ |line| line.strip }.select{ |line| !line.empty? }
+ command("GetCookies").lines.map { |line| line.strip }.select { |line| !line.empty? }
end
def set_proxy(options = {})
@@ -147,11 +148,19 @@ def register_shutdown_hook
@owner_pid = Process.pid
at_exit do
if Process.pid == @owner_pid
- Process.kill("INT", @pid)
+ kill_process(@pid)
end
end
end
+ def kill_process(pid)
+ if RbConfig::CONFIG['host_os'] =~ /mingw32/
+ Process.kill(9, pid)
+ else
+ Process.kill("INT", pid)
+ end
+ end
+
def server_pipe_and_pid(server_path)
cmdline = [server_path]
cmdline << "--ignore-ssl-errors" if @ignore_ssl_errors
@@ -207,7 +216,7 @@ def check
if result.nil?
raise WebkitNoResponseError, "No response received from the server."
- elsif result != 'ok'
+ elsif result != 'ok'
raise WebkitInvalidResponseError, read_response
end
@@ -223,10 +232,10 @@ def read_response
def default_proxy_options
{
- :host => "localhost",
- :port => "0",
- :user => "",
- :pass => ""
+ :host => "localhost",
+ :port => "0",
+ :user => "",
+ :pass => ""
}
end
end
View
43 lib/capybara_webkit_builder.rb
@@ -4,21 +4,35 @@
module CapybaraWebkitBuilder
extend self
+ def has_binary?(binary)
+ case RbConfig::CONFIG['host_os']
+ when /mingw32/, /mswin32/
+ system("#{binary} --version")
+ else
+ system("which #{binary}")
+ end
+ end
+
def make_bin
make_binaries = ['gmake', 'make']
- make_binaries.detect { |make| system("which #{make}") }
+ make_binaries.detect { |make| has_binary?(make) }
end
- def makefile
+ def qmake_bin
qmake_binaries = ['qmake', 'qmake-qt4']
- qmake = qmake_binaries.detect { |qmake| system("which #{qmake}") }
+ qmake_binaries.detect { |qmake| has_binary?(qmake) }
+ end
+
+ def makefile
case RbConfig::CONFIG['host_os']
when /linux/
- system("#{qmake} -spec linux-g++")
+ system("#{qmake_bin} -spec linux-g++")
when /freebsd/
- system("#{qmake} -spec freebsd-g++")
+ system("#{qmake_bin} -spec freebsd-g++")
+ when /mingw32/, /mswin32/
+ system("#{qmake_bin} -spec win32-g++")
else
- system("#{qmake} -spec macx-g++")
+ system("#{qmake_bin} -spec macx-g++")
end
end
@@ -26,16 +40,25 @@ def qmake
system("#{make_bin} qmake")
end
+ def path_to_binary
+ case RbConfig::CONFIG['host_os']
+ when /mingw32/, /mswin32/
+ 'src/debug/webkit_server.exe'
+ else
+ 'src/webkit_server'
+ end
+ end
+
def build
system(make_bin) or return false
- FileUtils.mkdir("bin") unless File.directory?("bin")
- FileUtils.cp("src/webkit_server", "bin", :preserve => true)
+ FileUtils.mkdir("bin") unless File.directory?("bin")
+ FileUtils.cp(path_to_binary, "bin", :preserve => true)
end
def build_all
makefile &&
- qmake &&
- build
+ qmake &&
+ build
end
end
View
5 spec/browser_spec.rb
@@ -81,7 +81,8 @@
browser_ignore_ssl_err.visit "https://#{@host}:#{@port}/"
end
end
- describe "forking" do
+
+ describe "forking", :skip_on_windows => true do
it "only shuts down the server from the main process" do
browser.reset!
pid = fork {}
@@ -95,7 +96,7 @@
@host = '127.0.0.1'
@user = 'user'
@pass = 'secret'
- @url = "http://example.org/"
+ @url = "http://example.org/"
@server = TCPServer.new(@host, 0)
@port = @server.addr[1]
View
11 spec/spec_helper.rb
@@ -1,5 +1,6 @@
require 'rspec'
require 'rspec/autorun'
+require 'rbconfig'
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')).freeze
@@ -10,12 +11,16 @@
spec_dir = nil
$:.detect do |dir|
if File.exists? File.join(dir, "capybara.rb")
- spec_dir = File.expand_path(File.join(dir,"..","spec"))
- $:.unshift( spec_dir )
+ spec_dir = File.expand_path(File.join(dir, "..", "spec"))
+ $:.unshift(spec_dir)
end
end
-require File.join(spec_dir,"spec_helper")
+RSpec.configure do |c|
+ c.filter_run_excluding :skip_on_windows => !(RbConfig::CONFIG['host_os'] =~ /mingw32/).nil?
+end
+
+require File.join(spec_dir, "spec_helper")
require 'capybara/driver/webkit/browser'
$webkit_browser = Capybara::Driver::Webkit::Browser.new(:socket_class => TCPSocket, :stdout => nil)

No commit comments for this range

Something went wrong with that request. Please try again.