smartest 0.3.1.alpha3 → 0.3.1.alpha4
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 -1
- data/lib/smartest/init_browser_generator.rb +9 -7
- data/lib/smartest/version.rb +1 -1
- data/smartest/smartest_test.rb +36 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f0ad4d0e55a491b021ce003225cabcec5ceef4e2f3fbfd5f24c5bfbb8064a65b
|
|
4
|
+
data.tar.gz: ea6b00342dfccdac90f904f90684af1ff69a75865ccaaf50b74803d7fdfd8cfb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '099d26d094f730b421d3cfe2d09c8a9391f13a1949e111c00c4c3612fa22510f6403db236a87ca352f4646a695fffc0136d3d9b804acaf0287c4d75d79c900cf'
|
|
7
|
+
data.tar.gz: f77ea77aa5cb56ecf4df7bdaf5d63537daae371997d2aeca7a66d74abc4a52add7241bb0b922e3c392306dd714405abe267af4ae65dcbeb6f0b3d8c506474a00
|
data/README.md
CHANGED
|
@@ -146,8 +146,9 @@ smartest/example_spec.rb
|
|
|
146
146
|
|
|
147
147
|
It also registers `PlaywrightFixture` and `PlaywrightMatcher`, adds
|
|
148
148
|
`playwright-ruby-client` to the Gemfile test group, runs `bundle install`, runs
|
|
149
|
+
`npm init --yes` when no `package.json` exists yet, runs
|
|
149
150
|
`npm install playwright --save-dev`, and downloads Chromium with
|
|
150
|
-
|
|
151
|
+
`./node_modules/.bin/playwright install`.
|
|
151
152
|
|
|
152
153
|
Run the generated browser example with:
|
|
153
154
|
|
|
@@ -74,12 +74,6 @@ module Smartest
|
|
|
74
74
|
end
|
|
75
75
|
RUBY
|
|
76
76
|
|
|
77
|
-
INSTALL_COMMANDS = [
|
|
78
|
-
["bundle", "install"],
|
|
79
|
-
["npm", "install", "playwright", "--save-dev"],
|
|
80
|
-
["./node_modules/.bin/playwright", "install"]
|
|
81
|
-
].freeze
|
|
82
|
-
|
|
83
77
|
def initialize(root: Dir.pwd, output: $stdout, command_runner: nil)
|
|
84
78
|
@root = root
|
|
85
79
|
@output = output
|
|
@@ -170,7 +164,7 @@ module Smartest
|
|
|
170
164
|
end
|
|
171
165
|
|
|
172
166
|
def install_dependencies
|
|
173
|
-
|
|
167
|
+
install_commands.each do |command|
|
|
174
168
|
@output.puts "run #{command.join(" ")}"
|
|
175
169
|
next if @command_runner.call(command, chdir: @root)
|
|
176
170
|
|
|
@@ -178,6 +172,14 @@ module Smartest
|
|
|
178
172
|
end
|
|
179
173
|
end
|
|
180
174
|
|
|
175
|
+
def install_commands
|
|
176
|
+
commands = [["bundle", "install"]]
|
|
177
|
+
commands << ["npm", "init", "--yes"] unless File.exist?(File.join(@root, "package.json"))
|
|
178
|
+
commands << ["npm", "install", "playwright", "--save-dev"]
|
|
179
|
+
commands << ["./node_modules/.bin/playwright", "install"]
|
|
180
|
+
commands
|
|
181
|
+
end
|
|
182
|
+
|
|
181
183
|
def run_system_command(command, chdir:)
|
|
182
184
|
system(*command, chdir: chdir)
|
|
183
185
|
end
|
data/lib/smartest/version.rb
CHANGED
data/smartest/smartest_test.rb
CHANGED
|
@@ -2044,13 +2044,49 @@ test("cli browser init generator creates Playwright scaffold and installation co
|
|
|
2044
2044
|
expect(commands).to eq(
|
|
2045
2045
|
[
|
|
2046
2046
|
[["bundle", "install"], dir],
|
|
2047
|
+
[["npm", "init", "--yes"], dir],
|
|
2047
2048
|
[["npm", "install", "playwright", "--save-dev"], dir],
|
|
2048
2049
|
[["./node_modules/.bin/playwright", "install"], dir]
|
|
2049
2050
|
]
|
|
2050
2051
|
)
|
|
2051
2052
|
expect(output.string).to include("run bundle install")
|
|
2053
|
+
expect(output.string).to include("run npm init --yes")
|
|
2052
2054
|
expect(output.string).to include("run npm install playwright --save-dev")
|
|
2053
2055
|
expect(output.string).to include("run ./node_modules/.bin/playwright install")
|
|
2054
2056
|
expect(output.string).to include("Run your browser test suite with: bundle exec smartest smartest/example_spec.rb")
|
|
2055
2057
|
end
|
|
2056
2058
|
end
|
|
2059
|
+
|
|
2060
|
+
test("cli browser init generator skips npm init when package.json already exists") do
|
|
2061
|
+
Dir.mktmpdir do |dir|
|
|
2062
|
+
File.write(File.join(dir, "Gemfile"), <<~RUBY)
|
|
2063
|
+
source "https://rubygems.org"
|
|
2064
|
+
|
|
2065
|
+
gem "smartest"
|
|
2066
|
+
RUBY
|
|
2067
|
+
File.write(File.join(dir, "package.json"), "{\n \"name\": \"existing\"\n}\n")
|
|
2068
|
+
|
|
2069
|
+
commands = []
|
|
2070
|
+
output = StringIO.new
|
|
2071
|
+
generator = Smartest::InitBrowserGenerator.new(
|
|
2072
|
+
root: dir,
|
|
2073
|
+
output: output,
|
|
2074
|
+
command_runner: ->(command, chdir:) {
|
|
2075
|
+
commands << [command, chdir]
|
|
2076
|
+
true
|
|
2077
|
+
}
|
|
2078
|
+
)
|
|
2079
|
+
|
|
2080
|
+
status = generator.run
|
|
2081
|
+
|
|
2082
|
+
expect(status).to eq(0)
|
|
2083
|
+
expect(commands).to eq(
|
|
2084
|
+
[
|
|
2085
|
+
[["bundle", "install"], dir],
|
|
2086
|
+
[["npm", "install", "playwright", "--save-dev"], dir],
|
|
2087
|
+
[["./node_modules/.bin/playwright", "install"], dir]
|
|
2088
|
+
]
|
|
2089
|
+
)
|
|
2090
|
+
expect(output.string).not_to include("npm init --yes")
|
|
2091
|
+
end
|
|
2092
|
+
end
|