Skip to content

Commit

Permalink
WIP: Improve test example
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdavid committed Jan 22, 2019
1 parent 56fe647 commit 19a1375
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions test/lib/y2firewall/clients/auto_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,9 @@
describe "#change" do
let(:result) { :ok }
let(:already_read) { false }
let(:exported_profile) { double("Exported Profile") }
let(:main_dialog) { instance_double("Dialog::Main", run: result) }

before do
allow(subject).to receive(:import)
allow(subject).to receive(:export).and_return(exported_profile)
allow(Y2Firewall::Dialogs::Main).to receive(:new).and_return(main_dialog)
allow(firewalld).to receive(:read?).and_return(already_read)
end
Expand Down Expand Up @@ -287,18 +284,31 @@
end

context "but its configuration has not been read" do
let(:example_zone) do
{ "name" => "example", "services" => ["http", "https", "ssh"] }
end

let(:imported_zones) do
{
"zones" => [example_zone]
}
end

before do
allow(subject).to receive(:autoyast).and_call_original
subject.import(imported_zones, false)
end

it "reads the minimal configuration" do
expect(firewalld).to receive(:read).with(minimal: true)

subject.change
end

it "keeps the previous configuration" do
expect(subject).to receive(:export)
expect(firewalld).to receive(:reset)
expect(subject).to receive(:import).with(exported_profile, false)

it "keeps the configuration previously imported" do
subject.change

expect(subject.export["zones"]).to include(hash_including(example_zone))
end
end
end
Expand Down

0 comments on commit 19a1375

Please sign in to comment.