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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f11aafa6695c0e551d55d0fe3be58c9c89e9a524557acfc58ac8a8499fae9181
4
- data.tar.gz: eac5da53234c829f4927f32b3499216443bd5b313a889d2640cd63e169c2d1bd
3
+ metadata.gz: 6c4a4a81cb34cfa393153470bcbd4e92c85a8772dd03062222fa785900f96535
4
+ data.tar.gz: 6c8702620175538fd7a1712f818dad10e57ca66256e8045db2c7a77512deea3e
5
5
  SHA512:
6
- metadata.gz: 895cb00cd4f6d0721a83b43cb2eb85bac6e4d391a11454f79db1002e57d4aa31177fd12c014f2977b32c29c6c8030f67a24c8f155f5e34bc030002c63edce996
7
- data.tar.gz: 9e549d9723a13a3e53a7ccaa4aaaa2414db0f168be90d055b998c7d2d970a5dac4b8ebe4d56aecb6198d9b85b40293c8503d9ce17c6a98eb1f49403820afa742
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
- ### Installation
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
- ### Usage
21
+ ## Usage
22
22
  Simply use
23
- `save_and_open_page_wsl` or
24
- `save_and_open_screenshot_wsl` instead of their normal versions. You can use same arguments.
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
- If you installed via `gem install`:
27
- Run `gem which capybara-wsl` in your console and copy output.
28
- Use as:
29
- ```
30
- require "copied output"
31
- Capybara::WSL.save_and_open_page
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
+ ```
@@ -8,7 +8,7 @@ module Capybara
8
8
  end
9
9
 
10
10
  def save_and_open_screenshot_wsl(path = nil, **options)
11
- Capybara::WSL.save_and_open_screenshot(path, options)
11
+ Capybara::WSL.save_and_open_screenshot(path, **options)
12
12
  end
13
13
  end
14
14
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Capybara
4
4
  module WSL
5
- VERSION = "1.0.1"
5
+ VERSION = "1.0.2"
6
6
  end
7
7
  end
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
- def self.save_and_open_page(path = nil)
14
- Capybara.current_session.save_page(path).tap do |s_path|
15
- open_file(s_path)
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
- def self.save_and_open_screenshot(path = nil, **options)
20
- Capybara.current_session.save_screenshot(path, options).tap do |s_path|
21
- open_file(s_path)
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
- private
26
+ private
26
27
 
27
- def self.open_file(path)
28
- Dotenv.overload!(File.expand_path("#{__FILE__}/../.env"))
29
- wsl_path = modify_path(path)
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."
33
- end
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
- def self.modify_path(path)
36
- path[1..-1].prepend(detect_path).gsub("/", "\\")
37
- end
36
+ def self.modify_path(path)
37
+ path[1..-1].prepend(detect_path).gsub("/", "\\")
38
+ end
38
39
 
39
- def self.detect_path
40
- path = `wslpath -m "/"`&.strip
40
+ def self.detect_path
41
+ path = `wslpath -m "/"`&.strip
41
42
 
42
- if path.empty?
43
- raise(Capybara::WSL::CannotDetectWSLPath,
44
- "Cannot detect WSL path. Are you sure you're running WSL?")
45
- end
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
- "file:#{path}"
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 Capybara::WSL::DSL
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.1
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: 2021-03-29 00:00:00.000000000 Z
11
+ date: 2023-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara