Move Cask shared_examples to test/support.
This commit is contained in:
parent
f84ad9ca2e
commit
cc4fb35ae4
@ -1,4 +1,5 @@
|
|||||||
require "spec_helper"
|
require "spec_helper"
|
||||||
|
require "test/support/helper/spec/shared_examples/hbc_dsl_base"
|
||||||
|
|
||||||
describe Hbc::DSL::Caveats do
|
describe Hbc::DSL::Caveats do
|
||||||
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
|
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
require "spec_helper"
|
require "spec_helper"
|
||||||
|
require "test/support/helper/spec/shared_examples/hbc_dsl_base"
|
||||||
|
require "test/support/helper/spec/shared_examples/hbc_staged"
|
||||||
|
|
||||||
describe Hbc::DSL::Postflight do
|
describe Hbc::DSL::Postflight do
|
||||||
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
|
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
require "spec_helper"
|
require "spec_helper"
|
||||||
|
require "test/support/helper/spec/shared_examples/hbc_dsl_base"
|
||||||
|
require "test/support/helper/spec/shared_examples/hbc_staged"
|
||||||
|
|
||||||
describe Hbc::DSL::Preflight do
|
describe Hbc::DSL::Preflight do
|
||||||
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
|
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
require "spec_helper"
|
require "spec_helper"
|
||||||
|
require "test/support/helper/spec/shared_examples/hbc_dsl_base"
|
||||||
|
|
||||||
describe Hbc::DSL::UninstallPostflight do
|
describe Hbc::DSL::UninstallPostflight do
|
||||||
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
|
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
require "spec_helper"
|
require "spec_helper"
|
||||||
|
require "test/support/helper/spec/shared_examples/hbc_dsl_base"
|
||||||
|
require "test/support/helper/spec/shared_examples/hbc_staged"
|
||||||
|
|
||||||
describe Hbc::DSL::UninstallPreflight do
|
describe Hbc::DSL::UninstallPreflight do
|
||||||
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
|
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
|
||||||
|
|||||||
@ -1,21 +1,17 @@
|
|||||||
require "spec_helper"
|
|
||||||
|
|
||||||
require "hbc/staged"
|
require "hbc/staged"
|
||||||
|
|
||||||
shared_examples Hbc::Staged do
|
shared_examples Hbc::Staged do
|
||||||
let(:fake_pathname_exists) {
|
let(:existing_path) { Pathname.new("/path/to/file/that/exists") }
|
||||||
fake_pathname = Pathname.new("/path/to/file/that/exists")
|
let(:non_existent_path) { Pathname.new("/path/to/file/that/does/not/exist") }
|
||||||
allow(fake_pathname).to receive(:exist?).and_return(true)
|
|
||||||
allow(fake_pathname).to receive(:expand_path).and_return(fake_pathname)
|
|
||||||
fake_pathname
|
|
||||||
}
|
|
||||||
|
|
||||||
let(:fake_pathname_does_not_exist) {
|
before(:each) do
|
||||||
fake_pathname = Pathname.new("/path/to/file/that/does/not/exist")
|
allow(existing_path).to receive(:exist?).and_return(true)
|
||||||
allow(fake_pathname).to receive(:exist?).and_return(false)
|
allow(existing_path).to receive(:expand_path)
|
||||||
allow(fake_pathname).to receive(:expand_path).and_return(fake_pathname)
|
.and_return(existing_path)
|
||||||
fake_pathname
|
allow(non_existent_path).to receive(:exist?).and_return(false)
|
||||||
}
|
allow(non_existent_path).to receive(:expand_path)
|
||||||
|
.and_return(non_existent_path)
|
||||||
|
end
|
||||||
|
|
||||||
it "can run system commands with list-form arguments" do
|
it "can run system commands with list-form arguments" do
|
||||||
Hbc::FakeSystemCommand.expects_command(
|
Hbc::FakeSystemCommand.expects_command(
|
||||||
@ -56,7 +52,7 @@ shared_examples Hbc::Staged do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "can set the permissions of a file" do
|
it "can set the permissions of a file" do
|
||||||
fake_pathname = fake_pathname_exists
|
fake_pathname = existing_path
|
||||||
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
||||||
|
|
||||||
Hbc::FakeSystemCommand.expects_command(
|
Hbc::FakeSystemCommand.expects_command(
|
||||||
@ -69,7 +65,7 @@ shared_examples Hbc::Staged do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "can set the permissions of multiple files" do
|
it "can set the permissions of multiple files" do
|
||||||
fake_pathname = fake_pathname_exists
|
fake_pathname = existing_path
|
||||||
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
||||||
|
|
||||||
Hbc::FakeSystemCommand.expects_command(
|
Hbc::FakeSystemCommand.expects_command(
|
||||||
@ -82,13 +78,13 @@ shared_examples Hbc::Staged do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "cannot set the permissions of a file that does not exist" do
|
it "cannot set the permissions of a file that does not exist" do
|
||||||
fake_pathname = fake_pathname_does_not_exist
|
fake_pathname = non_existent_path
|
||||||
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
||||||
staged.set_permissions(fake_pathname.to_s, "777")
|
staged.set_permissions(fake_pathname.to_s, "777")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can set the ownership of a file" do
|
it "can set the ownership of a file" do
|
||||||
fake_pathname = fake_pathname_exists
|
fake_pathname = existing_path
|
||||||
|
|
||||||
allow(staged).to receive(:current_user).and_return("fake_user")
|
allow(staged).to receive(:current_user).and_return("fake_user")
|
||||||
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
||||||
@ -103,7 +99,7 @@ shared_examples Hbc::Staged do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "can set the ownership of multiple files" do
|
it "can set the ownership of multiple files" do
|
||||||
fake_pathname = fake_pathname_exists
|
fake_pathname = existing_path
|
||||||
|
|
||||||
allow(staged).to receive(:current_user).and_return("fake_user")
|
allow(staged).to receive(:current_user).and_return("fake_user")
|
||||||
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
||||||
@ -118,7 +114,7 @@ shared_examples Hbc::Staged do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "can set the ownership of a file with a different user and group" do
|
it "can set the ownership of a file with a different user and group" do
|
||||||
fake_pathname = fake_pathname_exists
|
fake_pathname = existing_path
|
||||||
|
|
||||||
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
||||||
|
|
||||||
@ -133,7 +129,7 @@ shared_examples Hbc::Staged do
|
|||||||
|
|
||||||
it "cannot set the ownership of a file that does not exist" do
|
it "cannot set the ownership of a file that does not exist" do
|
||||||
allow(staged).to receive(:current_user).and_return("fake_user")
|
allow(staged).to receive(:current_user).and_return("fake_user")
|
||||||
fake_pathname = fake_pathname_does_not_exist
|
fake_pathname = non_existent_path
|
||||||
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
||||||
|
|
||||||
shutup do
|
shutup do
|
||||||
Loading…
x
Reference in New Issue
Block a user