capybara-wsl 1.0.1 → 1.0.3
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 +13 -12
- data/lib/capybara/wsl/dsl.rb +1 -1
- data/lib/capybara/wsl/version.rb +1 -1
- data/lib/capybara/wsl.rb +29 -27
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2128b5725af834b41e2b77bb6e6cc236fe1896b33b129870370b3862eddd90fe
|
4
|
+
data.tar.gz: c77e912387425cfc59f05bfee888ff60d0cf3b28e2a8608f02a5619d68484f57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 383cf0125eb5ee187983dc57a4a79b65c4285e3950fe7d1c52c7e3df1ea87b63fe4a9a443842ad7d57109d2a703d5e2c1c0c120783b1e66322d78d1c98333f94
|
7
|
+
data.tar.gz: 258e87786884857121b50a3400df140cb873fa68f1c7b1992794bbff73b2370aa1e715a920a06b00522f1d9b742d30b55e6a6d8ef2bb297eb342cff39d014c99
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ Capybara's `save_and_open_page` and `save_and_open_screenshot` methods don't wor
|
|
9
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
10
|
There's no need to manually set the `BROWSER` env variable since version 1.0.0.
|
11
11
|
|
12
|
-
|
12
|
+
## Installation
|
13
13
|
In your `Gemfile` add:
|
14
14
|
```
|
15
15
|
gem "capybara-wsl"
|
@@ -18,16 +18,17 @@ Then run `bundle install`.
|
|
18
18
|
|
19
19
|
Or `gem install capybara-wsl`, but then running it is a bit less straightforward.
|
20
20
|
|
21
|
-
|
21
|
+
## Usage
|
22
22
|
Simply use
|
23
|
-
|
24
|
-
|
23
|
+
```
|
24
|
+
save_and_open_page_wsl
|
25
|
+
save_and_open_screenshot_wsl
|
26
|
+
```
|
27
|
+
instead of their normal versions. You can use same arguments.
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
Capybara::WSL.save_and_open_screenshot
|
33
|
-
```
|
29
|
+
If you installed via `gem install`, use as:
|
30
|
+
```
|
31
|
+
require `gem which capybara-wsl`.strip
|
32
|
+
Capybara::WSL.save_and_open_page
|
33
|
+
Capybara::WSL.save_and_open_screenshot
|
34
|
+
```
|
data/lib/capybara/wsl/dsl.rb
CHANGED
data/lib/capybara/wsl/version.rb
CHANGED
data/lib/capybara/wsl.rb
CHANGED
@@ -10,44 +10,46 @@ module Capybara
|
|
10
10
|
class CapybaraWSLError < StandardError; end
|
11
11
|
class CannotDetectWSLPath < CapybaraWSLError; end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
class << self
|
14
|
+
def save_and_open_page(path = nil)
|
15
|
+
Capybara.current_session.save_page(path).tap do |s_path|
|
16
|
+
open_file(s_path)
|
17
|
+
end
|
16
18
|
end
|
17
|
-
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def save_and_open_screenshot(path = nil, **options)
|
21
|
+
Capybara.current_session.save_screenshot(path, **options).tap do |s_path|
|
22
|
+
open_file(s_path)
|
23
|
+
end
|
22
24
|
end
|
23
|
-
end
|
24
25
|
|
25
|
-
|
26
|
+
private
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
def open_file(path)
|
29
|
+
Dotenv.overload!(File.expand_path("#{__FILE__}/../.env"))
|
30
|
+
wsl_path = modify_path(path)
|
31
|
+
Launchy.open(wsl_path)
|
32
|
+
rescue LoadError
|
33
|
+
warn "File saved to #{wsl_path}.\nPlease install the launchy gem to open the file automatically."
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
def modify_path(path)
|
37
|
+
path[1..-1].prepend(detect_path).gsub("/", "\\")
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
def detect_path
|
41
|
+
path = `wslpath -m "/"`&.strip
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
if path.empty?
|
44
|
+
raise(Capybara::WSL::CannotDetectWSLPath,
|
45
|
+
"Cannot detect WSL path. Are you sure you're running WSL?")
|
46
|
+
end
|
46
47
|
|
47
|
-
|
48
|
+
"file:#{path}"
|
49
|
+
end
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
52
54
|
# Add WSL-related methods to Capybara's DSL
|
53
|
-
Capybara::DSL.include
|
55
|
+
Capybara::DSL.include(Capybara::WSL::DSL)
|
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: 1.0.
|
4
|
+
version: 1.0.3
|
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: 2023-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|