capybara-wsl 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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: 6c4a4a81cb34cfa393153470bcbd4e92c85a8772dd03062222fa785900f96535
|
4
|
+
data.tar.gz: 6c8702620175538fd7a1712f818dad10e57ca66256e8045db2c7a77512deea3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b7ff411a76b5e84ae35c23c0bdeb028e45fde33b08a0766f207848f14659c4097ec8619754f0bdb36f5a80ad38d1f7cc01a893058f8816ac772b7ae714ea5d1
|
7
|
+
data.tar.gz: 58b6f4a3233dd14debb186b5a63b72a82edc557b6234ce816614820d8bedccbd4371754c39ffe384eead5f898fe9a0e5a2ea4d5aab7a2dc3e2aa4b7c5c8a5c79
|
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 self.modify_path(path)
|
37
|
+
path[1..-1].prepend(detect_path).gsub("/", "\\")
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
def self.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.2
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|