diff options
| author | Markus Reiter | 2017-02-18 22:17:32 +0100 |
|---|---|---|
| committer | Markus Reiter | 2017-02-18 22:18:36 +0100 |
| commit | 262f357d86f145fad3c78b3d843b32ac4e384f5e (patch) | |
| tree | 2f0f2825d9995d5c46e42585a9b44fc6c57e0dd0 /Library/Homebrew/test/compiler_failure_spec.rb | |
| parent | c4cb1dd5813e5a2413238593d00d4475d4ba1a73 (diff) | |
| download | brew-262f357d86f145fad3c78b3d843b32ac4e384f5e.tar.bz2 | |
Convert CompilerFailure test to spec.
Diffstat (limited to 'Library/Homebrew/test/compiler_failure_spec.rb')
| -rw-r--r-- | Library/Homebrew/test/compiler_failure_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Library/Homebrew/test/compiler_failure_spec.rb b/Library/Homebrew/test/compiler_failure_spec.rb new file mode 100644 index 000000000..81e464a87 --- /dev/null +++ b/Library/Homebrew/test/compiler_failure_spec.rb @@ -0,0 +1,41 @@ +require "compilers" + +describe CompilerFailure do + matcher :fail_with do |expected| + match do |actual| + actual.fails_with?(expected) + end + end + + describe "::create" do + it "creates a failure when given a symbol" do + failure = described_class.create(:clang) + expect(failure).to fail_with(double("Compiler", name: :clang, version: 425)) + end + + it "can be given a build number in a block" do + failure = described_class.create(:clang) { build 211 } + expect(failure).to fail_with(double("Compiler", name: :clang, version: 210)) + expect(failure).not_to fail_with(double("Compiler", name: :clang, version: 318)) + end + + it "can be given an empty block" do + failure = described_class.create(:clang) {} + expect(failure).to fail_with(double("Compiler", name: :clang, version: 425)) + end + + it "creates a failure when given a hash" do + failure = described_class.create(gcc: "4.8") + expect(failure).to fail_with(double("Compiler", name: "gcc-4.8", version: "4.8")) + expect(failure).to fail_with(double("Compiler", name: "gcc-4.8", version: "4.8.1")) + expect(failure).not_to fail_with(double("Compiler", name: "gcc-4.7", version: "4.7")) + end + + it "creates a failure when given a hash and a block with aversion" do + failure = described_class.create(gcc: "4.8") { version "4.8.1" } + expect(failure).to fail_with(double("Compiler", name: "gcc-4.8", version: "4.8")) + expect(failure).to fail_with(double("Compiler", name: "gcc-4.8", version: "4.8.1")) + expect(failure).not_to fail_with(double("Compiler", name: "gcc-4.8", version: "4.8.2")) + end + end +end |
