smartest 0.3.1.alpha3 → 0.3.1.alpha5
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 +4 -3
- data/lib/smartest/init_browser_generator.rb +12 -14
- data/lib/smartest/version.rb +1 -1
- data/smartest/smartest_test.rb +39 -4
- 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: a5579f607ea23d2a51683b610acb2a75fdfeb4594e65a2489a8388c0561044f8
|
|
4
|
+
data.tar.gz: 4fb60cd6e38a79cbb5617a5f536abe773224cf86bb6bb1147c09ecd001aabce6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b5177080f4e761cc48b2fc5a67a97121e4dc4897f9a5bef1a7ea70525d4e9f14f41cfddce6d234a910789d3a71dc34c1681eda2ba448c2566086632ba0d1a289
|
|
7
|
+
data.tar.gz: aa8ddd2fbbdf3f3ce71e5c7c62161b358da6a90339171d6a416c64f548a90677e859eb4ed67dee3d68eb558b43dd9bfda8a1a9a589804430b7d9ede0aa60837c
|
data/README.md
CHANGED
|
@@ -141,18 +141,19 @@ predicate matcher, then adds:
|
|
|
141
141
|
```text
|
|
142
142
|
smartest/fixtures/playwright_fixture.rb
|
|
143
143
|
smartest/matchers/playwright_matcher.rb
|
|
144
|
-
smartest/
|
|
144
|
+
smartest/example_browser_test.rb
|
|
145
145
|
```
|
|
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
|
|
|
154
155
|
```bash
|
|
155
|
-
bundle exec smartest smartest/
|
|
156
|
+
bundle exec smartest smartest/example_browser_test.rb
|
|
156
157
|
```
|
|
157
158
|
|
|
158
159
|
## Defining tests
|
|
@@ -58,7 +58,7 @@ module Smartest
|
|
|
58
58
|
end
|
|
59
59
|
RUBY
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
EXAMPLE_BROWSER_TEST = <<~RUBY
|
|
62
62
|
# frozen_string_literal: true
|
|
63
63
|
|
|
64
64
|
require "test_helper"
|
|
@@ -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
|
|
@@ -99,7 +93,7 @@ module Smartest
|
|
|
99
93
|
update_gemfile
|
|
100
94
|
install_dependencies
|
|
101
95
|
@output.puts
|
|
102
|
-
@output.puts "Run your browser test suite with: bundle exec smartest smartest/
|
|
96
|
+
@output.puts "Run your browser test suite with: bundle exec smartest smartest/example_browser_test.rb"
|
|
103
97
|
|
|
104
98
|
0
|
|
105
99
|
end
|
|
@@ -107,11 +101,7 @@ module Smartest
|
|
|
107
101
|
private
|
|
108
102
|
|
|
109
103
|
def smartest_files
|
|
110
|
-
Smartest::InitGenerator::FILES.
|
|
111
|
-
next if path == "smartest/example_test.rb"
|
|
112
|
-
|
|
113
|
-
files[path] = contents
|
|
114
|
-
end.merge("smartest/example_spec.rb" => EXAMPLE_SPEC)
|
|
104
|
+
Smartest::InitGenerator::FILES.merge("smartest/example_browser_test.rb" => EXAMPLE_BROWSER_TEST)
|
|
115
105
|
end
|
|
116
106
|
|
|
117
107
|
def create_file(path, contents)
|
|
@@ -170,7 +160,7 @@ module Smartest
|
|
|
170
160
|
end
|
|
171
161
|
|
|
172
162
|
def install_dependencies
|
|
173
|
-
|
|
163
|
+
install_commands.each do |command|
|
|
174
164
|
@output.puts "run #{command.join(" ")}"
|
|
175
165
|
next if @command_runner.call(command, chdir: @root)
|
|
176
166
|
|
|
@@ -178,6 +168,14 @@ module Smartest
|
|
|
178
168
|
end
|
|
179
169
|
end
|
|
180
170
|
|
|
171
|
+
def install_commands
|
|
172
|
+
commands = [["bundle", "install"]]
|
|
173
|
+
commands << ["npm", "init", "--yes"] unless File.exist?(File.join(@root, "package.json"))
|
|
174
|
+
commands << ["npm", "install", "playwright", "--save-dev"]
|
|
175
|
+
commands << ["./node_modules/.bin/playwright", "install"]
|
|
176
|
+
commands
|
|
177
|
+
end
|
|
178
|
+
|
|
181
179
|
def run_system_command(command, chdir:)
|
|
182
180
|
system(*command, chdir: chdir)
|
|
183
181
|
end
|
data/lib/smartest/version.rb
CHANGED
data/smartest/smartest_test.rb
CHANGED
|
@@ -2024,9 +2024,8 @@ test("cli browser init generator creates Playwright scaffold and installation co
|
|
|
2024
2024
|
status = generator.run
|
|
2025
2025
|
|
|
2026
2026
|
expect(status).to eq(0)
|
|
2027
|
-
expect(File.
|
|
2028
|
-
expect(File.read(File.join(dir, "smartest/
|
|
2029
|
-
expect(File.read(File.join(dir, "smartest/example_spec.rb"))).to include('expect(page).to have_url("https://rubygems.org/gems/smartest")')
|
|
2027
|
+
expect(File.read(File.join(dir, "smartest/example_browser_test.rb"))).to include("finds the smartest gem on RubyGems")
|
|
2028
|
+
expect(File.read(File.join(dir, "smartest/example_browser_test.rb"))).to include('expect(page).to have_url("https://rubygems.org/gems/smartest")')
|
|
2030
2029
|
expect(File.read(File.join(dir, "smartest/fixtures/playwright_fixture.rb"))).to include("class PlaywrightFixture < Smartest::Fixture")
|
|
2031
2030
|
expect(File.read(File.join(dir, "smartest/fixtures/playwright_fixture.rb"))).to include('require "playwright"')
|
|
2032
2031
|
expect(File.read(File.join(dir, "smartest/fixtures/playwright_fixture.rb"))).to include('playwright_cli_executable_path: "./node_modules/.bin/playwright"')
|
|
@@ -2044,13 +2043,49 @@ test("cli browser init generator creates Playwright scaffold and installation co
|
|
|
2044
2043
|
expect(commands).to eq(
|
|
2045
2044
|
[
|
|
2046
2045
|
[["bundle", "install"], dir],
|
|
2046
|
+
[["npm", "init", "--yes"], dir],
|
|
2047
2047
|
[["npm", "install", "playwright", "--save-dev"], dir],
|
|
2048
2048
|
[["./node_modules/.bin/playwright", "install"], dir]
|
|
2049
2049
|
]
|
|
2050
2050
|
)
|
|
2051
2051
|
expect(output.string).to include("run bundle install")
|
|
2052
|
+
expect(output.string).to include("run npm init --yes")
|
|
2052
2053
|
expect(output.string).to include("run npm install playwright --save-dev")
|
|
2053
2054
|
expect(output.string).to include("run ./node_modules/.bin/playwright install")
|
|
2054
|
-
expect(output.string).to include("Run your browser test suite with: bundle exec smartest smartest/
|
|
2055
|
+
expect(output.string).to include("Run your browser test suite with: bundle exec smartest smartest/example_browser_test.rb")
|
|
2056
|
+
end
|
|
2057
|
+
end
|
|
2058
|
+
|
|
2059
|
+
test("cli browser init generator skips npm init when package.json already exists") do
|
|
2060
|
+
Dir.mktmpdir do |dir|
|
|
2061
|
+
File.write(File.join(dir, "Gemfile"), <<~RUBY)
|
|
2062
|
+
source "https://rubygems.org"
|
|
2063
|
+
|
|
2064
|
+
gem "smartest"
|
|
2065
|
+
RUBY
|
|
2066
|
+
File.write(File.join(dir, "package.json"), "{\n \"name\": \"existing\"\n}\n")
|
|
2067
|
+
|
|
2068
|
+
commands = []
|
|
2069
|
+
output = StringIO.new
|
|
2070
|
+
generator = Smartest::InitBrowserGenerator.new(
|
|
2071
|
+
root: dir,
|
|
2072
|
+
output: output,
|
|
2073
|
+
command_runner: ->(command, chdir:) {
|
|
2074
|
+
commands << [command, chdir]
|
|
2075
|
+
true
|
|
2076
|
+
}
|
|
2077
|
+
)
|
|
2078
|
+
|
|
2079
|
+
status = generator.run
|
|
2080
|
+
|
|
2081
|
+
expect(status).to eq(0)
|
|
2082
|
+
expect(commands).to eq(
|
|
2083
|
+
[
|
|
2084
|
+
[["bundle", "install"], dir],
|
|
2085
|
+
[["npm", "install", "playwright", "--save-dev"], dir],
|
|
2086
|
+
[["./node_modules/.bin/playwright", "install"], dir]
|
|
2087
|
+
]
|
|
2088
|
+
)
|
|
2089
|
+
expect(output.string).not_to include("npm init --yes")
|
|
2055
2090
|
end
|
|
2056
2091
|
end
|