capybara-wsl 0.2.1 → 0.3.0
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +42 -0
- data/README.md +6 -11
- data/lib/capybara/wsl.rb +16 -22
- data/lib/capybara/wsl/dsl.rb +6 -4
- data/lib/capybara/wsl/version.rb +1 -1
- metadata +3 -3
- data/lib/capybara/wsl/distros.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c268d40e531e50a7d5acc3542da8f8b8ff97f2e1f51706792ffcd3641fcd8040
|
4
|
+
data.tar.gz: 0b013a92616e617b2b3eec67275e36041a627cf157792bf7ed3070ef335c97ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfcccaf4c7b83b9168cc2094f29b766616553dc1725d7646ca2644a3beb793008975d71291442371c22790935423f1172115e35a3af797e6f0bd7449da79a9c0
|
7
|
+
data.tar.gz: cdd13d5a4d73419ab540daaae213482962785e8a327024b7bf4f6afeb6c1b35cce20dbe642ca708b178a0f093ff2121b4a67f1aac90cd86582ad380d10ea4c53
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
capybara-wsl (0.2.1)
|
5
|
+
capybara (>= 2.0)
|
6
|
+
launchy (>= 2.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.7.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
|
+
capybara (3.33.0)
|
14
|
+
addressable
|
15
|
+
mini_mime (>= 0.1.3)
|
16
|
+
nokogiri (~> 1.8)
|
17
|
+
rack (>= 1.6.0)
|
18
|
+
rack-test (>= 0.6.3)
|
19
|
+
regexp_parser (~> 1.5)
|
20
|
+
xpath (~> 3.2)
|
21
|
+
launchy (2.5.0)
|
22
|
+
addressable (~> 2.7)
|
23
|
+
mini_mime (1.0.2)
|
24
|
+
mini_portile2 (2.4.0)
|
25
|
+
nokogiri (1.10.10)
|
26
|
+
mini_portile2 (~> 2.4.0)
|
27
|
+
public_suffix (4.0.5)
|
28
|
+
rack (2.2.3)
|
29
|
+
rack-test (1.1.0)
|
30
|
+
rack (>= 1.0, < 3)
|
31
|
+
regexp_parser (1.7.1)
|
32
|
+
xpath (3.2.0)
|
33
|
+
nokogiri (~> 1.8)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
ruby
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
capybara-wsl!
|
40
|
+
|
41
|
+
BUNDLED WITH
|
42
|
+
2.1.4
|
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
|
1
|
+
capybara-wsl
|
2
2
|
=======================
|
3
3
|
[](https://badge.fury.io/rb/capybara-wsl)
|
4
4
|
|
5
5
|
#### Allows you use open saved pages from WSL
|
6
6
|
|
7
|
-
Capybara's `save_and_open_page` and `save_and_open_screenshot` methods don't work properly in WSL.
|
7
|
+
Capybara's `save_and_open_page` and `save_and_open_screenshot` methods don't work properly in WSL. Capybara saves pages/screenshots, but then it tries to open them via Launchy and there are several problems with that. We don't want to mess with GUI on WSL, we just want to open them in a Windows browser. However, Capybara passes a Linux path to Launchy, which obviously wouldn't work in Windows browsers.
|
8
8
|
|
9
|
-
This gem modifies that path to include `wsl$` part so that it's understandable for Windows browsers.
|
9
|
+
This gem modifies that path to include `wsl$` part so that it's understandable for Windows browsers. It automatically detects your current WSL distro (since version 0.3.0).
|
10
10
|
|
11
11
|
### Installation
|
12
12
|
In your `Gemfile` add:
|
@@ -20,15 +20,15 @@ Or `gem install capybara-wsl`, but then running it is a bit less straightforward
|
|
20
20
|
### Important note
|
21
21
|
In order for it to work, you have to add `$BROWSER` env variable.
|
22
22
|
###### Example for Firefox
|
23
|
-
In your `.bashrc` add:
|
23
|
+
In your `.bashrc` add (notice the quotes):
|
24
24
|
```
|
25
|
-
export BROWSER='/mnt/c/Program Files/Mozilla Firefox/firefox.exe'
|
25
|
+
export BROWSER="'/mnt/c/Program Files/Mozilla Firefox/firefox.exe'"
|
26
26
|
```
|
27
27
|
|
28
28
|
### Usage
|
29
29
|
Simply use
|
30
30
|
`save_and_open_page_wsl` or
|
31
|
-
`save_and_open_screenshot_wsl` instead of their normal versions.
|
31
|
+
`save_and_open_screenshot_wsl` instead of their normal versions. You can use same arguments.
|
32
32
|
|
33
33
|
If you installed via `gem install`:
|
34
34
|
Run `gem which capybara-wsl` in your console and copy output.
|
@@ -38,8 +38,3 @@ Simply use
|
|
38
38
|
Capybara::WSL.save_and_open_page
|
39
39
|
Capybara::WSL.save_and_open_screenshot
|
40
40
|
```
|
41
|
-
|
42
|
-
CapybaraWSL converts page/screenshot path to WSL Ubuntu path by default. If you have another distro, please set the `distro` setting `Capybara::WSL.distro = :debian` to whichever distro you are using.
|
43
|
-
You can look up available distro keys in `Capybara::WSL::DISTROS`. You can also set `distro` to a string with exact folder name of your distro `Capybara::WSL.distro = "openSUSE-Leap-15-1"`.
|
44
|
-
|
45
|
-
Please tell me if some of those distro folder names in `Capybara::WSL::DISTROS` are incorrect, I don't really have a way to check it.
|
data/lib/capybara/wsl.rb
CHANGED
@@ -2,51 +2,45 @@
|
|
2
2
|
|
3
3
|
require "capybara"
|
4
4
|
require "capybara/dsl"
|
5
|
-
require_relative "wsl/distros"
|
6
5
|
require_relative "wsl/dsl"
|
7
6
|
|
8
7
|
module Capybara
|
9
8
|
module WSL
|
10
9
|
class CapybaraWSLError < StandardError; end
|
11
|
-
class
|
10
|
+
class CannotDetectWSLPath < CapybaraWSLError; end
|
12
11
|
|
13
12
|
def self.save_and_open_page(path = nil)
|
14
13
|
Capybara.current_session.save_page(path).tap do |s_path|
|
15
|
-
|
16
|
-
Capybara.current_session.send(:open_file, wsl_path)
|
14
|
+
open_file(s_path)
|
17
15
|
end
|
18
16
|
end
|
19
17
|
|
20
18
|
def self.save_and_open_screenshot(path = nil, **options)
|
21
19
|
Capybara.current_session.save_screenshot(path, options).tap do |s_path|
|
22
|
-
|
23
|
-
Capybara.current_session.send(:open_file, wsl_path)
|
20
|
+
open_file(s_path)
|
24
21
|
end
|
25
22
|
end
|
26
23
|
|
27
|
-
|
28
|
-
@distro || :ubuntu
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.distro=(name)
|
32
|
-
if name.is_a?(Symbol) && DISTROS[name].nil?
|
33
|
-
raise(Capybara::WSL::DistroKeyNotSupported,
|
34
|
-
"This distro key is not supported. Please use supported key or pass a string with exact distro folder name.")
|
35
|
-
end
|
24
|
+
private
|
36
25
|
|
37
|
-
|
26
|
+
def self.open_file(path)
|
27
|
+
wsl_path = modify_path(path)
|
28
|
+
Capybara.current_session.send(:open_file, wsl_path)
|
38
29
|
end
|
39
30
|
|
40
|
-
private
|
41
|
-
|
42
31
|
def self.modify_path(path)
|
43
|
-
path.prepend(
|
32
|
+
path.prepend(detect_path)
|
44
33
|
end
|
45
34
|
|
46
|
-
def self.
|
47
|
-
|
35
|
+
def self.detect_path
|
36
|
+
path = `wslpath -m "/"`&.strip
|
37
|
+
|
38
|
+
if path.empty?
|
39
|
+
raise(Capybara::WSL::CannotDetectWSLPath,
|
40
|
+
"Cannot detect WSL path. Are you sure you're running WSL?")
|
41
|
+
end
|
48
42
|
|
49
|
-
|
43
|
+
"file:///#{path}"
|
50
44
|
end
|
51
45
|
end
|
52
46
|
end
|
data/lib/capybara/wsl/dsl.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Capybara
|
2
4
|
module WSL
|
3
5
|
module DSL
|
4
|
-
def save_and_open_page_wsl
|
5
|
-
Capybara::WSL.save_and_open_page
|
6
|
+
def save_and_open_page_wsl(path = nil)
|
7
|
+
Capybara::WSL.save_and_open_page(path)
|
6
8
|
end
|
7
9
|
|
8
|
-
def save_and_open_screenshot_wsl
|
9
|
-
Capybara::WSL.save_and_open_screenshot
|
10
|
+
def save_and_open_screenshot_wsl(path = nil, **options)
|
11
|
+
Capybara::WSL.save_and_open_screenshot(path, options)
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
data/lib/capybara/wsl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-wsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Tityuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -45,11 +45,11 @@ extensions: []
|
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
47
|
- Gemfile
|
48
|
+
- Gemfile.lock
|
48
49
|
- README.md
|
49
50
|
- capybara-wsl.gemspec
|
50
51
|
- lib/capybara-wsl.rb
|
51
52
|
- lib/capybara/wsl.rb
|
52
|
-
- lib/capybara/wsl/distros.rb
|
53
53
|
- lib/capybara/wsl/dsl.rb
|
54
54
|
- lib/capybara/wsl/version.rb
|
55
55
|
homepage: https://github.com/dersnek/capybara-wsl
|
data/lib/capybara/wsl/distros.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Capybara
|
4
|
-
module WSL
|
5
|
-
DISTROS = {
|
6
|
-
alpine: "Alpine-WSL",
|
7
|
-
centos: "CentOS",
|
8
|
-
debian: "Debian",
|
9
|
-
fedors: "Fedora-Remix-for-WSL",
|
10
|
-
kali: "kali-linux",
|
11
|
-
opensuse: "openSUSE-Leap-15-1",
|
12
|
-
pengwin: "Pengwin",
|
13
|
-
ubuntu: "Ubuntu",
|
14
|
-
}.freeze
|
15
|
-
end
|
16
|
-
end
|