ruby-changes:50748
From: eregon <ko1@a...>
Date: Tue, 27 Mar 2018 05:48:07 +0900 (JST)
Subject: [ruby-changes:50748] eregon:r62929 (trunk): Update to ruby/mspec@8b54bf3
eregon 2018-03-27 05:48:01 +0900 (Tue, 27 Mar 2018) New Revision: 62929 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62929 Log: Update to ruby/mspec@8b54bf3 Added files: trunk/spec/mspec/lib/mspec/matchers/include_any_of.rb trunk/spec/mspec/spec/matchers/include_any_of_spec.rb Modified files: trunk/spec/mspec/lib/mspec/matchers.rb trunk/spec/mspec/tool/sync/sync-rubyspec.rb Index: spec/mspec/lib/mspec/matchers/include_any_of.rb =================================================================== --- spec/mspec/lib/mspec/matchers/include_any_of.rb (nonexistent) +++ spec/mspec/lib/mspec/matchers/include_any_of.rb (revision 62929) @@ -0,0 +1,29 @@ https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/matchers/include_any_of.rb#L1 +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 Index: spec/mspec/lib/mspec/matchers.rb =================================================================== --- spec/mspec/lib/mspec/matchers.rb (revision 62928) +++ spec/mspec/lib/mspec/matchers.rb (revision 62929) @@ -25,6 +25,7 @@ require 'mspec/matchers/have_protected_i https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/matchers.rb#L25 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' Index: spec/mspec/spec/matchers/include_any_of_spec.rb =================================================================== --- spec/mspec/spec/matchers/include_any_of_spec.rb (nonexistent) +++ spec/mspec/spec/matchers/include_any_of_spec.rb (revision 62929) @@ -0,0 +1,42 @@ https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/matchers/include_any_of_spec.rb#L1 +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 Index: spec/mspec/tool/sync/sync-rubyspec.rb =================================================================== --- spec/mspec/tool/sync/sync-rubyspec.rb (revision 62928) +++ spec/mspec/tool/sync/sync-rubyspec.rb (revision 62929) @@ -13,7 +13,6 @@ IMPLS = { https://github.com/ruby/ruby/blob/trunk/spec/mspec/tool/sync/sync-rubyspec.rb#L13 mri: { git: "https://github.com/ruby/ruby.git", master: "trunk", - merge_message: "Update to ruby/spec@", }, } @@ -64,7 +63,7 @@ class RubyImplementation https://github.com/ruby/ruby/blob/trunk/spec/mspec/tool/sync/sync-rubyspec.rb#L63 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/