diff --git a/lib/rubyripper/cli/cliDisc.rb b/lib/rubyripper/cli/cliDisc.rb index bb96f40..42eb465 100644 --- a/lib/rubyripper/cli/cliDisc.rb +++ b/lib/rubyripper/cli/cliDisc.rb @@ -57,8 +57,11 @@ def tracks private def discReady? ; @cd.status == 'ok' ; end - # read the disc contents - def refreshDisc ; @cd.scan() ; end + # read the disc contents. Recreate Disc to get fresh scanner & calculator state. + def refreshDisc + @cd = Disc.new() + @cd.scan() + end # show the contents of the audio disc def showDisc diff --git a/spec/cli/cliDisc_spec.rb b/spec/cli/cliDisc_spec.rb new file mode 100644 index 0000000..2459354 --- /dev/null +++ b/spec/cli/cliDisc_spec.rb @@ -0,0 +1,46 @@ +#!/usr/bin/env ruby +# RubyRipperRemix - A secure ripper for Linux/BSD/OSX +# Copyright (C) 2026 Masterisk-F +# +# This file is part of RubyRipperRemix. RubyRipperRemix is free software: you can +# redistribute it and/or modify it under the terms of the GNU General +# Public License as published by the Free Software Foundation, either +# version 3 of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see + +require 'rubyripper/cli/cliDisc' + +describe CliDisc do + let(:out) {StringIO.new} + let(:int) {double('CliGetInt').as_null_object} + let(:bool) {double('CliGetBool').as_null_object} + let(:string) {double('CliGetString').as_null_object} + let(:prefs) {double('Preferences::Main').as_null_object} + + def setup_cli_disc + CliDisc.new(out, int, bool, string, prefs) + end + + context "When refreshing the disc" do + it "should create a new Disc instance on refresh" do + first_disc = double('Disc').as_null_object + second_disc = double('Disc').as_null_object + + expect(Disc).to receive(:new).and_return(first_disc, second_disc) + + cli_disc = setup_cli_disc + expect(cli_disc.cd).to eq(first_disc) + + expect(second_disc).to receive(:scan) + cli_disc.send(:refreshDisc) + expect(cli_disc.cd).to eq(second_disc) + end + end +end diff --git a/spec/disc/scanDiscCdparanoia_spec.rb b/spec/disc/scanDiscCdparanoia_spec.rb index cca6d82..ab0d647 100644 --- a/spec/disc/scanDiscCdparanoia_spec.rb +++ b/spec/disc/scanDiscCdparanoia_spec.rb @@ -22,7 +22,7 @@ def setQueryReply(reply, command=nil) allow(prefs).to receive('testdisc').and_return false command ||= 'cd-paranoia -d /dev/cdrom -vQ' - allow(exec).to receive(:launch).with(command).and_return reply + allow(exec).to receive(:launch).with(command, false, nil, any_args).and_return reply end let(:exec) {double('Execute').as_null_object}