diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-26 20:48:01 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-26 20:48:01 +0000 |
commit | e389e2c5cde394a61e43907a2a4b05933aba66c1 (patch) | |
tree | 9d815561e794b75d4ef4d1719624dbe2df10a9c4 /spec/mspec | |
parent | 587d882d911df4c2aa4645431e7f3eca081e83ec (diff) |
Update to ruby/mspec@8b54bf3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/mspec')
-rw-r--r-- | spec/mspec/lib/mspec/matchers.rb | 1 | ||||
-rw-r--r-- | spec/mspec/lib/mspec/matchers/include_any_of.rb | 29 | ||||
-rw-r--r-- | spec/mspec/spec/matchers/include_any_of_spec.rb | 42 | ||||
-rw-r--r-- | spec/mspec/tool/sync/sync-rubyspec.rb | 3 |
4 files changed, 73 insertions, 2 deletions
diff --git a/spec/mspec/lib/mspec/matchers.rb b/spec/mspec/lib/mspec/matchers.rb index 8eab73198a..f3e8e7bb73 100644 --- a/spec/mspec/lib/mspec/matchers.rb +++ b/spec/mspec/lib/mspec/matchers.rb @@ -25,6 +25,7 @@ require 'mspec/matchers/have_protected_instance_method' require 'mspec/matchers/have_public_instance_method' require 'mspec/matchers/have_singleton_method' require 'mspec/matchers/include' +require 'mspec/matchers/include_any_of' require 'mspec/matchers/infinity' require 'mspec/matchers/match_yaml' require 'mspec/matchers/raise_error' diff --git a/spec/mspec/lib/mspec/matchers/include_any_of.rb b/spec/mspec/lib/mspec/matchers/include_any_of.rb new file mode 100644 index 0000000000..ce097ccf0f --- /dev/null +++ b/spec/mspec/lib/mspec/matchers/include_any_of.rb @@ -0,0 +1,29 @@ +class IncludeAnyOfMatcher + def initialize(*expected) + @expected = expected + end + + def matches?(actual) + @actual = actual + @expected.each do |e| + if @actual.include?(e) + return true + end + end + return false + end + + def failure_message + ["Expected #{@actual.inspect}", "to include any of #{@expected.inspect}"] + end + + def negative_failure_message + ["Expected #{@actual.inspect}", "not to include any of #{@expected.inspect}"] + end +end + +module MSpecMatchers + private def include_any_of(*expected) + IncludeAnyOfMatcher.new(*expected) + end +end 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 diff --git a/spec/mspec/tool/sync/sync-rubyspec.rb b/spec/mspec/tool/sync/sync-rubyspec.rb index cee45c6262..13e9120b36 100644 --- a/spec/mspec/tool/sync/sync-rubyspec.rb +++ b/spec/mspec/tool/sync/sync-rubyspec.rb @@ -13,7 +13,6 @@ IMPLS = { mri: { git: "https://github.com/ruby/ruby.git", master: "trunk", - merge_message: "Update to ruby/spec@", }, } @@ -64,7 +63,7 @@ class RubyImplementation end def last_merge_message - message = @data[:merge_message] || "Merge ruby/spec commit" + message = @data[:merge_message] || "Update to ruby/spec@" message.gsub!("ruby/spec", "ruby/mspec") if MSPEC message end |