test-recorder 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +75 -0
- data/LICENSE.txt +21 -0
- data/README.md +3 -0
- data/Rakefile +12 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/test-recorder.rb +1 -0
- data/lib/test_recorder.rb +1 -0
- data/lib/test_recorder/rails.rb +5 -0
- data/lib/test_recorder/rails/setup_and_teardown.rb +34 -0
- data/lib/test_recorder/rspec.rb +45 -0
- data/lib/test_recorder/version.rb +3 -0
- data/test-recorder.gemspec +24 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 745f47568a578d0d76e8558dc16fd6277045cd86dca6a09f38b4914b90e09775
|
4
|
+
data.tar.gz: 9ec908cb4e136d8137d5304c77594fd0d88e81070ff5b086198035e5cdef1d39
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f3962a434f3c98a2dfdd9840cf60205795cc175a18b34d2eb3dd66f6c1ec43603f9b6bd53cc0970811e1cfd6cb54149bdef3db2858173db72769f75a191b750e
|
7
|
+
data.tar.gz: 97b93c654e9125cf0732c803e49808d4fb6a72402827307708cd52853d21def581843c9d8da877b027206d322cebae31a9efab655f28617212adfc4e299152f2
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
test-recorder (0.1.0)
|
5
|
+
headless
|
6
|
+
railties
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionpack (6.0.3.4)
|
12
|
+
actionview (= 6.0.3.4)
|
13
|
+
activesupport (= 6.0.3.4)
|
14
|
+
rack (~> 2.0, >= 2.0.8)
|
15
|
+
rack-test (>= 0.6.3)
|
16
|
+
rails-dom-testing (~> 2.0)
|
17
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
18
|
+
actionview (6.0.3.4)
|
19
|
+
activesupport (= 6.0.3.4)
|
20
|
+
builder (~> 3.1)
|
21
|
+
erubi (~> 1.4)
|
22
|
+
rails-dom-testing (~> 2.0)
|
23
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
24
|
+
activesupport (6.0.3.4)
|
25
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
|
+
i18n (>= 0.7, < 2)
|
27
|
+
minitest (~> 5.1)
|
28
|
+
tzinfo (~> 1.1)
|
29
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
30
|
+
builder (3.2.4)
|
31
|
+
concurrent-ruby (1.1.7)
|
32
|
+
crass (1.0.6)
|
33
|
+
erubi (1.9.0)
|
34
|
+
headless (2.3.1)
|
35
|
+
i18n (1.8.5)
|
36
|
+
concurrent-ruby (~> 1.0)
|
37
|
+
loofah (2.7.0)
|
38
|
+
crass (~> 1.0.2)
|
39
|
+
nokogiri (>= 1.5.9)
|
40
|
+
method_source (1.0.0)
|
41
|
+
mini_portile2 (2.4.0)
|
42
|
+
minitest (5.14.2)
|
43
|
+
nokogiri (1.10.10)
|
44
|
+
mini_portile2 (~> 2.4.0)
|
45
|
+
rack (2.2.3)
|
46
|
+
rack-test (1.1.0)
|
47
|
+
rack (>= 1.0, < 3)
|
48
|
+
rails-dom-testing (2.0.3)
|
49
|
+
activesupport (>= 4.2.0)
|
50
|
+
nokogiri (>= 1.6)
|
51
|
+
rails-html-sanitizer (1.3.0)
|
52
|
+
loofah (~> 2.3)
|
53
|
+
railties (6.0.3.4)
|
54
|
+
actionpack (= 6.0.3.4)
|
55
|
+
activesupport (= 6.0.3.4)
|
56
|
+
method_source
|
57
|
+
rake (>= 0.8.7)
|
58
|
+
thor (>= 0.20.3, < 2.0)
|
59
|
+
rake (12.3.3)
|
60
|
+
thor (1.0.1)
|
61
|
+
thread_safe (0.3.6)
|
62
|
+
tzinfo (1.2.7)
|
63
|
+
thread_safe (~> 0.1)
|
64
|
+
zeitwerk (2.4.0)
|
65
|
+
|
66
|
+
PLATFORMS
|
67
|
+
ruby
|
68
|
+
|
69
|
+
DEPENDENCIES
|
70
|
+
minitest (~> 5.0)
|
71
|
+
rake (~> 12.0)
|
72
|
+
test-recorder!
|
73
|
+
|
74
|
+
BUNDLED WITH
|
75
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 yuuji.yaginuma
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "videotest/recorder"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "test_recorder"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "test_recorder/version"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "headless"
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
module TestRecorder
|
5
|
+
module Rails
|
6
|
+
module SetupAndTeardown
|
7
|
+
attr_reader :video_dir, :headless
|
8
|
+
|
9
|
+
def before_setup
|
10
|
+
@video_dir = ::Rails.root.join("tmp", "videos")
|
11
|
+
FileUtils.mkdir_p(video_dir)
|
12
|
+
|
13
|
+
# TODO: Allow configuring parameters.
|
14
|
+
@headless = Headless.new(video: { provider: :ffmpeg, codec: :libx264, extra: %w(-preset ultrafast) })
|
15
|
+
headless.start
|
16
|
+
headless.video.start_capture
|
17
|
+
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def before_teardown
|
22
|
+
if failures.empty?
|
23
|
+
headless.video.stop_and_discard
|
24
|
+
else
|
25
|
+
video = video_dir.join("failures_#{self.name}.mp4")
|
26
|
+
headless.video.stop_and_save(video)
|
27
|
+
puts "[Video]: #{video}"
|
28
|
+
end
|
29
|
+
ensure
|
30
|
+
super
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "headless"
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
module TestRecorder
|
5
|
+
module Rspec
|
6
|
+
CHARS_TO_TRANSLATE = ['/', '.', ':', ',', "'", '"', " "].freeze
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_accessor :headless, :video_dir
|
10
|
+
|
11
|
+
def after_failed_example(example)
|
12
|
+
if example.exception
|
13
|
+
video = video_dir.join("failures_#{method_name(example)}.mp4")
|
14
|
+
headless.video.stop_and_save(video)
|
15
|
+
example.metadata[:extra_failure_lines] = [example.metadata[:extra_failure_lines], "[Video]: #{video}"]
|
16
|
+
else
|
17
|
+
headless.video.stop_and_discard
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_name(example)
|
22
|
+
example.description.underscore.tr(CHARS_TO_TRANSLATE.join, "_")[0...200] + "_#{rand(1000)}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
RSpec.configure do |config|
|
29
|
+
config.before do
|
30
|
+
TestRecorder::Rspec.video_dir = ::Rails.root.join("tmp", "videos")
|
31
|
+
FileUtils.mkdir_p(TestRecorder::Rspec.video_dir)
|
32
|
+
|
33
|
+
TestRecorder::Rspec.headless = Headless.new(video: { provider: :ffmpeg, codec: :libx264, extra: %w(-preset ultrafast) })
|
34
|
+
TestRecorder::Rspec.headless.start
|
35
|
+
TestRecorder::Rspec.headless.video.start_capture
|
36
|
+
end
|
37
|
+
|
38
|
+
config.after(type: :system) do |example|
|
39
|
+
TestRecorder::Rspec.after_failed_example(example)
|
40
|
+
end
|
41
|
+
|
42
|
+
config.after(type: :feature) do |example|
|
43
|
+
TestRecorder::Rspec.after_failed_example(example)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'lib/test_recorder/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "test-recorder"
|
5
|
+
spec.version = TestRecorder::VERSION
|
6
|
+
spec.authors = ["Yuji Yaginuma"]
|
7
|
+
spec.email = ["yuuji.yaginuma@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{Automatically record videos when tests failed.}
|
10
|
+
spec.homepage = "http://github.com/y-yagi/test-recorder"
|
11
|
+
spec.license = "MIT"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
+
|
14
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
15
|
+
|
16
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
17
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
spec.add_dependency "headless"
|
23
|
+
spec.add_dependency "railties"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: test-recorder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yuji Yaginuma
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-10-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: headless
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: railties
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- yuuji.yaginuma@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- lib/test-recorder.rb
|
57
|
+
- lib/test_recorder.rb
|
58
|
+
- lib/test_recorder/rails.rb
|
59
|
+
- lib/test_recorder/rails/setup_and_teardown.rb
|
60
|
+
- lib/test_recorder/rspec.rb
|
61
|
+
- lib/test_recorder/version.rb
|
62
|
+
- test-recorder.gemspec
|
63
|
+
homepage: http://github.com/y-yagi/test-recorder
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata:
|
67
|
+
homepage_uri: http://github.com/y-yagi/test-recorder
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 2.3.0
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubygems_version: 3.1.2
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: Automatically record videos when tests failed.
|
87
|
+
test_files: []
|