Skip to content

Commit

Permalink
Fix some mocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Apr 6, 2016
1 parent 11a6bdb commit a480c60
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions test/inst_disks_activate_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit a480c60

Please sign in to comment.