Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Cask shared_examples to test/support. #2257

Merged
merged 1 commit into from Mar 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Library/Homebrew/cask/spec/cask/dsl/caveats_spec.rb
@@ -1,4 +1,5 @@
require "spec_helper"
require "test/support/helper/spec/shared_examples/hbc_dsl_base"

describe Hbc::DSL::Caveats do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/cask/spec/cask/dsl/postflight_spec.rb
@@ -1,4 +1,6 @@
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
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb
@@ -1,4 +1,6 @@
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
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
Expand Down
@@ -1,4 +1,5 @@
require "spec_helper"
require "test/support/helper/spec/shared_examples/hbc_dsl_base"

describe Hbc::DSL::UninstallPostflight do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
Expand Down
@@ -1,4 +1,6 @@
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
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
Expand Down
@@ -1,21 +1,17 @@
require "spec_helper"

require "hbc/staged"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reckon this should be in a cask directory as hbc isn't obviously relating to Cask.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reckon this should be in a cask directory as hbc isn't obviously relating to Cask.


shared_examples Hbc::Staged do
let(:fake_pathname_exists) {
fake_pathname = Pathname.new("/path/to/file/that/exists")
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) {
fake_pathname = Pathname.new("/path/to/file/that/does/not/exist")
allow(fake_pathname).to receive(:exist?).and_return(false)
allow(fake_pathname).to receive(:expand_path).and_return(fake_pathname)
fake_pathname
}
let(:existing_path) { Pathname.new("/path/to/file/that/exists") }
let(:non_existent_path) { Pathname.new("/path/to/file/that/does/not/exist") }

before(:each) do
allow(existing_path).to receive(:exist?).and_return(true)
allow(existing_path).to receive(:expand_path)
.and_return(existing_path)
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
Hbc::FakeSystemCommand.expects_command(
Expand Down Expand Up @@ -56,7 +52,7 @@
end

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)

Hbc::FakeSystemCommand.expects_command(
Expand All @@ -69,7 +65,7 @@
end

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)

Hbc::FakeSystemCommand.expects_command(
Expand All @@ -82,13 +78,13 @@
end

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)
staged.set_permissions(fake_pathname.to_s, "777")
end

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(:Pathname).and_return(fake_pathname)
Expand All @@ -103,7 +99,7 @@
end

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(:Pathname).and_return(fake_pathname)
Expand All @@ -118,7 +114,7 @@
end

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)

Expand All @@ -133,7 +129,7 @@

it "cannot set the ownership of a file that does not exist" do
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)

shutup do
Expand Down