videotest-recorder 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cac55b6b89fe0824e50877cb215b84d9089d973f109441e1083dc93ce1f36c58
4
+ data.tar.gz: eb429c8a9c1270d54a56b2f9c4e2e7606901a19795fc70e7be1156912461a324
5
+ SHA512:
6
+ metadata.gz: 796c60ffff57208ec08a740939fe50cffcedfc2d9b23aff29f72d9a076e99160871d1c9c2c607ce596f5665c34933d87f19d0dacd201c0499678e6a228cfdb85
7
+ data.tar.gz: e6f82e714c82fbfcc883f57bd4cadd8cfeb80eaf16ec4dbf2d6ffece8400aba206e16493049a64be1af50ff94aca2f9bcc83a40c2e78883a72f7075bbdb15260
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in videotest-recorder.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "minitest", "~> 5.0"
@@ -0,0 +1,75 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ videotest-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
+ videotest-recorder!
73
+
74
+ BUNDLED WITH
75
+ 2.1.4
@@ -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.
@@ -0,0 +1,3 @@
1
+ # Videotest::Recorder
2
+
3
+ :hammer_and_pick: WIP :hammer_and_pick:
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.verbose = true
8
+ t.warning = true
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ task :default => :test
@@ -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__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1 @@
1
+ require "videotest/recorder/version"
@@ -0,0 +1,5 @@
1
+ require "videotest/recorder/rails/setup_and_teardown"
2
+
3
+ ActiveSupport.on_load(:action_dispatch_system_test_case) do
4
+ include Videotest::Recorder::Rails::SetupAndTeardown
5
+ end
@@ -0,0 +1,36 @@
1
+ require "headless"
2
+ require "fileutils"
3
+
4
+ module Videotest
5
+ module Recorder
6
+ module Rails
7
+ module SetupAndTeardown
8
+ attr_reader :video_dir, :headless
9
+
10
+ def before_setup
11
+ @video_dir = ::Rails.root.join("tmp", "videos")
12
+ FileUtils.mkdir_p(video_dir)
13
+
14
+ # TODO: Allow configuring parameters.
15
+ @headless = Headless.new(video: { provider: :ffmpeg, codec: :libx264, extra: %w(-preset ultrafast) })
16
+ headless.start
17
+ headless.video.start_capture
18
+
19
+ super
20
+ end
21
+
22
+ def before_teardown
23
+ if failures.empty?
24
+ headless.video.stop_and_discard
25
+ else
26
+ video = video_dir.join("failures_#{self.name}.mp4")
27
+ headless.video.stop_and_save(video)
28
+ puts "[Video]: #{video}"
29
+ end
30
+ ensure
31
+ super
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,47 @@
1
+ require "headless"
2
+ require "fileutils"
3
+
4
+ module Videotest
5
+ module Recorder
6
+ module Rspec
7
+ CHARS_TO_TRANSLATE = ['/', '.', ':', ',', "'", '"', " "].freeze
8
+
9
+ class << self
10
+ attr_accessor :headless, :video_dir
11
+
12
+ def after_failed_example(example)
13
+ if example.exception
14
+ video = video_dir.join("failures_#{method_name(example)}.mp4")
15
+ headless.video.stop_and_save(video)
16
+ example.metadata[:extra_failure_lines] = [example.metadata[:extra_failure_lines], "[Video]: #{video}"]
17
+ else
18
+ headless.video.stop_and_discard
19
+ end
20
+ end
21
+
22
+ def method_name(example)
23
+ example.description.underscore.tr(CHARS_TO_TRANSLATE.join, "_")[0...200] + "_#{rand(1000)}"
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ RSpec.configure do |config|
31
+ config.before do
32
+ Videotest::Recorder::Rspec.video_dir = ::Rails.root.join("tmp", "videos")
33
+ FileUtils.mkdir_p(Videotest::Recorder::Rspec.video_dir)
34
+
35
+ Videotest::Recorder::Rspec.headless = Headless.new(video: { provider: :ffmpeg, codec: :libx264, extra: %w(-preset ultrafast) })
36
+ Videotest::Recorder::Rspec.headless.start
37
+ Videotest::Recorder::Rspec.headless.video.start_capture
38
+ end
39
+
40
+ config.after(type: :system) do |example|
41
+ Videotest::Recorder::Rspec.after_failed_example(example)
42
+ end
43
+
44
+ config.after(type: :feature) do |example|
45
+ Videotest::Recorder::Rspec.after_failed_example(example)
46
+ end
47
+ end
@@ -0,0 +1,5 @@
1
+ module Videotest
2
+ module Recorder
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ require_relative 'lib/videotest/recorder/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "videotest-recorder"
5
+ spec.version = Videotest::Recorder::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/videotest-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,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: videotest-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/videotest/recorder.rb
57
+ - lib/videotest/recorder/rails.rb
58
+ - lib/videotest/recorder/rails/setup_and_teardown.rb
59
+ - lib/videotest/recorder/rspec.rb
60
+ - lib/videotest/recorder/version.rb
61
+ - videotest-recorder.gemspec
62
+ homepage: http://github.com/y-yagi/videotest-recorder
63
+ licenses:
64
+ - MIT
65
+ metadata:
66
+ homepage_uri: http://github.com/y-yagi/videotest-recorder
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 2.3.0
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubygems_version: 3.1.2
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Automatically record videos when tests failed.
86
+ test_files: []