capybara-wsl 0.3.0 → 1.0.0

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: c268d40e531e50a7d5acc3542da8f8b8ff97f2e1f51706792ffcd3641fcd8040
4
- data.tar.gz: 0b013a92616e617b2b3eec67275e36041a627cf157792bf7ed3070ef335c97ba
3
+ metadata.gz: d6e1fa1dc4d6306f92befd8404b9e970240cf9b0040af5797e305f6bd84248b0
4
+ data.tar.gz: 9f1d5aa261b96d27c8672b31d1d9811f09e14a65fb8bbe0c97aa938334a9d1ff
5
5
  SHA512:
6
- metadata.gz: dfcccaf4c7b83b9168cc2094f29b766616553dc1725d7646ca2644a3beb793008975d71291442371c22790935423f1172115e35a3af797e6f0bd7449da79a9c0
7
- data.tar.gz: cdd13d5a4d73419ab540daaae213482962785e8a327024b7bf4f6afeb6c1b35cce20dbe642ca708b178a0f093ff2121b4a67f1aac90cd86582ad380d10ea4c53
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 browsers. It automatically detects your current WSL distro (since version 0.3.0).
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
@@ -16,4 +16,5 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.add_dependency "capybara", ">= 2.0"
18
18
  s.add_dependency "launchy", ">= 2.0"
19
+ s.add_dependency "dotenv"
19
20
  end
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 "capybara"
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
- Capybara.current_session.send(:open_file, wsl_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."
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:///#{path}"
47
+ "file:#{path}"
44
48
  end
45
49
  end
46
50
  end
47
51
 
48
- # Add WSL-relared methods to Capybara's DSL
52
+ # Add WSL-related methods to Capybara's DSL
49
53
  Capybara::DSL.include Capybara::WSL::DSL
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Capybara
4
4
  module WSL
5
- VERSION = "0.3.0"
5
+ VERSION = "1.0.0"
6
6
  end
7
7
  end
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.3.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: 2020-07-10 00:00:00.000000000 Z
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.2
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