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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e868dca992d2695188debf897102cd76ed6374a25abcb0bbd8875414f9714f9e
4
- data.tar.gz: ecad80fbed7bc759ef3d30043b1fcdeb15202f3caa3a6e095b29e9d5ccf77e9c
3
+ metadata.gz: db491c5f3e52392c234291c174bbc1fff1bfb67d05a0ba23e50560529ea21d25
4
+ data.tar.gz: ae3f23d20992e0ec4e9cc4597fa15e346e52e1d2c31e482eab750d64942f8df1
5
5
  SHA512:
6
- metadata.gz: d13e0d7f4fe1056b99f367c08ea89424cfc86780a0d04754425098c7d9c9964f8abb675360a6fafd8c3e8db4fdb0e5f4b9d55890e2376dbf70391a2c3ddfac52
7
- data.tar.gz: dccb98cfda3cf96ffd888f3cea87cc8cfd9d27631da0ce66408c410fbf1b74fc74c7ea45461c48ffe1c29cca1895d96c7716884189fe4e689ea7175c4dd6e480
6
+ metadata.gz: d4964d2703dc893155e0d246843141221e75991c57eb93da21e3c1331c9d9d648f56cf32d88885d4f89fc6da07b3889215549c055c9986aeecd3ac9c43bde1d7
7
+ data.tar.gz: d4c944875e4ee763fa6b88c434e700afa63fd1c3380d392e2d18f589a3e6f15aae4c2c83a52ece118829b0b343581efbe8b4a9d982b291921715c4e72f553f31
@@ -20,7 +20,7 @@ jobs:
20
20
  node-version: '14'
21
21
  - name: Install ffmpeg
22
22
  run: |
23
- sudo apt install ffmpeg
23
+ sudo apt update && sudo apt install ffmpeg
24
24
  - name: Install dependencies
25
25
  run: |
26
26
  gem install bundler --no-document
data/Gemfile CHANGED
@@ -1,7 +1,8 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in videotest-recorder.gemspec
3
+ # Specify your gem's dependencies in test-recorder.gemspec
4
4
  gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
7
  gem "minitest", "~> 5.0"
8
+ gem "debug"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- test-recorder (0.1.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.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.9)
19
- i18n (1.8.11)
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
- minitest (5.14.2)
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.96.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
- ![CI](https://github.com/y-yagi/test-recorder/workflows/CI/badge.svg)
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 headless.
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
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "videotest/recorder"
4
+ require "test_recorder"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -4,7 +4,8 @@ module TestRecorder
4
4
  class CdpRecorder
5
5
  def initialize(enabled:)
6
6
  @enabled = enabled
7
- setup if @enabled
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
- return unless @enabled
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
- @counter = 1
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" % @counter
28
+ filename = "%010d.jpeg" % counter
27
29
  if Dir.exist?(@tmpdir)
28
30
  IO.binwrite("#{File.join(@tmpdir, filename)}", decoded_data)
29
- @counter += 1
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 !@enabled || @page.nil?
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: true)
8
- @cdp_recorder.start(page: page)
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(page: @example_group_instance.page)
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
@@ -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: true)
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)
@@ -1,3 +1,3 @@
1
1
  module TestRecorder
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/test_recorder.rb CHANGED
@@ -1 +1,17 @@
1
1
  require "test_recorder/version"
2
+
3
+ module TestRecorder
4
+ class << self
5
+ def enable!
6
+ @enable = true
7
+ end
8
+
9
+ def disable!
10
+ @enable = false
11
+ end
12
+
13
+ def enabled?
14
+ defined?(@enable) ? @enable : true
15
+ end
16
+ end
17
+ end
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "activesupport"
23
23
  spec.add_dependency "selenium-webdriver", ">= 4.0"
24
24
  spec.add_dependency "selenium-devtools"
25
+ spec.add_development_dependency "activesupport-testing-metadata"
25
26
  end
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.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-01-08 00:00:00.000000000 Z
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