Merge pull request #826 from reitermarkus/rspec-syntax
Don’t use `should` syntax in rspec.
This commit is contained in:
commit
6409186ea9
@ -32,7 +32,7 @@ describe Hbc::Artifact::Binary do
|
|||||||
Hbc::Artifact::Binary.new(cask).install_phase
|
Hbc::Artifact::Binary.new(cask).install_phase
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(expected_path).to_not be :symlink?
|
expect(expected_path).not_to be :symlink?
|
||||||
end
|
end
|
||||||
|
|
||||||
it "clobbers an existing symlink" do
|
it "clobbers an existing symlink" do
|
||||||
|
@ -22,7 +22,7 @@ describe Hbc::Audit do
|
|||||||
audit.add_error "bad"
|
audit.add_error "bad"
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should match(%r{failed}) }
|
it { is_expected.to match(%r{failed}) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when there are warnings" do
|
context "when there are warnings" do
|
||||||
@ -30,7 +30,7 @@ describe Hbc::Audit do
|
|||||||
audit.add_warning "eh"
|
audit.add_warning "eh"
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should match(%r{warning}) }
|
it { is_expected.to match(%r{warning}) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when there are errors and warnings" do
|
context "when there are errors and warnings" do
|
||||||
@ -39,11 +39,11 @@ describe Hbc::Audit do
|
|||||||
audit.add_warning "eh"
|
audit.add_warning "eh"
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should match(%r{failed}) }
|
it { is_expected.to match(%r{failed}) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when there are no errors or warnings" do
|
context "when there are no errors or warnings" do
|
||||||
it { should match(%r{passed}) }
|
it { is_expected.to match(%r{passed}) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ describe Hbc::Audit do
|
|||||||
%w[version sha256 url name homepage license].each do |stanza|
|
%w[version sha256 url name homepage license].each do |stanza|
|
||||||
context "when missing #{stanza}" do
|
context "when missing #{stanza}" do
|
||||||
let(:cask_token) { "missing-#{stanza}" }
|
let(:cask_token) { "missing-#{stanza}" }
|
||||||
it { should fail_with(%r{#{stanza} stanza is required}) }
|
it { is_expected.to fail_with(%r{#{stanza} stanza is required}) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -65,7 +65,7 @@ describe Hbc::Audit do
|
|||||||
|
|
||||||
context "when version is 'latest'" do
|
context "when version is 'latest'" do
|
||||||
let(:cask_token) { "version-latest-string" }
|
let(:cask_token) { "version-latest-string" }
|
||||||
it { should fail_with(error_msg) }
|
it { is_expected.to fail_with(error_msg) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when version is :latest" do
|
context "when version is :latest" do
|
||||||
@ -77,34 +77,34 @@ describe Hbc::Audit do
|
|||||||
describe "sha256 checks" do
|
describe "sha256 checks" do
|
||||||
context "when version is :latest and sha256 is not :no_check" do
|
context "when version is :latest and sha256 is not :no_check" do
|
||||||
let(:cask_token) { "version-latest-with-checksum" }
|
let(:cask_token) { "version-latest-with-checksum" }
|
||||||
it { should fail_with("you should use sha256 :no_check when version is :latest") }
|
it { is_expected.to fail_with("you should use sha256 :no_check when version is :latest") }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when sha256 is not a legal SHA-256 digest" do
|
context "when sha256 is not a legal SHA-256 digest" do
|
||||||
let(:cask_token) { "invalid-sha256" }
|
let(:cask_token) { "invalid-sha256" }
|
||||||
it { should fail_with("sha256 string must be of 64 hexadecimal characters") }
|
it { is_expected.to fail_with("sha256 string must be of 64 hexadecimal characters") }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when sha256 is sha256 for empty string" do
|
context "when sha256 is sha256 for empty string" do
|
||||||
let(:cask_token) { "sha256-for-empty-string" }
|
let(:cask_token) { "sha256-for-empty-string" }
|
||||||
it { should fail_with(%r{cannot use the sha256 for an empty string}) }
|
it { is_expected.to fail_with(%r{cannot use the sha256 for an empty string}) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "appcast checks" do
|
describe "appcast checks" do
|
||||||
context "when appcast has no sha256" do
|
context "when appcast has no sha256" do
|
||||||
let(:cask_token) { "appcast-missing-checkpoint" }
|
let(:cask_token) { "appcast-missing-checkpoint" }
|
||||||
it { should fail_with(%r{checkpoint sha256 is required for appcast}) }
|
it { is_expected.to fail_with(%r{checkpoint sha256 is required for appcast}) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when appcast checkpoint is not a string of 64 hexadecimal characters" do
|
context "when appcast checkpoint is not a string of 64 hexadecimal characters" do
|
||||||
let(:cask_token) { "appcast-invalid-checkpoint" }
|
let(:cask_token) { "appcast-invalid-checkpoint" }
|
||||||
it { should fail_with(%r{string must be of 64 hexadecimal characters}) }
|
it { is_expected.to fail_with(%r{string must be of 64 hexadecimal characters}) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when appcast checkpoint is sha256 for empty string" do
|
context "when appcast checkpoint is sha256 for empty string" do
|
||||||
let(:cask_token) { "appcast-checkpoint-sha256-for-empty-string" }
|
let(:cask_token) { "appcast-checkpoint-sha256-for-empty-string" }
|
||||||
it { should fail_with(%r{cannot use the sha256 for an empty string}) }
|
it { is_expected.to fail_with(%r{cannot use the sha256 for an empty string}) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when appcast checkpoint is valid sha256" do
|
context "when appcast checkpoint is valid sha256" do
|
||||||
@ -139,7 +139,7 @@ describe Hbc::Audit do
|
|||||||
|
|
||||||
context "when HTTP code is not 200" do
|
context "when HTTP code is not 200" do
|
||||||
let(:stdout) { "404" }
|
let(:stdout) { "404" }
|
||||||
it { should warn_with(wrong_code_msg) }
|
it { is_expected.to warn_with(wrong_code_msg) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ describe Hbc::Audit do
|
|||||||
allow(fake_curl_result).to receive(:stderr).and_return("Some curl error")
|
allow(fake_curl_result).to receive(:stderr).and_return("Some curl error")
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should warn_with(curl_error_msg) }
|
it { is_expected.to warn_with(curl_error_msg) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ describe Hbc::Audit do
|
|||||||
|
|
||||||
context "when appcast checkpoint is out of date" do
|
context "when appcast checkpoint is out of date" do
|
||||||
let(:actual_checkpoint) { random_sha256 }
|
let(:actual_checkpoint) { random_sha256 }
|
||||||
it { should warn_with(mismatch_msg) }
|
it { is_expected.to warn_with(mismatch_msg) }
|
||||||
it { should_not warn_with(curl_error_msg) }
|
it { should_not warn_with(curl_error_msg) }
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ describe Hbc::Audit do
|
|||||||
allow(fake_curl_result).to receive(:stderr).and_return("Some curl error")
|
allow(fake_curl_result).to receive(:stderr).and_return("Some curl error")
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should warn_with(curl_error_msg) }
|
it { is_expected.to warn_with(curl_error_msg) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -209,7 +209,7 @@ describe Hbc::Audit do
|
|||||||
|
|
||||||
context "with incorrect SourceForge URL format" do
|
context "with incorrect SourceForge URL format" do
|
||||||
let(:cask_token) { "sourceforge-incorrect-url-format" }
|
let(:cask_token) { "sourceforge-incorrect-url-format" }
|
||||||
it { should warn_with(warning_msg) }
|
it { is_expected.to warn_with(warning_msg) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with correct SourceForge URL format" do
|
context "with correct SourceForge URL format" do
|
||||||
@ -224,7 +224,7 @@ describe Hbc::Audit do
|
|||||||
|
|
||||||
context "with incorrect OSDN URL format" do
|
context "with incorrect OSDN URL format" do
|
||||||
let(:cask_token) { "osdn-incorrect-url-format" }
|
let(:cask_token) { "osdn-incorrect-url-format" }
|
||||||
it { should warn_with(warning_msg) }
|
it { is_expected.to warn_with(warning_msg) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with correct OSDN URL format" do
|
context "with correct OSDN URL format" do
|
||||||
@ -236,12 +236,12 @@ describe Hbc::Audit do
|
|||||||
describe "generic artifact checks" do
|
describe "generic artifact checks" do
|
||||||
context "with no target" do
|
context "with no target" do
|
||||||
let(:cask_token) { "generic-artifact-no-target" }
|
let(:cask_token) { "generic-artifact-no-target" }
|
||||||
it { should fail_with(%r{target required for generic artifact}) }
|
it { is_expected.to fail_with(%r{target required for generic artifact}) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with relative target" do
|
context "with relative target" do
|
||||||
let(:cask_token) { "generic-artifact-relative-target" }
|
let(:cask_token) { "generic-artifact-relative-target" }
|
||||||
it { should fail_with(%r{target must be absolute path for generic artifact}) }
|
it { is_expected.to fail_with(%r{target must be absolute path for generic artifact}) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with absolute target" do
|
context "with absolute target" do
|
||||||
@ -256,7 +256,7 @@ describe Hbc::Audit do
|
|||||||
|
|
||||||
context "when loading the cask" do
|
context "when loading the cask" do
|
||||||
it "does not evaluate the block" do
|
it "does not evaluate the block" do
|
||||||
expect { cask }.to_not raise_error
|
expect { cask }.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ describe Hbc::Audit do
|
|||||||
|
|
||||||
context "when cask token conflicts with a core formula" do
|
context "when cask token conflicts with a core formula" do
|
||||||
let(:formula_names) { %w[with-binary other-formula] }
|
let(:formula_names) { %w[with-binary other-formula] }
|
||||||
it { should warn_with(%r{possible duplicate}) }
|
it { is_expected.to warn_with(%r{possible duplicate}) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when cask token does not conflict with a core formula" do
|
context "when cask token does not conflict with a core formula" do
|
||||||
@ -308,7 +308,7 @@ describe Hbc::Audit do
|
|||||||
download.expects(:perform).raises(StandardError.new(error_msg))
|
download.expects(:perform).raises(StandardError.new(error_msg))
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should fail_with(%r{#{error_msg}}) }
|
it { is_expected.to fail_with(%r{#{error_msg}}) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when verification fails" do
|
context "when verification fails" do
|
||||||
@ -317,7 +317,7 @@ describe Hbc::Audit do
|
|||||||
verify.expects(:all).raises(StandardError.new(error_msg))
|
verify.expects(:all).raises(StandardError.new(error_msg))
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should fail_with(%r{#{error_msg}}) }
|
it { is_expected.to fail_with(%r{#{error_msg}}) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ describe Hbc::Audit do
|
|||||||
cask.expects(:version).raises(StandardError.new)
|
cask.expects(:version).raises(StandardError.new)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should fail_with(%r{exception while auditing}) }
|
it { is_expected.to fail_with(%r{exception while auditing}) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -65,7 +65,7 @@ describe Hbc::CLI::Style do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "exits successfully" do
|
it "exits successfully" do
|
||||||
expect { subject }.to_not raise_error
|
expect { subject }.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -198,27 +198,27 @@ describe Hbc::CLI::Style do
|
|||||||
|
|
||||||
context "when --fix is passed as an argument" do
|
context "when --fix is passed as an argument" do
|
||||||
let(:args) { ["adium", "--fix"] }
|
let(:args) { ["adium", "--fix"] }
|
||||||
it { should be_truthy }
|
it { is_expected.to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when --correct is passed as an argument" do
|
context "when --correct is passed as an argument" do
|
||||||
let(:args) { ["adium", "--correct"] }
|
let(:args) { ["adium", "--correct"] }
|
||||||
it { should be_truthy }
|
it { is_expected.to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when --auto-correct is passed as an argument" do
|
context "when --auto-correct is passed as an argument" do
|
||||||
let(:args) { ["adium", "--auto-correct"] }
|
let(:args) { ["adium", "--auto-correct"] }
|
||||||
it { should be_truthy }
|
it { is_expected.to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when --auto-correct is misspelled as --autocorrect" do
|
context "when --auto-correct is misspelled as --autocorrect" do
|
||||||
let(:args) { ["adium", "--autocorrect"] }
|
let(:args) { ["adium", "--autocorrect"] }
|
||||||
it { should be_truthy }
|
it { is_expected.to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when no flag equivalent to --fix is passed as an argument" do
|
context "when no flag equivalent to --fix is passed as an argument" do
|
||||||
let(:args) { ["adium"] }
|
let(:args) { ["adium"] }
|
||||||
it { should be_falsey }
|
it { is_expected.to be_falsey }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -10,30 +10,30 @@ describe Hbc::DSL::Version do
|
|||||||
|
|
||||||
context "when other is nil" do
|
context "when other is nil" do
|
||||||
let(:other) { nil }
|
let(:other) { nil }
|
||||||
it { should == false }
|
it { is_expected.to be false }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when other is a String" do
|
context "when other is a String" do
|
||||||
context "when other == self.raw_version" do
|
context "when other == self.raw_version" do
|
||||||
let(:other) { "1.2.3" }
|
let(:other) { "1.2.3" }
|
||||||
it { should == true }
|
it { is_expected.to be true }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when other != self.raw_version" do
|
context "when other != self.raw_version" do
|
||||||
let(:other) { "1.2.3.4" }
|
let(:other) { "1.2.3.4" }
|
||||||
it { should == false }
|
it { is_expected.to be false }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when other is a #{described_class}" do
|
context "when other is a #{described_class}" do
|
||||||
context "when other.raw_version == self.raw_version" do
|
context "when other.raw_version == self.raw_version" do
|
||||||
let(:other) { described_class.new("1.2.3") }
|
let(:other) { described_class.new("1.2.3") }
|
||||||
it { should == true }
|
it { is_expected.to be true }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when other.raw_version != self.raw_version" do
|
context "when other.raw_version != self.raw_version" do
|
||||||
let(:other) { described_class.new("1.2.3.4") }
|
let(:other) { described_class.new("1.2.3.4") }
|
||||||
it { should == false }
|
it { is_expected.to be false }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -21,25 +21,25 @@ describe Hbc::Verify::Checksum do
|
|||||||
context "sha256 is :no_check" do
|
context "sha256 is :no_check" do
|
||||||
let(:sha256) { :no_check }
|
let(:sha256) { :no_check }
|
||||||
|
|
||||||
it { should == false }
|
it { is_expected.to be false }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "sha256 is nil" do
|
context "sha256 is nil" do
|
||||||
let(:sha256) { nil }
|
let(:sha256) { nil }
|
||||||
|
|
||||||
it { should == true }
|
it { is_expected.to be true }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "sha256 is empty" do
|
context "sha256 is empty" do
|
||||||
let(:sha256) { "" }
|
let(:sha256) { "" }
|
||||||
|
|
||||||
it { should == true }
|
it { is_expected.to be true }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "sha256 is a valid shasum" do
|
context "sha256 is a valid shasum" do
|
||||||
let(:sha256) { random_sha256 }
|
let(:sha256) { random_sha256 }
|
||||||
|
|
||||||
it { should == true }
|
it { is_expected.to be true }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ describe Hbc::Verify::Checksum do
|
|||||||
let(:sha256) { computed }
|
let(:sha256) { computed }
|
||||||
|
|
||||||
it "does not raise an error" do
|
it "does not raise an error" do
|
||||||
expect { subject }.to_not raise_error
|
expect { subject }.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ describe Hbc::Verify::Checksum do
|
|||||||
let(:sha256) { :no_check }
|
let(:sha256) { :no_check }
|
||||||
|
|
||||||
it "does not raise an error" do
|
it "does not raise an error" do
|
||||||
expect { subject }.to_not raise_error
|
expect { subject }.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ describe Hbc::Verify do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "excludes inapplicable verifications" do
|
it "excludes inapplicable verifications" do
|
||||||
expect(subject).to_not include(inapplicable_verification_class)
|
expect(subject).not_to include(inapplicable_verification_class)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ describe Hbc::Verify do
|
|||||||
|
|
||||||
it "runs only applicable verifications" do
|
it "runs only applicable verifications" do
|
||||||
expect(applicable_verification).to receive(:verify)
|
expect(applicable_verification).to receive(:verify)
|
||||||
expect(inapplicable_verification).to_not receive(:verify)
|
expect(inapplicable_verification).not_to receive(:verify)
|
||||||
subject
|
subject
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,7 +3,7 @@ module ExpectationsHashHelper
|
|||||||
expectations.each do |input_value, expected_output|
|
expectations.each do |input_value, expected_output|
|
||||||
context "when #{input_name} is #{input_value.inspect}" do
|
context "when #{input_name} is #{input_value.inspect}" do
|
||||||
let(input_name.to_sym) { input_value }
|
let(input_name.to_sym) { input_value }
|
||||||
it { should == expected_output }
|
it { is_expected.to eq expected_output }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user