test-recorder 0.1.1 → 0.1.2

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: 77e11d42cdce42863b8b7d991d61c8b864c82ee82a17458532cd31cb7aafd9f2
4
+ data.tar.gz: 5bae5ab5fc6a7ab032989af8bd6729a0e2e4f9d241b5d8f945d6f1cdf7e0315c
5
5
  SHA512:
6
- metadata.gz: d13e0d7f4fe1056b99f367c08ea89424cfc86780a0d04754425098c7d9c9964f8abb675360a6fafd8c3e8db4fdb0e5f4b9d55890e2376dbf70391a2c3ddfac52
7
- data.tar.gz: dccb98cfda3cf96ffd888f3cea87cc8cfd9d27631da0ce66408c410fbf1b74fc74c7ea45461c48ffe1c29cca1895d96c7716884189fe4e689ea7175c4dd6e480
6
+ metadata.gz: be418cf8a5badd4f717bdc9f6c3f9928aeb756e960151508709b20a0685dcb6ffa285e5f5bc1dbf5a1e922fceabe349b40643cbe337e55e9b1cf04039dcd1932
7
+ data.tar.gz: 6366982b9bf6f65011fc9a7854f32af57975ac0d7d811b20b6d7bd4a443709ce254e75dcd699a93e7005bc8020dbf60a0d4abe75327269c2153f11084adaa95f
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,28 +1,39 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- test-recorder (0.1.1)
4
+ test-recorder (0.1.2)
5
5
  activesupport
6
+ activesupport-testing-metadata
6
7
  selenium-devtools
7
8
  selenium-webdriver (>= 4.0)
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
- activesupport (7.0.0)
13
+ activesupport (7.0.1)
13
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
15
  i18n (>= 1.6, < 2)
15
16
  minitest (>= 5.1)
16
17
  tzinfo (~> 2.0)
18
+ activesupport-testing-metadata (0.1.0)
19
+ activesupport (>= 4.0)
17
20
  childprocess (4.1.0)
18
21
  concurrent-ruby (1.1.9)
22
+ debug (1.4.0)
23
+ irb (>= 1.3.6)
24
+ reline (>= 0.2.7)
19
25
  i18n (1.8.11)
20
26
  concurrent-ruby (~> 1.0)
27
+ io-console (0.5.11)
28
+ irb (1.4.1)
29
+ reline (>= 0.3.0)
21
30
  minitest (5.14.2)
22
31
  rake (12.3.3)
32
+ reline (0.3.1)
33
+ io-console (~> 0.5)
23
34
  rexml (3.2.5)
24
35
  rubyzip (2.3.2)
25
- selenium-devtools (0.96.0)
36
+ selenium-devtools (0.97.0)
26
37
  websocket (~> 1.0)
27
38
  selenium-webdriver (4.1.0)
28
39
  childprocess (>= 0.5, < 5.0)
@@ -36,6 +47,7 @@ PLATFORMS
36
47
  ruby
37
48
 
38
49
  DEPENDENCIES
50
+ debug
39
51
  minitest (~> 5.0)
40
52
  rake (~> 12.0)
41
53
  test-recorder!
data/README.md CHANGED
@@ -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,38 @@ 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
+ ```ruby
58
+ # test/test_helper.rb
59
+ require 'test_recorder/rails'
60
+ require 'active_support/testing/metadata'
61
+
62
+ TestRecorder.disable!
63
+ ```
64
+
65
+ ```ruby
66
+ test "test to something", test_recorder: true do
67
+ # ...
68
+ end
69
+ ```
70
+
71
+ #### RSpec
72
+
73
+ ```ruby
74
+ # test/test_helper.rb
75
+ require 'test_recorder/rspec'
76
+
77
+ TestRecorder.disable!
78
+ ```
79
+
80
+ ```ruby
81
+ it "test to something", test_recorder: true do
82
+ # ...
83
+ end
84
+
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,8 +13,9 @@ 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
21
  @counter = 1
@@ -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)
@@ -4,8 +4,9 @@ module TestRecorder
4
4
  module Rails
5
5
  module SetupAndTeardown
6
6
  def before_setup
7
- @cdp_recorder = TestRecorder::CdpRecorder.new(enabled: true)
8
- @cdp_recorder.start(page: page)
7
+
8
+ @cdp_recorder = TestRecorder::CdpRecorder.new(enabled: TestRecorder.enabled?)
9
+ @cdp_recorder.start(page: page, enabled: metadata[:test_recorder])
9
10
 
10
11
  super
11
12
  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.2"
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
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
  spec.add_dependency "activesupport"
23
+ spec.add_dependency "activesupport-testing-metadata"
23
24
  spec.add_dependency "selenium-webdriver", ">= 4.0"
24
25
  spec.add_dependency "selenium-devtools"
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.2
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-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport-testing-metadata
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'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: selenium-webdriver
29
43
  requirement: !ruby/object:Gem::Requirement