Skip to content

Commit

Permalink
Changes based on code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Oct 3, 2017
1 parent f80e4c5 commit fe78401
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
27 changes: 13 additions & 14 deletions test/host_test.rb
Expand Up @@ -11,7 +11,7 @@

describe Yast::Host do
let(:file) do
file_path = File.expand_path("../data/hosts", __FILE__)
file_path = File.join(DATA_PATH, "hosts")
CFA::MemoryFile.new(File.read(file_path))
end

Expand Down Expand Up @@ -116,7 +116,7 @@

describe ".Import" do
let(:file) do
file_path = File.expand_path("../data/default_hosts", __FILE__)
file_path = File.join(DATA_PATH, "default_hosts")
CFA::MemoryFile.new(File.read(file_path))
end

Expand Down Expand Up @@ -147,7 +147,7 @@

describe ".Export" do
let(:file) do
file_path = File.expand_path("../data/default_hosts", __FILE__)
file_path = File.join(DATA_PATH, "default_hosts")
CFA::MemoryFile.new(File.read(file_path))
end

Expand Down Expand Up @@ -314,9 +314,9 @@
end

it "sets Host as modified" do
expect(Yast::Host.GetModified).to eql(false)
Yast::Host.EnsureHostnameResolvable
expect(Yast::Host.GetModified).to eql(true)
expect { Yast::Host.EnsureHostnameResolvable }
.to change { Yast::Host.GetModified }
.from(false).to(true)
end
end

Expand All @@ -337,25 +337,24 @@
end

it "sets Host as modified" do
expect(Yast::Host.GetModified).to eql(false)
Yast::Host.EnsureHostnameResolvable
expect(Yast::Host.GetModified).to eql(true)
expect { Yast::Host.EnsureHostnameResolvable }
.to change { Yast::Host.GetModified }
.from(false).to(true)
end
end
end

context "and /etc/hosts does not contains 127.0.0.2 entry" do
let(:file) do
file_path = File.expand_path("../data/default_hosts", __FILE__)
file_path = File.join(DATA_PATH, "default_hosts")
CFA::MemoryFile.new(File.read(file_path))
end

it "doest not set Host as modified" do
it "does not set Host as modified" do
allow(Yast::DNS).to receive(:write_hostname).and_return(false)

expect(Yast::Host.GetModified).to eql(false)
Yast::Host.EnsureHostnameResolvable
expect(Yast::Host.GetModified).to eql(false)
expect { Yast::Host.EnsureHostnameResolvable }
.not_to change { Yast::Host.GetModified }.from(false)
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions test/test_helper.rb
Expand Up @@ -16,6 +16,8 @@
c.include SCRStub
end

DATA_PATH = File.join(File.expand_path(File.dirname(__FILE__)), "data")

# stub module to prevent its Import
# Useful for modules from different yast packages, to avoid build dependencies
def stub_module(name)
Expand Down

0 comments on commit fe78401

Please sign in to comment.