test-recorder 0.1.1 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/Gemfile +2 -1
- data/Gemfile.lock +18 -6
- data/README.md +49 -2
- data/bin/console +1 -1
- data/lib/test_recorder/cdp_recorder.rb +10 -8
- data/lib/test_recorder/rails/setup_and_teardown.rb +3 -4
- data/lib/test_recorder/rspec/example_wrapper.rb +4 -1
- data/lib/test_recorder/rspec.rb +1 -1
- data/lib/test_recorder/version.rb +1 -1
- data/lib/test_recorder.rb +16 -0
- data/test-recorder.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db491c5f3e52392c234291c174bbc1fff1bfb67d05a0ba23e50560529ea21d25
|
4
|
+
data.tar.gz: ae3f23d20992e0ec4e9cc4597fa15e346e52e1d2c31e482eab750d64942f8df1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4964d2703dc893155e0d246843141221e75991c57eb93da21e3c1331c9d9d648f56cf32d88885d4f89fc6da07b3889215549c055c9986aeecd3ac9c43bde1d7
|
7
|
+
data.tar.gz: d4c944875e4ee763fa6b88c434e700afa63fd1c3380d392e2d18f589a3e6f15aae4c2c83a52ece118829b0b343581efbe8b4a9d982b291921715c4e72f553f31
|
data/.github/workflows/ci.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
test-recorder (0.1.
|
4
|
+
test-recorder (0.1.4)
|
5
5
|
activesupport
|
6
6
|
selenium-devtools
|
7
7
|
selenium-webdriver (>= 4.0)
|
@@ -9,20 +9,30 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (7.0.
|
12
|
+
activesupport (7.0.3)
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
14
|
i18n (>= 1.6, < 2)
|
15
15
|
minitest (>= 5.1)
|
16
16
|
tzinfo (~> 2.0)
|
17
|
+
activesupport-testing-metadata (0.1.0)
|
18
|
+
activesupport (>= 4.0)
|
17
19
|
childprocess (4.1.0)
|
18
|
-
concurrent-ruby (1.1.
|
19
|
-
|
20
|
+
concurrent-ruby (1.1.10)
|
21
|
+
debug (1.5.0)
|
22
|
+
irb (>= 1.3.6)
|
23
|
+
reline (>= 0.2.7)
|
24
|
+
i18n (1.10.0)
|
20
25
|
concurrent-ruby (~> 1.0)
|
21
|
-
|
26
|
+
io-console (0.5.11)
|
27
|
+
irb (1.4.1)
|
28
|
+
reline (>= 0.3.0)
|
29
|
+
minitest (5.15.0)
|
22
30
|
rake (12.3.3)
|
31
|
+
reline (0.3.1)
|
32
|
+
io-console (~> 0.5)
|
23
33
|
rexml (3.2.5)
|
24
34
|
rubyzip (2.3.2)
|
25
|
-
selenium-devtools (0.
|
35
|
+
selenium-devtools (0.101.0)
|
26
36
|
websocket (~> 1.0)
|
27
37
|
selenium-webdriver (4.1.0)
|
28
38
|
childprocess (>= 0.5, < 5.0)
|
@@ -36,6 +46,8 @@ PLATFORMS
|
|
36
46
|
ruby
|
37
47
|
|
38
48
|
DEPENDENCIES
|
49
|
+
activesupport-testing-metadata
|
50
|
+
debug
|
39
51
|
minitest (~> 5.0)
|
40
52
|
rake (~> 12.0)
|
41
53
|
test-recorder!
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Record a video automatically when tests failed. The videos are generated in `tmp/videos` directory.
|
4
4
|
|
5
|
-
![
|
5
|
+
[![Build Status](https://github.com/y-yagi/test-recorder/workflows/CI/badge.svg)](https://github.com/y-yagi/test-recorder/actions)
|
6
6
|
[![Gem Version](https://badge.fury.io/rb/test-recorder.svg)](http://badge.fury.io/rb/test-recorder)
|
7
7
|
|
8
8
|
|
@@ -22,7 +22,7 @@ Rails system tests and RSpec(System Spec and Feature Spec).
|
|
22
22
|
|
23
23
|
## Limitations
|
24
24
|
|
25
|
-
Currently, this gem only supports a Chrome
|
25
|
+
Currently, this gem only supports a Headless Chrome.
|
26
26
|
|
27
27
|
## Usage
|
28
28
|
|
@@ -47,3 +47,50 @@ require 'test_recorder/rails'
|
|
47
47
|
```ruby
|
48
48
|
require 'test_recorder/rspec'
|
49
49
|
```
|
50
|
+
|
51
|
+
### Only record specific tests
|
52
|
+
|
53
|
+
`TestRecorder` records all tests by default. But if you want to limit the tests, you can do it by specifying metadata.
|
54
|
+
|
55
|
+
#### Rails
|
56
|
+
|
57
|
+
##### 1: Install the additional Gem
|
58
|
+
|
59
|
+
Using Bundler, add the following to your Gemfile:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
gem 'activesupport-testing-metadata', group: :test
|
63
|
+
```
|
64
|
+
|
65
|
+
##### 2. Disable `TestRecorder`, and specified tests with the tag
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
# test/test_helper.rb
|
69
|
+
require 'test_recorder/rails'
|
70
|
+
require 'active_support/testing/metadata'
|
71
|
+
|
72
|
+
TestRecorder.disable!
|
73
|
+
```
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
test "test to something", test_recorder: true do
|
77
|
+
# ...
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
81
|
+
#### RSpec
|
82
|
+
|
83
|
+
You don't need to install other gems. Only disable `TestRecorder`, and specified tests with the tag.
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
# test/test_helper.rb
|
87
|
+
require 'test_recorder/rspec'
|
88
|
+
|
89
|
+
TestRecorder.disable!
|
90
|
+
```
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
it "test to something", test_recorder: true do
|
94
|
+
# ...
|
95
|
+
end
|
96
|
+
|
data/bin/console
CHANGED
@@ -4,7 +4,8 @@ module TestRecorder
|
|
4
4
|
class CdpRecorder
|
5
5
|
def initialize(enabled:)
|
6
6
|
@enabled = enabled
|
7
|
-
|
7
|
+
@tmpdir = nil
|
8
|
+
setup
|
8
9
|
end
|
9
10
|
|
10
11
|
def setup
|
@@ -12,21 +13,22 @@ module TestRecorder
|
|
12
13
|
FileUtils.mkdir_p(@video_dir)
|
13
14
|
end
|
14
15
|
|
15
|
-
def start(page:)
|
16
|
-
|
16
|
+
def start(page:, enabled: nil)
|
17
|
+
enabled = @enabled if enabled.nil?
|
18
|
+
return unless enabled
|
17
19
|
|
18
20
|
@tmpdir = Dir.mktmpdir("testrecorder")
|
19
|
-
|
21
|
+
counter = 1
|
20
22
|
|
21
23
|
@page = page
|
22
24
|
@page.driver.browser.devtools.page.enable
|
23
25
|
|
24
26
|
@page.driver.browser.devtools.page.on(:screencast_frame) do |event|
|
25
27
|
decoded_data = Base64.decode64(event["data"])
|
26
|
-
filename = "%010d.jpeg" %
|
28
|
+
filename = "%010d.jpeg" % counter
|
27
29
|
if Dir.exist?(@tmpdir)
|
28
30
|
IO.binwrite("#{File.join(@tmpdir, filename)}", decoded_data)
|
29
|
-
|
31
|
+
counter += 1
|
30
32
|
end
|
31
33
|
@page.driver.browser.devtools.page.screencast_frame_ack(session_id: event["sessionId"])
|
32
34
|
end
|
@@ -35,11 +37,11 @@ module TestRecorder
|
|
35
37
|
end
|
36
38
|
|
37
39
|
def stop_and_discard
|
38
|
-
FileUtils.rm_rf(@tmpdir)
|
40
|
+
FileUtils.rm_rf(@tmpdir) unless @tmpdir.nil?
|
39
41
|
end
|
40
42
|
|
41
43
|
def stop_and_save(filename)
|
42
|
-
return if
|
44
|
+
return if @tmpdir.nil? || @page.nil?
|
43
45
|
|
44
46
|
@page.driver.browser.devtools.page.stop_screencast
|
45
47
|
video_path = File.join(@video_dir, filename)
|
@@ -1,11 +1,10 @@
|
|
1
|
-
require "fileutils"
|
2
|
-
|
3
1
|
module TestRecorder
|
4
2
|
module Rails
|
5
3
|
module SetupAndTeardown
|
6
4
|
def before_setup
|
7
|
-
@cdp_recorder = TestRecorder::CdpRecorder.new(enabled:
|
8
|
-
|
5
|
+
@cdp_recorder = TestRecorder::CdpRecorder.new(enabled: TestRecorder.enabled?)
|
6
|
+
enabled = respond_to?(:metadata) ? metadata[:test_recorder] : nil
|
7
|
+
@cdp_recorder.start(page: page, enabled: enabled)
|
9
8
|
|
10
9
|
super
|
11
10
|
end
|
@@ -3,7 +3,10 @@ module TestRecorder
|
|
3
3
|
module ExampleWrapper
|
4
4
|
def run_before_example
|
5
5
|
super
|
6
|
-
TestRecorder::RSpec.cdp_recorder.start(
|
6
|
+
TestRecorder::RSpec.cdp_recorder.start(
|
7
|
+
page: @example_group_instance.page,
|
8
|
+
enabled: self.metadata[:test_recorder]
|
9
|
+
)
|
7
10
|
end
|
8
11
|
end
|
9
12
|
end
|
data/lib/test_recorder/rspec.rb
CHANGED
@@ -29,7 +29,7 @@ end
|
|
29
29
|
RSpec::Core::Example.prepend(TestRecorder::RSpec::ExampleWrapper)
|
30
30
|
|
31
31
|
RSpec.configure do |config|
|
32
|
-
TestRecorder::RSpec.cdp_recorder = TestRecorder::CdpRecorder.new(enabled:
|
32
|
+
TestRecorder::RSpec.cdp_recorder = TestRecorder::CdpRecorder.new(enabled: TestRecorder.enabled?)
|
33
33
|
|
34
34
|
config.after(type: :system) do |example|
|
35
35
|
TestRecorder::RSpec.after_failed_example(example)
|
data/lib/test_recorder.rb
CHANGED
data/test-recorder.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-recorder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Yaginuma
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport-testing-metadata
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description:
|
56
70
|
email:
|
57
71
|
- yuuji.yaginuma@gmail.com
|