capybara-wsl 0.3.0 → 1.0.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/README.md +2 -9
- data/capybara-wsl.gemspec +1 -0
- data/lib/capybara/.env +1 -0
- data/lib/capybara/wsl.rb +9 -5
- data/lib/capybara/wsl/version.rb +1 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6e1fa1dc4d6306f92befd8404b9e970240cf9b0040af5797e305f6bd84248b0
|
4
|
+
data.tar.gz: 9f1d5aa261b96d27c8672b31d1d9811f09e14a65fb8bbe0c97aa938334a9d1ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e70cbf7a30b3ffbd7c942377e7b36a19a12fe009e0e373587cdf73f1ee872eaa74738a1017e0a2dc46ae31332f21682edf6e519b55df2d70da2acd5358191bb
|
7
|
+
data.tar.gz: 94150365d110b182c06a3d3d587ac29327375614cb46759ad41d498a211f8bb78367e73a5062736358188e84f06cb9aac98d8d03b60006f9cb77bddb55af54a6
|
data/README.md
CHANGED
@@ -6,7 +6,8 @@
|
|
6
6
|
|
7
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
|
9
|
+
This gem modifies that path to include `wsl$` part so that it's understandable for Windows and opens it in your default browser. It automatically detects your current WSL distro (since version 0.3.0).
|
10
|
+
There's no need to manually set the `BROWSER` env variable since version 1.0.0.
|
10
11
|
|
11
12
|
### Installation
|
12
13
|
In your `Gemfile` add:
|
@@ -17,14 +18,6 @@ Then run `bundle install`.
|
|
17
18
|
|
18
19
|
Or `gem install capybara-wsl`, but then running it is a bit less straightforward.
|
19
20
|
|
20
|
-
### Important note
|
21
|
-
In order for it to work, you have to add `$BROWSER` env variable.
|
22
|
-
###### Example for Firefox
|
23
|
-
In your `.bashrc` add (notice the quotes):
|
24
|
-
```
|
25
|
-
export BROWSER="'/mnt/c/Program Files/Mozilla Firefox/firefox.exe'"
|
26
|
-
```
|
27
|
-
|
28
21
|
### Usage
|
29
22
|
Simply use
|
30
23
|
`save_and_open_page_wsl` or
|
data/capybara-wsl.gemspec
CHANGED
data/lib/capybara/.env
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export BROWSER="'/mnt/c/Windows/explorer.exe'"
|
data/lib/capybara/wsl.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "dotenv"
|
4
|
+
require "launchy"
|
4
5
|
require "capybara/dsl"
|
5
6
|
require_relative "wsl/dsl"
|
6
7
|
|
@@ -24,12 +25,15 @@ module Capybara
|
|
24
25
|
private
|
25
26
|
|
26
27
|
def self.open_file(path)
|
28
|
+
Dotenv.overload!(File.expand_path("#{__FILE__}/../.env"))
|
27
29
|
wsl_path = modify_path(path)
|
28
|
-
|
30
|
+
Launchy.open(wsl_path)
|
31
|
+
rescue LoadError
|
32
|
+
warn "File saved to #{wsl_path}.\nPlease install the launchy gem to open the file automatically."
|
29
33
|
end
|
30
34
|
|
31
35
|
def self.modify_path(path)
|
32
|
-
path.prepend(detect_path)
|
36
|
+
path[1..-1].prepend(detect_path).gsub("/", "\\")
|
33
37
|
end
|
34
38
|
|
35
39
|
def self.detect_path
|
@@ -40,10 +44,10 @@ module Capybara
|
|
40
44
|
"Cannot detect WSL path. Are you sure you're running WSL?")
|
41
45
|
end
|
42
46
|
|
43
|
-
"file
|
47
|
+
"file:#{path}"
|
44
48
|
end
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
48
|
-
# Add WSL-
|
52
|
+
# Add WSL-related methods to Capybara's DSL
|
49
53
|
Capybara::DSL.include Capybara::WSL::DSL
|
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: 1.0.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:
|
11
|
+
date: 2021-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dotenv
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Allows Capybara to open pages/screenshots in Windows browsers via Launchy.
|
42
56
|
email: mark.tityuk@gmail.com
|
43
57
|
executables: []
|
@@ -49,6 +63,7 @@ files:
|
|
49
63
|
- README.md
|
50
64
|
- capybara-wsl.gemspec
|
51
65
|
- lib/capybara-wsl.rb
|
66
|
+
- lib/capybara/.env
|
52
67
|
- lib/capybara/wsl.rb
|
53
68
|
- lib/capybara/wsl/dsl.rb
|
54
69
|
- lib/capybara/wsl/version.rb
|
@@ -71,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
86
|
- !ruby/object:Gem::Version
|
72
87
|
version: '0'
|
73
88
|
requirements: []
|
74
|
-
rubygems_version: 3.1.
|
89
|
+
rubygems_version: 3.1.4
|
75
90
|
signing_key:
|
76
91
|
specification_version: 4
|
77
92
|
summary: Open pages/screenshots in WSL from Capybara
|