diff options
Diffstat (limited to 'spec/mspec/spec/matchers/base_spec.rb')
-rw-r--r-- | spec/mspec/spec/matchers/base_spec.rb | 140 |
1 files changed, 70 insertions, 70 deletions
diff --git a/spec/mspec/spec/matchers/base_spec.rb b/spec/mspec/spec/matchers/base_spec.rb index 762822bf09..6b5a3fbd72 100644 --- a/spec/mspec/spec/matchers/base_spec.rb +++ b/spec/mspec/spec/matchers/base_spec.rb @@ -3,11 +3,11 @@ require 'mspec/expectations/expectations' require 'mspec/matchers' require 'time' -describe SpecPositiveOperatorMatcher, "== operator" do +RSpec.describe SpecPositiveOperatorMatcher, "== operator" do it "provides a failure message that 'Expected x to equal y'" do - lambda { + expect { SpecPositiveOperatorMatcher.new(1) == 2 - }.should raise_error(SpecExpectationNotMetError, "Expected 1 == 2\nto be truthy but was false") + }.to raise_error(SpecExpectationNotMetError, "Expected 1 == 2\nto be truthy but was false") end it "does not raise an exception when == returns true" do @@ -15,11 +15,11 @@ describe SpecPositiveOperatorMatcher, "== operator" do end end -describe SpecPositiveOperatorMatcher, "=~ operator" do +RSpec.describe SpecPositiveOperatorMatcher, "=~ operator" do it "provides a failure message that 'Expected \"x\" to match y'" do - lambda { + expect { SpecPositiveOperatorMatcher.new('real') =~ /fake/ - }.should raise_error(SpecExpectationNotMetError, "Expected \"real\" =~ /fake/\nto be truthy but was nil") + }.to raise_error(SpecExpectationNotMetError, "Expected \"real\" =~ /fake/\nto be truthy but was nil") end it "does not raise an exception when =~ returns true" do @@ -27,11 +27,11 @@ describe SpecPositiveOperatorMatcher, "=~ operator" do end end -describe SpecPositiveOperatorMatcher, "> operator" do +RSpec.describe SpecPositiveOperatorMatcher, "> operator" do it "provides a failure message that 'Expected x to be greater than y'" do - lambda { + expect { SpecPositiveOperatorMatcher.new(4) > 5 - }.should raise_error(SpecExpectationNotMetError, "Expected 4 > 5\nto be truthy but was false") + }.to raise_error(SpecExpectationNotMetError, "Expected 4 > 5\nto be truthy but was false") end it "does not raise an exception when > returns true" do @@ -39,11 +39,11 @@ describe SpecPositiveOperatorMatcher, "> operator" do end end -describe SpecPositiveOperatorMatcher, ">= operator" do +RSpec.describe SpecPositiveOperatorMatcher, ">= operator" do it "provides a failure message that 'Expected x to be greater than or equal to y'" do - lambda { + expect { SpecPositiveOperatorMatcher.new(4) >= 5 - }.should raise_error(SpecExpectationNotMetError, "Expected 4 >= 5\nto be truthy but was false") + }.to raise_error(SpecExpectationNotMetError, "Expected 4 >= 5\nto be truthy but was false") end it "does not raise an exception when > returns true" do @@ -52,11 +52,11 @@ describe SpecPositiveOperatorMatcher, ">= operator" do end end -describe SpecPositiveOperatorMatcher, "< operator" do +RSpec.describe SpecPositiveOperatorMatcher, "< operator" do it "provides a failure message that 'Expected x to be less than y'" do - lambda { + expect { SpecPositiveOperatorMatcher.new(5) < 4 - }.should raise_error(SpecExpectationNotMetError, "Expected 5 < 4\nto be truthy but was false") + }.to raise_error(SpecExpectationNotMetError, "Expected 5 < 4\nto be truthy but was false") end it "does not raise an exception when < returns true" do @@ -64,11 +64,11 @@ describe SpecPositiveOperatorMatcher, "< operator" do end end -describe SpecPositiveOperatorMatcher, "<= operator" do +RSpec.describe SpecPositiveOperatorMatcher, "<= operator" do it "provides a failure message that 'Expected x to be less than or equal to y'" do - lambda { + expect { SpecPositiveOperatorMatcher.new(5) <= 4 - }.should raise_error(SpecExpectationNotMetError, "Expected 5 <= 4\nto be truthy but was false") + }.to raise_error(SpecExpectationNotMetError, "Expected 5 <= 4\nto be truthy but was false") end it "does not raise an exception when < returns true" do @@ -77,7 +77,7 @@ describe SpecPositiveOperatorMatcher, "<= operator" do end end -describe SpecPositiveOperatorMatcher, "arbitrary predicates" do +RSpec.describe SpecPositiveOperatorMatcher, "arbitrary predicates" do it "do not raise an exception when the predicate is truthy" do SpecPositiveOperatorMatcher.new(2).eql?(2) SpecPositiveOperatorMatcher.new(2).equal?(2) @@ -89,31 +89,31 @@ describe SpecPositiveOperatorMatcher, "arbitrary predicates" do end it "provide a failure message when the predicate returns a falsy value" do - lambda { + expect { SpecPositiveOperatorMatcher.new(2).eql?(3) - }.should raise_error(SpecExpectationNotMetError, "Expected 2.eql? 3\nto be truthy but was false") - lambda { + }.to raise_error(SpecExpectationNotMetError, "Expected 2.eql? 3\nto be truthy but was false") + expect { SpecPositiveOperatorMatcher.new(2).equal?(3) - }.should raise_error(SpecExpectationNotMetError, "Expected 2.equal? 3\nto be truthy but was false") - lambda { + }.to raise_error(SpecExpectationNotMetError, "Expected 2.equal? 3\nto be truthy but was false") + expect { SpecPositiveOperatorMatcher.new([1, 2, 3]).include?(4) - }.should raise_error(SpecExpectationNotMetError, "Expected [1, 2, 3].include? 4\nto be truthy but was false") - lambda { + }.to raise_error(SpecExpectationNotMetError, "Expected [1, 2, 3].include? 4\nto be truthy but was false") + expect { SpecPositiveOperatorMatcher.new("abc").start_with?("de") - }.should raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"de\"\nto be truthy but was false") - lambda { + }.to raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"de\"\nto be truthy but was false") + expect { SpecPositiveOperatorMatcher.new("abc").start_with?("d", "e") - }.should raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"d\", \"e\"\nto be truthy but was false") - lambda { + }.to raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"d\", \"e\"\nto be truthy but was false") + expect { SpecPositiveOperatorMatcher.new(2).odd? - }.should raise_error(SpecExpectationNotMetError, "Expected 2.odd?\nto be truthy but was false") - lambda { + }.to raise_error(SpecExpectationNotMetError, "Expected 2.odd?\nto be truthy but was false") + expect { SpecPositiveOperatorMatcher.new([1, 3]).any? { |e| e.even? } - }.should raise_error(SpecExpectationNotMetError, "Expected [1, 3].any? { ... }\nto be truthy but was false") + }.to raise_error(SpecExpectationNotMetError, "Expected [1, 3].any? { ... }\nto be truthy but was false") end end -describe SpecNegativeOperatorMatcher, "arbitrary predicates" do +RSpec.describe SpecNegativeOperatorMatcher, "arbitrary predicates" do it "do not raise an exception when the predicate returns a falsy value" do SpecNegativeOperatorMatcher.new(2).eql?(3) SpecNegativeOperatorMatcher.new(2).equal?(3) @@ -125,35 +125,35 @@ describe SpecNegativeOperatorMatcher, "arbitrary predicates" do end it "provide a failure message when the predicate returns a truthy value" do - lambda { + expect { SpecNegativeOperatorMatcher.new(2).eql?(2) - }.should raise_error(SpecExpectationNotMetError, "Expected 2.eql? 2\nto be falsy but was true") - lambda { + }.to raise_error(SpecExpectationNotMetError, "Expected 2.eql? 2\nto be falsy but was true") + expect { SpecNegativeOperatorMatcher.new(2).equal?(2) - }.should raise_error(SpecExpectationNotMetError, "Expected 2.equal? 2\nto be falsy but was true") - lambda { + }.to raise_error(SpecExpectationNotMetError, "Expected 2.equal? 2\nto be falsy but was true") + expect { SpecNegativeOperatorMatcher.new([1, 2, 3]).include?(2) - }.should raise_error(SpecExpectationNotMetError, "Expected [1, 2, 3].include? 2\nto be falsy but was true") - lambda { + }.to raise_error(SpecExpectationNotMetError, "Expected [1, 2, 3].include? 2\nto be falsy but was true") + expect { SpecNegativeOperatorMatcher.new("abc").start_with?("ab") - }.should raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"ab\"\nto be falsy but was true") - lambda { + }.to raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"ab\"\nto be falsy but was true") + expect { SpecNegativeOperatorMatcher.new("abc").start_with?("d", "a") - }.should raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"d\", \"a\"\nto be falsy but was true") - lambda { + }.to raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"d\", \"a\"\nto be falsy but was true") + expect { SpecNegativeOperatorMatcher.new(3).odd? - }.should raise_error(SpecExpectationNotMetError, "Expected 3.odd?\nto be falsy but was true") - lambda { + }.to raise_error(SpecExpectationNotMetError, "Expected 3.odd?\nto be falsy but was true") + expect { SpecNegativeOperatorMatcher.new([1, 2]).any? { |e| e.even? } - }.should raise_error(SpecExpectationNotMetError, "Expected [1, 2].any? { ... }\nto be falsy but was true") + }.to raise_error(SpecExpectationNotMetError, "Expected [1, 2].any? { ... }\nto be falsy but was true") end end -describe SpecNegativeOperatorMatcher, "== operator" do +RSpec.describe SpecNegativeOperatorMatcher, "== operator" do it "provides a failure message that 'Expected x not to equal y'" do - lambda { + expect { SpecNegativeOperatorMatcher.new(1) == 1 - }.should raise_error(SpecExpectationNotMetError, "Expected 1 == 1\nto be falsy but was true") + }.to raise_error(SpecExpectationNotMetError, "Expected 1 == 1\nto be falsy but was true") end it "does not raise an exception when == returns false" do @@ -161,11 +161,11 @@ describe SpecNegativeOperatorMatcher, "== operator" do end end -describe SpecNegativeOperatorMatcher, "=~ operator" do +RSpec.describe SpecNegativeOperatorMatcher, "=~ operator" do it "provides a failure message that 'Expected \"x\" not to match /y/'" do - lambda { + expect { SpecNegativeOperatorMatcher.new('real') =~ /real/ - }.should raise_error(SpecExpectationNotMetError, "Expected \"real\" =~ /real/\nto be falsy but was 0") + }.to raise_error(SpecExpectationNotMetError, "Expected \"real\" =~ /real/\nto be falsy but was 0") end it "does not raise an exception when =~ returns false" do @@ -173,11 +173,11 @@ describe SpecNegativeOperatorMatcher, "=~ operator" do end end -describe SpecNegativeOperatorMatcher, "< operator" do +RSpec.describe SpecNegativeOperatorMatcher, "< operator" do it "provides a failure message that 'Expected x not to be less than y'" do - lambda { + expect { SpecNegativeOperatorMatcher.new(4) < 5 - }.should raise_error(SpecExpectationNotMetError, "Expected 4 < 5\nto be falsy but was true") + }.to raise_error(SpecExpectationNotMetError, "Expected 4 < 5\nto be falsy but was true") end it "does not raise an exception when < returns false" do @@ -185,14 +185,14 @@ describe SpecNegativeOperatorMatcher, "< operator" do end end -describe SpecNegativeOperatorMatcher, "<= operator" do +RSpec.describe SpecNegativeOperatorMatcher, "<= operator" do it "provides a failure message that 'Expected x not to be less than or equal to y'" do - lambda { + expect { SpecNegativeOperatorMatcher.new(4) <= 5 - }.should raise_error(SpecExpectationNotMetError, "Expected 4 <= 5\nto be falsy but was true") - lambda { + }.to raise_error(SpecExpectationNotMetError, "Expected 4 <= 5\nto be falsy but was true") + expect { SpecNegativeOperatorMatcher.new(5) <= 5 - }.should raise_error(SpecExpectationNotMetError, "Expected 5 <= 5\nto be falsy but was true") + }.to raise_error(SpecExpectationNotMetError, "Expected 5 <= 5\nto be falsy but was true") end it "does not raise an exception when <= returns false" do @@ -200,11 +200,11 @@ describe SpecNegativeOperatorMatcher, "<= operator" do end end -describe SpecNegativeOperatorMatcher, "> operator" do +RSpec.describe SpecNegativeOperatorMatcher, "> operator" do it "provides a failure message that 'Expected x not to be greater than y'" do - lambda { + expect { SpecNegativeOperatorMatcher.new(5) > 4 - }.should raise_error(SpecExpectationNotMetError, "Expected 5 > 4\nto be falsy but was true") + }.to raise_error(SpecExpectationNotMetError, "Expected 5 > 4\nto be falsy but was true") end it "does not raise an exception when > returns false" do @@ -212,14 +212,14 @@ describe SpecNegativeOperatorMatcher, "> operator" do end end -describe SpecNegativeOperatorMatcher, ">= operator" do +RSpec.describe SpecNegativeOperatorMatcher, ">= operator" do it "provides a failure message that 'Expected x not to be greater than or equal to y'" do - lambda { + expect { SpecNegativeOperatorMatcher.new(5) >= 4 - }.should raise_error(SpecExpectationNotMetError, "Expected 5 >= 4\nto be falsy but was true") - lambda { + }.to raise_error(SpecExpectationNotMetError, "Expected 5 >= 4\nto be falsy but was true") + expect { SpecNegativeOperatorMatcher.new(5) >= 5 - }.should raise_error(SpecExpectationNotMetError, "Expected 5 >= 5\nto be falsy but was true") + }.to raise_error(SpecExpectationNotMetError, "Expected 5 >= 5\nto be falsy but was true") end it "does not raise an exception when >= returns false" do |