Skip to content

Commit

Permalink
convert FtpServer test to rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Sep 20, 2016
1 parent cff97f0 commit 07bb3fe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 33 deletions.
26 changes: 16 additions & 10 deletions test/ftpserver_test.rb
Expand Up @@ -67,30 +67,36 @@ def mock_config(config_path, map)
}

describe "Yast::FtpServer" do
describe ".Modified" do
it "returns false if no modification happens"
expect(Yast::FtpServer.ValueUI("VerboseLogging", false)).to eq false
end
end

describe ".ValueUI" do
context "'VerboseLogging' when getting vsftpd settings" do
before do
Yast::FtpServer.vsftpd_edit = true
end

it "returns default value 'YES' if 'log_ftp_protocol' missing in config file" do
mock_config(VS_CONFIG_PATH, VS_SETTINGS)
Yast::FtpServer.ReadVSFTPDSettings()

expect(Yast::FtpServer.ValueUI("VerboseLogging", false)).to eql "YES"
end

it "returns value from config file 'NO' if 'log_ftp_protocol = NO' in config file" do
mock_config(VS_CONFIG_PATH, VS_SETTINGS.merge("log_ftp_protocol" => "NO"))
Yast::FtpServer.ReadVSFTPDSettings()

expect(Yast::FtpServer.ValueUI("VerboseLogging", false)).to eql "NO"
end

it "returns value from config file 'YES' if 'log_ftp_protocol = YES' in config file" do
mock_config(VS_CONFIG_PATH, VS_SETTINGS.merge("log_ftp_protocol" => "YES"))
Yast::FtpServer.ReadVSFTPDSettings()

expect(Yast::FtpServer.ValueUI("VerboseLogging", false)).to eql "YES"
end
end
Expand All @@ -99,25 +105,25 @@ def mock_config(config_path, map)
before do
Yast::FtpServer.vsftpd_edit = false
end

it "returns default value 'NO' if config file empty" do
mock_config(PURE_CONFIG_PATH, {})
Yast::FtpServer.ReadPUREFTPDSettings()

expect(Yast::FtpServer.ValueUI("VerboseLogging", false)).to eql "NO"
end

it "returns value from config file 'NO' if 'VerboseLog = no' in config file" do
mock_config(PURE_CONFIG_PATH, PURE_SETTINGS)
Yast::FtpServer.ReadPUREFTPDSettings()

expect(Yast::FtpServer.ValueUI("VerboseLogging", false)).to eql "NO"
end

it "returns value from config file 'YES' if 'VerboseLog = yes' in config file" do
mock_config(PURE_CONFIG_PATH, PURE_SETTINGS.merge("VerboseLog" => "YES"))
Yast::FtpServer.ReadPUREFTPDSettings()

expect(Yast::FtpServer.ValueUI("VerboseLogging", false)).to eql "YES"
end
end
Expand Down
Empty file removed testsuite/tests/FtpServer.err
Empty file.
2 changes: 0 additions & 2 deletions testsuite/tests/FtpServer.out

This file was deleted.

21 changes: 0 additions & 21 deletions testsuite/tests/FtpServer.rb

This file was deleted.

0 comments on commit 07bb3fe

Please sign in to comment.