From a480c60963f256216c283fb14ac7971384f92575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Alejandro=20Anderssen=20Gonz=C3=A1lez?= Date: Wed, 6 Apr 2016 09:12:40 +0100 Subject: [PATCH] Fix some mocks. --- test/inst_disks_activate_test.rb | 59 +++++++++++++++++--------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/test/inst_disks_activate_test.rb b/test/inst_disks_activate_test.rb index 3081e92ed..65ac04b4b 100755 --- a/test/inst_disks_activate_test.rb +++ b/test/inst_disks_activate_test.rb @@ -10,21 +10,25 @@ Yast.import "GetInstArgs" Yast.import "UI" Yast.import "Popup" + Yast.import "Storage" describe "#main" do let(:probed_disks) { [] } + let(:s390) { false } before do allow(Yast::Linuxrc).to receive(:InstallInf).with("WithFCoE").and_return("0") allow(Yast::UI).to receive(:OpenDialog) allow(Yast::UI).to receive(:CloseDialog) allow(Yast::Popup).to receive(:ConfirmAbort).with(:painless).and_return(true) + allow(Yast::Arch).to receive(:s390).and_return(s390) + allow(Yast::Storage).to receive(:ReReadTargetMap) end context "when architecture is s390" do + let(:s390) { true } before do allow(Yast::UI).to receive(:UserInput).and_return(:abort) - allow(Yast::Arch).to receive(:s390).and_return(true) end it "detects DASD disks" do @@ -46,45 +50,44 @@ expect(subject.main).to eq(:abort) end + end - context "when dasd button is clicked" do - before do - allow(Yast::UI).to receive(:UserInput).and_return(:dasd, :abort) - end + context "when dasd button is clicked" do + before do + allow(Yast::UI).to receive(:UserInput).and_return(:dasd, :abort) + end - it "calls inst_dasd client" do - expect(Yast::WFM).to receive(:call).with("inst_dasd") - expect(subject).to receive(:show_base_dialog).twice + it "calls inst_dasd client" do + expect(Yast::WFM).to receive(:call).with("inst_dasd") + expect(subject).to receive(:show_base_dialog).twice - subject.main - end + subject.main end + end - context "when network button is clicked" do - before do - allow(Yast::UI).to receive(:UserInput).and_return(:network, :abort) - end + context "when network button is clicked" do + before do + allow(Yast::UI).to receive(:UserInput).and_return(:network, :abort) + end - it "calls inst_lan client" do - expect(Yast::WFM).to receive(:call).with("inst_lan", ["skip_detection" => true]) - expect(subject).to receive(:show_base_dialog).twice + it "calls inst_lan client" do + expect(Yast::WFM).to receive(:call).with("inst_lan", ["skip_detection" => true]) + expect(subject).to receive(:show_base_dialog).twice - subject.main - end + subject.main end + end - context "when abort button is clicked" do - before do - allow(Yast::UI).to receive(:UserInput).and_return(:abort) - end + context "when abort button is clicked" do + before do + allow(Yast::UI).to receive(:UserInput).and_return(:abort) + end - it "returns :abort" do - expect(subject).to receive(:show_base_dialog).once + it "returns :abort" do + expect(subject).to receive(:show_base_dialog).once - expect(subject.main).to eq(:abort) - end + expect(subject.main).to eq(:abort) end - end end end