From e389e2c5cde394a61e43907a2a4b05933aba66c1 Mon Sep 17 00:00:00 2001 From: eregon Date: Mon, 26 Mar 2018 20:48:01 +0000 Subject: Update to ruby/mspec@8b54bf3 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/mspec/spec/matchers/include_any_of_spec.rb | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 spec/mspec/spec/matchers/include_any_of_spec.rb (limited to 'spec/mspec/spec') diff --git a/spec/mspec/spec/matchers/include_any_of_spec.rb b/spec/mspec/spec/matchers/include_any_of_spec.rb new file mode 100644 index 0000000000..697c8d8886 --- /dev/null +++ b/spec/mspec/spec/matchers/include_any_of_spec.rb @@ -0,0 +1,42 @@ +require 'spec_helper' +require 'mspec/expectations/expectations' +require 'mspec/matchers' + +describe IncludeAnyOfMatcher do + it "matches when actual includes expected" do + IncludeAnyOfMatcher.new(2).matches?([1,2,3]).should == true + IncludeAnyOfMatcher.new("b").matches?("abc").should == true + end + + it "does not match when actual does not include expected" do + IncludeAnyOfMatcher.new(4).matches?([1,2,3]).should == false + IncludeAnyOfMatcher.new("d").matches?("abc").should == false + end + + it "matches when actual includes all expected" do + IncludeAnyOfMatcher.new(3, 2, 1).matches?([1,2,3]).should == true + IncludeAnyOfMatcher.new("a", "b", "c").matches?("abc").should == true + end + + it "matches when actual includes any expected" do + IncludeAnyOfMatcher.new(3, 4, 5).matches?([1,2,3]).should == true + IncludeAnyOfMatcher.new("c", "d", "e").matches?("abc").should == true + end + + it "does not match when actual does not include any expected" do + IncludeAnyOfMatcher.new(4, 5).matches?([1,2,3]).should == false + IncludeAnyOfMatcher.new("de").matches?("abc").should == false + end + + it "provides a useful failure message" do + matcher = IncludeAnyOfMatcher.new(5, 6) + matcher.matches?([1,2,3]) + matcher.failure_message.should == ["Expected [1, 2, 3]", "to include any of [5, 6]"] + end + + it "provides a useful negative failure message" do + matcher = IncludeAnyOfMatcher.new(1, 2, 3) + matcher.matches?([1,2]) + matcher.negative_failure_message.should == ["Expected [1, 2]", "not to include any of [1, 2, 3]"] + end +end -- cgit v1.2.3