Return keys are really nice.

They make code more readable by visually separating different sections
of text.

Signed-off-by: Ryan Davis <zenspider@chef.io>
This commit is contained in:
Ryan Davis 2019-07-18 01:43:08 -07:00
parent d3df69213b
commit 7de549577c

View file

@ -4,6 +4,7 @@ require "inspec/resources/file"
describe Inspec::Resources::FileResource do
let(:file) { stub(unix_mode_mask: 000, mode: 000) }
it "responds on Ubuntu" do
resource = MockLoader.new(:ubuntu1404).load_resource("file", "/fakepath/fakefile")
resource.stubs(:exist?).returns(true)
@ -18,6 +19,7 @@ describe Inspec::Resources::FileResource do
resource.stubs(:file_permission_granted?).with("read", "by_usergroup", "by_specific_user").returns("test_result")
resource.stubs(:file_permission_granted?).with("write", "by_usergroup", "by_specific_user").returns("test_result")
resource.stubs(:file_permission_granted?).with("execute", "by_usergroup", "by_specific_user").returns("test_result")
_(resource.content).must_equal "content"
_(resource.more_permissive_than?("000")).must_equal false
_(resource.exist?).must_equal true
@ -35,6 +37,7 @@ describe Inspec::Resources::FileResource do
proc { resource.send(:more_permissive_than?, nil) }.must_raise(ArgumentError)
proc { resource.send(:more_permissive_than?, 0700) }.must_raise(ArgumentError)
end
it "responds on Windows" do
resource = MockLoader.new(:windows).load_resource("file", "C:/fakepath/fakefile")
resource.stubs(:exist?).returns(true)
@ -55,12 +58,14 @@ describe Inspec::Resources::FileResource do
_(resource.allowed?("execute", by: "by_usergroup", by_user: "by_specific_user")).must_equal "test_result"
_(resource.allowed?("full-control", by: "by_usergroup", by_user: "by_specific_user")).must_equal "test_result"
end
it "does not support Windows-style ACL on Ubuntu" do
resource = MockLoader.new(:ubuntu1404).load_resource("file", "/fakepath/fakefile")
resource.stubs(:exist?).returns(true)
proc { resource.send("allowed?", "full-control", { by: "by_usergroup", by_user: "by_specific_user" }) }.must_raise(RuntimeError)
proc { resource.send("allowed?", "modify", { by: "by_usergroup", by_user: "by_specific_user" }) }.must_raise(RuntimeError)
end
it "does not support check by mask on Windows" do
resource = MockLoader.new(:windows).load_resource("file", "C:/fakepath/fakefile")
resource.stubs(:exist?).returns(true)
@ -68,6 +73,7 @@ describe Inspec::Resources::FileResource do
proc { resource.send("writable?", "by_usergroup", nil) }.must_raise(RuntimeError)
proc { resource.send("executable?", "by_usergroup", nil) }.must_raise(RuntimeError)
end
it "responds with errors on unsupported OS" do
resource = MockLoader.new(:undefined).load_resource("file", "C:/fakepath/fakefile")
resource.stubs(:exist?).returns(true)