Skip to content

Commit

Permalink
make the tests simpler - remove contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Apr 18, 2014
1 parent ab12fda commit 3f1af5e
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions test/sw_mgmt_spec.rb
Expand Up @@ -104,26 +104,16 @@
expect(credentials).to receive(:write)
end

context "service does not exist yet" do
before do
expect(yast_pkg).to receive(:ServiceAliases).and_return([])
end

it "creates a new service" do
expect(yast_pkg).to receive(:ServiceAdd).with("test", service_url).and_return(true)
expect { Registration::SwMgmt.add_services([product_services], credentials) }.to_not raise_error
end
it "it creates a new service if the service does not exist yet" do
expect(yast_pkg).to receive(:ServiceAliases).and_return([])
expect(yast_pkg).to receive(:ServiceAdd).with("test", service_url).and_return(true)
expect { Registration::SwMgmt.add_services([product_services], credentials) }.to_not raise_error
end

context "service already exists" do
before do
expect(yast_pkg).to receive(:ServiceAliases).and_return(["test"])
end

it "updates the existing service" do
expect(yast_pkg).to receive(:ServiceSet).with("test", hash_including("url" => service_url)).and_return(true)
expect { Registration::SwMgmt.add_services([product_services], credentials) }.to_not raise_error
end
it "updates the existing service if the service already exists" do
expect(yast_pkg).to receive(:ServiceAliases).and_return(["test"])
expect(yast_pkg).to receive(:ServiceSet).with("test", hash_including("url" => service_url)).and_return(true)
expect { Registration::SwMgmt.add_services([product_services], credentials) }.to_not raise_error
end
end

Expand Down

0 comments on commit 3f1af5e

Please sign in to comment.