Skip to content

Commit

Permalink
using double
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Apr 5, 2018
1 parent d8ee1cb commit db9100a
Showing 1 changed file with 39 additions and 42 deletions.
81 changes: 39 additions & 42 deletions test/lib/inst_confirm_test.rb
Expand Up @@ -5,12 +5,14 @@

describe Yast::InstConfirmDialog do
subject(:confirm) { Yast::InstConfirmDialog.new }
let(:product_license) { double("Yast::ProductLicense",
AcceptanceNeeded: true, info_seen!: nil, ShowLicenseInInstallation: nil ) }

describe "#run" do
before do
allow(Yast::Pkg).to receive(:SourceGetCurrent).and_return([])
allow(Yast::ProductLicense).to receive(:info_seen!).with(0)
allow(Yast::Storage).to receive(:GetCommitInfos).and_return([{ destructive: true }])
allow(Yast::Storage).to receive(:GetCommitInfos).and_return([{:destructive => true}])
stub_const("Yast::ProductLicense", product_license)
end

context "installation mode" do
Expand All @@ -19,52 +21,47 @@
expect(Yast::Label).to receive(:InstallButton)
end

context "no license confirmation UI" do
it "returns true if the user clicks ok" do
expect(Yast::UI).to receive(:UserInput).and_return(:ok)
expect(confirm.run(false)).to eq(true)
end
context "no license confirmation UI" do
it "returns true if the user clicks ok" do
expect(Yast::UI).to receive(:UserInput).and_return(:ok)
expect(confirm.run(false)).to eq(true)
end

it "returns false if the user clicks abort" do
expect(Yast::UI).to receive(:UserInput).and_return(:abort)
expect(confirm.run(false)).to eq(false)
end
end

context "license confirmation UI" do
before do
expect(Yast::ProductLicense).to receive(:AcceptanceNeeded).and_return(true)
expect(Yast::ProductLicense).to receive(:ShowLicenseIInstallation).with(:base_license_rp,
0)
end
it "returns false if the user clicks abort" do
expect(Yast::UI).to receive(:UserInput).and_return(:abort)
expect(confirm.run(false)).to eq(false)
end
end

context "user clicks ok" do
before do
expect(Yast::UI).to receive(:UserInput).and_return(:ok)
end
context "license confirmation UI" do
context "user clicks ok" do
before do
expect(Yast::UI).to receive(:UserInput).and_return(:ok)
end

it "returns true if the user has accepted license" do
allow(Yast::InstData).to receive(:product_license_accepted).and_return(true)
expect(confirm.run(true)).to eq(true)
end
end
it "returns true if the user has accepted license" do
allow(Yast::InstData).to receive(:product_license_accepted).and_return(true)
expect(confirm.run(true)).to eq(true)
end
end

context "user clicks abort" do
before do
expect(Yast::UI).to receive(:UserInput).and_return(:abort)
end
context "user clicks abort" do
before do
expect(Yast::UI).to receive(:UserInput).and_return(:abort)
end

it "returns false if the user has not accepted license" do
allow(Yast::InstData).to receive(:product_license_accepted).and_return(false)
expect(confirm.run(true)).to eq(false)
end
it "returns false if the user has not accepted license" do
allow(Yast::InstData).to receive(:product_license_accepted).and_return(false)
expect(confirm.run(true)).to eq(false)
end

it "returns false even if the user has accepted license" do
allow(Yast::InstData).to receive(:product_license_accepted).and_return(true)
expect(confirm.run(true)).to eq(false)
end
end
end
it "returns false even if the user has accepted license" do
allow(Yast::InstData).to receive(:product_license_accepted).and_return(true)
expect(confirm.run(true)).to eq(false)
end
end
end

end

context "update mode" do
Expand Down

0 comments on commit db9100a

Please sign in to comment.