Skip to content

Commit

Permalink
replace allow_any_instance
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Oct 30, 2023
1 parent c3932bc commit f563c2f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
16 changes: 6 additions & 10 deletions service/test/agama/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
describe Agama::Config do
let(:config) { described_class.new("web" => { "ssl" => "SOMETHING" }) }

before do
allow_any_instance_of(Agama::ProductReader).to receive(:load_products).and_return([])
end

describe ".load" do
before do
described_class.reset
Expand Down Expand Up @@ -91,7 +87,7 @@

describe "#products" do
it "returns products available for current hardware" do
allow_any_instance_of(Agama::ProductReader).to receive(:load_products).and_return(
allow(Agama::ProductReader).to receive(:new).and_return(double(load_products:
[
{
"id" => "test",
Expand All @@ -102,7 +98,7 @@
"archs" => "s390x"
}
]
)
))
expect(Yast2::ArchFilter).to receive(:from_string).twice.and_return(double(match?: true),
double(match?: false))
expect(subject.products.size).to eq 1
Expand All @@ -112,7 +108,7 @@
describe "#multi_product?" do
context "when more than one product is defined" do
before do
allow_any_instance_of(Agama::ProductReader).to receive(:load_products).and_call_original
allow(Agama::ProductReader).to receive(:new).and_call_original
end

it "returns true" do
Expand All @@ -122,10 +118,10 @@

context "when just one product is defined" do
before do
allow_any_instance_of(Agama::ProductReader).to receive(:load_products).and_call_original
allow(Agama::ProductReader).to receive(:new).and_call_original
products = Agama::ProductReader.new.load_products
allow_any_instance_of(Agama::ProductReader).to receive(:load_products)
.and_return([products.first])
allow(Agama::ProductReader).to receive(:new)
.and_return(double(load_products: [products.first]))
end

it "returns false" do
Expand Down
2 changes: 1 addition & 1 deletion service/test/agama/software/manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
allow(Agama::DBus::Clients::Questions).to receive(:new).and_return(questions_client)
allow(Agama::Software::RepositoriesManager).to receive(:new).and_return(repositories)
allow(Agama::Software::Proposal).to receive(:new).and_return(proposal)
allow_any_instance_of(Agama::ProductReader).to receive(:load_products).and_call_original
allow(Agama::ProductReader).to receive(:new).and_call_original
end

describe "#probe" do
Expand Down
3 changes: 2 additions & 1 deletion service/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def require(path)

RSpec.configure do |c|
c.before do
allow_any_instance_of(Agama::ProductReader).to receive(:load_products).and_return([])
allow(Agama::ProductReader).to receive(:new)
.and_return(double(load_products: []))
end
end

Expand Down

0 comments on commit f563c2f

Please sign in to comment.