Skip to content

Commit 4b49472

Browse files
committed
Move .startup to TestBase class
1 parent 7a62f14 commit 4b49472

File tree

3 files changed

+17
-32
lines changed

3 files changed

+17
-32
lines changed

bindings/ruby/tests/helper.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,21 @@
44

55
class TestBase < Test::Unit::TestCase
66
AUDIO = File.join(__dir__, "..", "..", "..", "samples", "jfk.wav")
7+
8+
class << self
9+
attr_reader :whisper
10+
11+
def startup
12+
@whisper = Whisper::Context.new("base.en")
13+
params = Whisper::Params.new
14+
params.print_timestamps = false
15+
@whisper.transcribe(TestBase::AUDIO, params)
16+
end
17+
end
18+
19+
private
20+
21+
def whisper
22+
self.class.whisper
23+
end
724
end

bindings/ruby/tests/test_segment.rb

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
require_relative "helper"
22

33
class TestSegment < TestBase
4-
class << self
5-
attr_reader :whisper
6-
7-
def startup
8-
@whisper = Whisper::Context.new("base.en")
9-
params = Whisper::Params.new
10-
params.print_timestamps = false
11-
@whisper.transcribe(TestBase::AUDIO, params)
12-
end
13-
end
14-
154
def test_iteration
165
whisper.each_segment do |segment|
176
assert_instance_of Whisper::Segment, segment
@@ -74,10 +63,4 @@ def test_on_new_segment_twice
7463
end
7564
whisper.transcribe(AUDIO, params)
7665
end
77-
78-
private
79-
80-
def whisper
81-
self.class.whisper
82-
end
8366
end

bindings/ruby/tests/test_whisper.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,6 @@ def test_whisper
2121
end
2222

2323
sub_test_case "After transcription" do
24-
class << self
25-
attr_reader :whisper
26-
27-
def startup
28-
@whisper = Whisper::Context.new("base.en")
29-
params = Whisper::Params.new
30-
params.print_timestamps = false
31-
@whisper.transcribe(TestBase::AUDIO, params)
32-
end
33-
end
34-
35-
def whisper
36-
self.class.whisper
37-
end
38-
3924
def test_full_n_segments
4025
assert_equal 1, whisper.full_n_segments
4126
end

0 commit comments

Comments
 (0)