Hello community, here is the log from the commit of package rubygem-rspec-expectations for openSUSE:Factory checked in at 2016-07-16 22:11:24 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-rspec-expectations (Old) and /work/SRC/openSUSE:Factory/.rubygem-rspec-expectations.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-rspec-expectations" Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-rspec-expectations/rubygem-rspec-expectations.changes 2015-12-01 10:02:15.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-rspec-expectations.new/rubygem-rspec-expectations.changes 2016-07-16 22:11:27.000000000 +0200 @@ -1,0 +2,61 @@ +Sat Jul 2 05:21:54 UTC 2016 - coolo@suse.com + +- updated to version 3.5.0 + see installed Changelog.md + + ### 3.5.0 / 2016-07-01 + [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.5.0.beta4...v3.5.0) + + **No user facing changes since beta4** + + ### 3.5.0.beta4 / 2016-06-05 + [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.5.0.beta3...v3.5.0.beta4) + + Bug Fixes: + + * Fix `include` matcher so that it provides a valid diff for hashes. (Yuji Nakayama, #916) + + ### 3.5.0.beta3 / 2016-04-02 + [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.5.0.beta2...v3.5.0.beta3) + + Enhancements: + + * Make `rspec/expectations/minitest_integration` work on Minitest::Spec + 5.6+. (Myron Marston, #904) + * Add an alias `having_attributes` for `have_attributes` matcher. + (Yuji Nakayama, #905) + * Improve `change` matcher error message when block is mis-used. + (Alex Altair, #908) + + ### 3.5.0.beta2 / 2016-03-10 + [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.5.0.beta1...v3.5.0.beta2) + + Enhancements: + + * Add the ability to raise an error on encountering false positives via + `RSpec::Configuration#on_potential_false_positives = :raise`. (Jon Rowe, #900) + * When using the custom matcher DSL, support new + `notify_expectation_failures: true` option for the `match` method to + allow expectation failures to be raised as normal instead of being + converted into a `false` return value for `matches?`. (Jon Rowe, #892) + + Bug Fixes: + + * Allow `should` deprecation check to work on `BasicObject`s. (James Coleman, #898) + + ### 3.5.0.beta1 / 2016-02-06 + [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.4.0...v3.5.0.beta1) + + Enhancements: + + * Make `match_when_negated` in custom matcher DSL support use of + expectations within the match logic. (Chris Arcand, #789) + + Bug Fixes: + + * Return `true` as expected from passing negated expectations + (such as `expect("foo").not_to eq "bar"`), so they work + properly when used within a `match` or `match_when_negated` + block. (Chris Arcand, #789) + +------------------------------------------------------------------- Old: ---- rspec-expectations-3.4.0.gem New: ---- rspec-expectations-3.5.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-rspec-expectations.spec ++++++ --- /var/tmp/diff_new_pack.cOtBDb/_old 2016-07-16 22:11:27.000000000 +0200 +++ /var/tmp/diff_new_pack.cOtBDb/_new 2016-07-16 22:11:27.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-rspec-expectations # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ # Name: rubygem-rspec-expectations -Version: 3.4.0 +Version: 3.5.0 Release: 0 %define mod_name rspec-expectations %define mod_full_name %{mod_name}-%{version} @@ -33,7 +33,7 @@ BuildRequires: %{rubygem gem2rpm} BuildRequires: %{rubygem rdoc > 3.10} BuildRequires: ruby-macros >= 5 -Url: http://github.com/rspec/rspec-expectations +Url: https://github.com/rspec/rspec-expectations Source: http://rubygems.org/gems/%{mod_full_name}.gem Source1: gem2rpm.yml Summary: API to express expected outcomes of a code example ++++++ rspec-expectations-3.4.0.gem -> rspec-expectations-3.5.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Changelog.md new/Changelog.md --- old/Changelog.md 2015-11-12 08:48:14.000000000 +0100 +++ new/Changelog.md 2016-07-01 17:45:57.000000000 +0200 @@ -1,3 +1,58 @@ +### 3.5.0 / 2016-07-01 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.5.0.beta4...v3.5.0) + +**No user facing changes since beta4** + +### 3.5.0.beta4 / 2016-06-05 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.5.0.beta3...v3.5.0.beta4) + +Bug Fixes: + +* Fix `include` matcher so that it provides a valid diff for hashes. (Yuji Nakayama, #916) + +### 3.5.0.beta3 / 2016-04-02 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.5.0.beta2...v3.5.0.beta3) + +Enhancements: + +* Make `rspec/expectations/minitest_integration` work on Minitest::Spec + 5.6+. (Myron Marston, #904) +* Add an alias `having_attributes` for `have_attributes` matcher. + (Yuji Nakayama, #905) +* Improve `change` matcher error message when block is mis-used. + (Alex Altair, #908) + +### 3.5.0.beta2 / 2016-03-10 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.5.0.beta1...v3.5.0.beta2) + +Enhancements: + +* Add the ability to raise an error on encountering false positives via + `RSpec::Configuration#on_potential_false_positives = :raise`. (Jon Rowe, #900) +* When using the custom matcher DSL, support new + `notify_expectation_failures: true` option for the `match` method to + allow expectation failures to be raised as normal instead of being + converted into a `false` return value for `matches?`. (Jon Rowe, #892) + +Bug Fixes: + +* Allow `should` deprecation check to work on `BasicObject`s. (James Coleman, #898) + +### 3.5.0.beta1 / 2016-02-06 +[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.4.0...v3.5.0.beta1) + +Enhancements: + +* Make `match_when_negated` in custom matcher DSL support use of + expectations within the match logic. (Chris Arcand, #789) + +Bug Fixes: + +* Return `true` as expected from passing negated expectations + (such as `expect("foo").not_to eq "bar"`), so they work + properly when used within a `match` or `match_when_negated` + block. (Chris Arcand, #789) + ### 3.4.0 / 2015-11-11 [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.3.1...v3.4.0) Files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/checksums.yaml.gz.sig new/checksums.yaml.gz.sig --- old/checksums.yaml.gz.sig 2015-11-12 08:48:14.000000000 +0100 +++ new/checksums.yaml.gz.sig 2016-07-01 17:45:57.000000000 +0200 @@ -1,2 +1,5 @@ -+u\{#Rg#L^Kcb5n3IS_C۴وtLMj'ՙ*# D0Hv-PTlUGV㩱FրcBNU2!KG]'?[Omc819I$`jHݸJy)iΐ>>8ְ&Öݨ+ﮩ -^n s/φIc$GO#ly`e0ͦ=P'XB ;;p8Wz lambda { |message| RSpec.warning message }, + :raise => lambda { |message| raise ArgumentError, message }, + :nothing => lambda { |_| true }, + } + def initialize - @warn_about_potential_false_positives = true + @on_potential_false_positives = :warn end # Configures the supported syntax. @@ -141,14 +149,43 @@ # Configures whether RSpec will warn about matcher use which will # potentially cause false positives in tests. # - # @param value [Boolean] - attr_writer :warn_about_potential_false_positives + # @param [Boolean] boolean + def warn_about_potential_false_positives=(boolean) + if boolean + self.on_potential_false_positives = :warn + elsif warn_about_potential_false_positives? + self.on_potential_false_positives = :nothing + else + # no-op, handler is something else + end + end + # + # Configures what RSpec will do about matcher use which will + # potentially cause false positives in tests. + # + # @param [Symbol] behavior can be set to :warn, :raise or :nothing + def on_potential_false_positives=(behavior) + unless FALSE_POSITIVE_BEHAVIOURS.key?(behavior) + raise ArgumentError, "Supported values are: #{FALSE_POSITIVE_BEHAVIOURS.keys}" + end + @on_potential_false_positives = behavior + end + + # Indicates what RSpec will do about matcher use which will + # potentially cause false positives in tests, generally you want to + # avoid such scenarios so this defaults to `true`. + attr_reader :on_potential_false_positives # Indicates whether RSpec will warn about matcher use which will # potentially cause false positives in tests, generally you want to # avoid such scenarios so this defaults to `true`. def warn_about_potential_false_positives? - @warn_about_potential_false_positives + on_potential_false_positives == :warn + end + + # @private + def false_positives_handler + FALSE_POSITIVE_BEHAVIOURS.fetch(@on_potential_false_positives) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rspec/expectations/expectation_target.rb new/lib/rspec/expectations/expectation_target.rb --- old/lib/rspec/expectations/expectation_target.rb 2015-11-12 08:48:14.000000000 +0100 +++ new/lib/rspec/expectations/expectation_target.rb 2016-07-01 17:45:57.000000000 +0200 @@ -21,6 +21,12 @@ # `nil` is a valid value to pass. UndefinedValue = Module.new + # @note this name aligns with `Minitest::Expectation` so that our + # {InstanceMethods} module can be included in that class when + # used in a Minitest context. + # @return [Object] the target of the expectation + attr_reader :target + # @api private def initialize(value) @target = value @@ -40,40 +46,48 @@ end end - # Runs the given expectation, passing if `matcher` returns true. - # @example - # expect(value).to eq(5) - # expect { perform }.to raise_error - # @param [Matcher] - # matcher - # @param [String or Proc] message optional message to display when the expectation fails - # @return [Boolean] true if the expectation succeeds (else raises) - # @see RSpec::Matchers - def to(matcher=nil, message=nil, &block) - prevent_operator_matchers(:to) unless matcher - RSpec::Expectations::PositiveExpectationHandler.handle_matcher(@target, matcher, message, &block) - end + # Defines instance {ExpectationTarget} instance methods. These are defined + # in a module so we can include it in `Minitest::Expectation` when + # `rspec/expectations/minitest_integration` is laoded in order to + # support usage with Minitest. + module InstanceMethods + # Runs the given expectation, passing if `matcher` returns true. + # @example + # expect(value).to eq(5) + # expect { perform }.to raise_error + # @param [Matcher] + # matcher + # @param [String or Proc] message optional message to display when the expectation fails + # @return [Boolean] true if the expectation succeeds (else raises) + # @see RSpec::Matchers + def to(matcher=nil, message=nil, &block) + prevent_operator_matchers(:to) unless matcher + RSpec::Expectations::PositiveExpectationHandler.handle_matcher(target, matcher, message, &block) + end - # Runs the given expectation, passing if `matcher` returns false. - # @example - # expect(value).not_to eq(5) - # @param [Matcher] - # matcher - # @param [String or Proc] message optional message to display when the expectation fails - # @return [Boolean] false if the negative expectation succeeds (else raises) - # @see RSpec::Matchers - def not_to(matcher=nil, message=nil, &block) - prevent_operator_matchers(:not_to) unless matcher - RSpec::Expectations::NegativeExpectationHandler.handle_matcher(@target, matcher, message, &block) - end - alias to_not not_to + # Runs the given expectation, passing if `matcher` returns false. + # @example + # expect(value).not_to eq(5) + # @param [Matcher] + # matcher + # @param [String or Proc] message optional message to display when the expectation fails + # @return [Boolean] false if the negative expectation succeeds (else raises) + # @see RSpec::Matchers + def not_to(matcher=nil, message=nil, &block) + prevent_operator_matchers(:not_to) unless matcher + RSpec::Expectations::NegativeExpectationHandler.handle_matcher(target, matcher, message, &block) + end + alias to_not not_to - private + private - def prevent_operator_matchers(verb) - raise ArgumentError, "The expect syntax does not support operator matchers, " \ - "so you must pass a matcher to `##{verb}`." + def prevent_operator_matchers(verb) + raise ArgumentError, "The expect syntax does not support operator matchers, " \ + "so you must pass a matcher to `##{verb}`." + end end + + include InstanceMethods end # @private diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rspec/expectations/handler.rb new/lib/rspec/expectations/handler.rb --- old/lib/rspec/expectations/handler.rb 2015-11-12 08:48:14.000000000 +0100 +++ new/lib/rspec/expectations/handler.rb 2016-07-01 17:45:57.000000000 +0200 @@ -69,7 +69,7 @@ def self.handle_matcher(actual, initial_matcher, message=nil, &block) ExpectationHelper.with_matcher(self, initial_matcher, message) do |matcher| return ::RSpec::Matchers::BuiltIn::NegativeOperatorMatcher.new(actual) unless initial_matcher - !(does_not_match?(matcher, actual, &block) || ExpectationHelper.handle_failure(matcher, message, :failure_message_when_negated)) + does_not_match?(matcher, actual, &block) || ExpectationHelper.handle_failure(matcher, message, :failure_message_when_negated) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rspec/expectations/minitest_integration.rb new/lib/rspec/expectations/minitest_integration.rb --- old/lib/rspec/expectations/minitest_integration.rb 2015-11-12 08:48:14.000000000 +0100 +++ new/lib/rspec/expectations/minitest_integration.rb 2016-07-01 17:45:57.000000000 +0200 @@ -3,8 +3,12 @@ Minitest::Test.class_eval do include ::RSpec::Matchers + # This `expect` will only be called if the user is using Minitest < 5.6 + # or if they are _not_ using Minitest::Spec on 5.6+. Minitest::Spec on 5.6+ + # defines its own `expect` and will have the assertions incremented via our + # definitions of `to`/`not_to`/`to_not` below. def expect(*a, &b) - assert(true) # so each expectation gets counted in minitest's assertion stats + self.assertions += 1 super end @@ -22,6 +26,29 @@ end end +# Older versions of Minitest (e.g. before 5.6) do not define +# `Minitest::Expectation`. +if defined?(::Minitest::Expectation) + Minitest::Expectation.class_eval do + include RSpec::Expectations::ExpectationTarget::InstanceMethods + + def to(*args) + ctx.assertions += 1 + super + end + + def not_to(*args) + ctx.assertions += 1 + super + end + + def to_not(*args) + ctx.assertions += 1 + super + end + end +end + module RSpec module Expectations remove_const :ExpectationNotMetError diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rspec/expectations/syntax.rb new/lib/rspec/expectations/syntax.rb --- old/lib/rspec/expectations/syntax.rb 2015-11-12 08:48:14.000000000 +0100 +++ new/lib/rspec/expectations/syntax.rb 2016-07-01 17:45:57.000000000 +0200 @@ -41,12 +41,12 @@ syntax_host.module_exec do def should(matcher=nil, message=nil, &block) - ::RSpec::Expectations::Syntax.warn_about_should_unless_configured(__method__) + ::RSpec::Expectations::Syntax.warn_about_should_unless_configured(::Kernel.__method__) ::RSpec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher, message, &block) end def should_not(matcher=nil, message=nil, &block) - ::RSpec::Expectations::Syntax.warn_about_should_unless_configured(__method__) + ::RSpec::Expectations::Syntax.warn_about_should_unless_configured(::Kernel.__method__) ::RSpec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rspec/expectations/version.rb new/lib/rspec/expectations/version.rb --- old/lib/rspec/expectations/version.rb 2015-11-12 08:48:14.000000000 +0100 +++ new/lib/rspec/expectations/version.rb 2016-07-01 17:45:57.000000000 +0200 @@ -2,7 +2,7 @@ module Expectations # @private module Version - STRING = '3.4.0' + STRING = '3.5.0' end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rspec/matchers/built_in/be.rb new/lib/rspec/matchers/built_in/be.rb --- old/lib/rspec/matchers/built_in/be.rb 2015-11-12 08:48:14.000000000 +0100 +++ new/lib/rspec/matchers/built_in/be.rb 2016-07-01 17:45:57.000000000 +0200 @@ -137,7 +137,8 @@ include BeHelpers def initialize(operand, operator) - @expected, @operator = operand, operator + @expected = operand + @operator = operator @args = [] end @@ -151,13 +152,15 @@ # @api private # @return [String] def failure_message - "expected: #{@operator} #{expected_formatted}\n got: #{@operator.to_s.gsub(/./, ' ')} #{actual_formatted}" + "expected: #{@operator} #{expected_formatted}\n" \ + " got: #{@operator.to_s.gsub(/./, ' ')} #{actual_formatted}" end # @api private # @return [String] def failure_message_when_negated - message = "`expect(#{actual_formatted}).not_to be #{@operator} #{expected_formatted}`" + message = "`expect(#{actual_formatted}).not_to " \ + "be #{@operator} #{expected_formatted}`" if [:<, :>, :<=, :>=].include?(@operator) message + " not only FAILED, it is a bit confusing." else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rspec/matchers/built_in/change.rb new/lib/rspec/matchers/built_in/change.rb --- old/lib/rspec/matchers/built_in/change.rb 2015-11-12 08:48:14.000000000 +0100 +++ new/lib/rspec/matchers/built_in/change.rb 2016-07-01 17:45:57.000000000 +0200 @@ -87,8 +87,8 @@ end def raise_block_syntax_error - raise SyntaxError, "The block passed to the `change` matcher must " \ - "use `{ ... }` instead of do/end" + raise SyntaxError, "Block not received by the `change` matcher. " \ + "Perhaps you want to use `{ ... }` instead of do/end?" end def positive_failure_reason diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rspec/matchers/built_in/include.rb new/lib/rspec/matchers/built_in/include.rb --- old/lib/rspec/matchers/built_in/include.rb 2015-11-12 08:48:14.000000000 +0100 +++ new/lib/rspec/matchers/built_in/include.rb 2016-07-01 17:45:57.000000000 +0200 @@ -5,8 +5,11 @@ # Provides the implementation for `include`. # Not intended to be instantiated directly. class Include < BaseMatcher - def initialize(*expected) - @expected = expected + # @private + attr_reader :expecteds + + def initialize(*expecteds) + @expecteds = expecteds end # @api private @@ -24,7 +27,7 @@ # @api private # @return [String] def description - improve_hash_formatting("include#{readable_list_of(expected)}") + improve_hash_formatting("include#{readable_list_of(expecteds)}") end # @api private @@ -45,6 +48,16 @@ !diff_would_wrongly_highlight_matched_item? end + # @api private + # @return [Array, Hash] + def expected + if expecteds.one? && Hash === expecteds.first + expecteds.first + else + expecteds + end + end + private def format_failure_message(preposition) @@ -73,7 +86,7 @@ def excluded_from_actual return [] unless @actual.respond_to?(:include?) - expected.inject([]) do |memo, expected_item| + expecteds.inject([]) do |memo, expected_item| if comparing_hash_to_a_subset?(expected_item) expected_item.each do |(key, value)| memo << { key => value } unless yield actual_hash_includes?(key, value) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rspec/matchers/built_in/raise_error.rb new/lib/rspec/matchers/built_in/raise_error.rb --- old/lib/rspec/matchers/built_in/raise_error.rb 2015-11-12 08:48:14.000000000 +0100 +++ new/lib/rspec/matchers/built_in/raise_error.rb 2016-07-01 17:45:57.000000000 +0200 @@ -12,7 +12,7 @@ def initialize(expected_error_or_message=nil, expected_message=nil, &block) @block = block @actual_error = nil - @warn_about_bare_error = warn_about_potential_false_positives? && expected_error_or_message.nil? + @warn_about_bare_error = expected_error_or_message.nil? case expected_error_or_message when nil @@ -132,7 +132,6 @@ end def warn_for_false_positives - return unless warn_about_potential_false_positives? expression = if expecting_specific_exception? && @expected_message "`expect { }.not_to raise_error(SpecificErrorClass, message)`" elsif expecting_specific_exception? @@ -146,8 +145,8 @@ warn_about_negative_false_positive expression end - def warn_about_potential_false_positives? - RSpec::Expectations.configuration.warn_about_potential_false_positives? + def handle_warning(message) + RSpec::Expectations.configuration.false_positives_handler.call(message) end def warning_about_bare_error @@ -155,25 +154,28 @@ end def warn_about_bare_error - RSpec.warning("Using the `raise_error` matcher without providing a specific " \ - "error or message risks false positives, since `raise_error` " \ - "will match when Ruby raises a `NoMethodError`, `NameError` or " \ - "`ArgumentError`, potentially allowing the expectation to pass " \ - "without even executing the method you are intending to call. " \ - "#{warning}"\ - "Instead consider providing a specific error class or message. " \ - "This message can be supressed by setting: " \ - "`RSpec::Expectations.configuration.warn_about_potential_false_positives = false`") + handle_warning("Using the `raise_error` matcher without providing a specific " \ + "error or message risks false positives, since `raise_error` " \ + "will match when Ruby raises a `NoMethodError`, `NameError` or " \ + "`ArgumentError`, potentially allowing the expectation to pass " \ + "without even executing the method you are intending to call. " \ + "#{warning}"\ + "Instead consider providing a specific error class or message. " \ + "This message can be suppressed by setting: " \ + "`RSpec::Expectations.configuration.on_potential_false" \ + "_positives = :nothing`") end def warn_about_negative_false_positive(expression) - RSpec.warning("Using #{expression} risks false positives, since literally " \ - "any other error would cause the expectation to pass, " \ - "including those raised by Ruby (e.g. NoMethodError, NameError " \ - "and ArgumentError), meaning the code you are intending to test " \ - "may not even get reached. Instead consider using " \ - "`expect {}.not_to raise_error`. This message can be supressed by setting: " \ - "`RSpec::Expectations.configuration.warn_about_potential_false_positives = false`") + handle_warning("Using #{expression} risks false positives, since literally " \ + "any other error would cause the expectation to pass, " \ + "including those raised by Ruby (e.g. NoMethodError, NameError " \ + "and ArgumentError), meaning the code you are intending to test " \ + "may not even get reached. Instead consider using " \ + "`expect {}.not_to raise_error` or `expect { }.to raise_error" \ + "(DifferentSpecificErrorClass)`. This message can be suppressed by " \ + "setting: `RSpec::Expectations.configuration.on_potential_false" \ + "_positives = :nothing`") end def expected_error diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rspec/matchers/built_in/respond_to.rb new/lib/rspec/matchers/built_in/respond_to.rb --- old/lib/rspec/matchers/built_in/respond_to.rb 2015-11-12 08:48:14.000000000 +0100 +++ new/lib/rspec/matchers/built_in/respond_to.rb 2016-07-01 17:45:57.000000000 +0200 @@ -10,6 +10,9 @@ def initialize(*names) @names = names @expected_arity = nil + @expected_keywords = [] + @unlimited_arguments = nil + @arbitrary_keywords = nil end # @api public @@ -23,6 +26,43 @@ end # @api public + # Specifies keyword arguments, if any. + # + # @example + # expect(obj).to respond_to(:message).with_keywords(:color, :shape) + # @example with an expected number of arguments + # expect(obj).to respond_to(:message).with(3).arguments.and_keywords(:color, :shape) + def with_keywords(*keywords) + @expected_keywords = keywords + self + end + alias :and_keywords :with_keywords + + # @api public + # Specifies that the method accepts any keyword, i.e. the method has + # a splatted keyword parameter of the form **kw_args. + # + # @example + # expect(obj).to respond_to(:message).with_any_keywords + def with_any_keywords + @arbitrary_keywords = true + self + end + alias :and_any_keywords :with_any_keywords + + # @api public + # Specifies that the number of arguments has no upper limit, i.e. the + # method has a splatted parameter of the form *args. + # + # @example + # expect(obj).to respond_to(:message).with_unlimited_arguments + def with_unlimited_arguments + @unlimited_arguments = true + self + end + alias :and_unlimited_arguments :with_unlimited_arguments + + # @api public # No-op. Intended to be used as syntactic sugar when using `with`. # # @example @@ -70,15 +110,50 @@ end def matches_arity?(actual, name) - return true unless @expected_arity + expectation = Support::MethodSignatureExpectation.new + + if @expected_arity.is_a?(Range) + expectation.min_count = @expected_arity.min + expectation.max_count = @expected_arity.max + else + expectation.min_count = @expected_arity + end + + expectation.keywords = @expected_keywords + expectation.expect_unlimited_arguments = @unlimited_arguments + expectation.expect_arbitrary_keywords = @arbitrary_keywords + + return true if expectation.empty? signature = Support::MethodSignature.new(Support.method_handle_for(actual, name)) - Support::StrictSignatureVerifier.new(signature, Array.new(@expected_arity)).valid? + + Support::StrictSignatureVerifier.new(signature).with_expectation(expectation).valid? end def with_arity - return "" unless @expected_arity - " with #{@expected_arity} argument#{@expected_arity == 1 ? '' : 's'}" + str = '' + str << " with #{with_arity_string}" if @expected_arity + str << " #{str.length == 0 ? 'with' : 'and'} #{with_keywords_string}" if @expected_keywords && @expected_keywords.count > 0 + str << " #{str.length == 0 ? 'with' : 'and'} unlimited arguments" if @unlimited_arguments + str << " #{str.length == 0 ? 'with' : 'and'} any keywords" if @arbitrary_keywords + str + end + + def with_arity_string + "#{@expected_arity} argument#{@expected_arity == 1 ? '' : 's'}" + end + + def with_keywords_string + kw_str = case @expected_keywords.count + when 1 + @expected_keywords.first.inspect + when 2 + @expected_keywords.map(&:inspect).join(' and ') + else + "#{@expected_keywords[0...-1].map(&:inspect).join(', ')}, and #{@expected_keywords.last.inspect}" + end + + "keyword#{@expected_keywords.count == 1 ? '' : 's'} #{kw_str}" end def pp_names diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rspec/matchers/dsl.rb new/lib/rspec/matchers/dsl.rb --- old/lib/rspec/matchers/dsl.rb 2015-11-12 08:48:14.000000000 +0100 +++ new/lib/rspec/matchers/dsl.rb 2016-07-01 17:45:57.000000000 +0200 @@ -55,16 +55,23 @@ # expect(3).to be_even # fails # expect(4).not_to be_even # fails # + # By default the match block will swallow expectation errors (e.g. + # caused by using an expectation such as `expect(1).to eq 2`), if you + # with to allow these to bubble up, pass in the option + # `:notify_expectation_failures => true`. + # + # @param [Hash] options for defining the behavior of the match block. # @yield [Object] actual the actual value (i.e. the value wrapped by `expect`) - def match(&match_block) + def match(options={}, &match_block) define_user_override(:matches?, match_block) do |actual| - begin - @actual = actual - RSpec::Support.with_failure_notifier(RAISE_NOTIFIER) do + @actual = actual + RSpec::Support.with_failure_notifier(RAISE_NOTIFIER) do + begin super(*actual_arg_for(match_block)) + rescue RSpec::Expectations::ExpectationNotMetError + raise if options[:notify_expectation_failures] + false end - rescue RSpec::Expectations::ExpectationNotMetError - false end end end @@ -80,8 +87,14 @@ # @yield [Object] actual the actual value (i.e. the value wrapped by `expect`) def match_when_negated(&match_block) define_user_override(:does_not_match?, match_block) do |actual| - @actual = actual - super(*actual_arg_for(match_block)) + begin + @actual = actual + RSpec::Support.with_failure_notifier(RAISE_NOTIFIER) do + super(*actual_arg_for(match_block)) + end + rescue RSpec::Expectations::ExpectationNotMetError + false + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rspec/matchers/english_phrasing.rb new/lib/rspec/matchers/english_phrasing.rb --- old/lib/rspec/matchers/english_phrasing.rb 2015-11-12 08:48:14.000000000 +0100 +++ new/lib/rspec/matchers/english_phrasing.rb 2016-07-01 17:45:57.000000000 +0200 @@ -37,6 +37,22 @@ " #{items[0...-1].join(', ')}, and #{items[-1]}" end end + + if RUBY_VERSION == '1.8.7' + # Not sure why, but on travis on 1.8.7 we have gotten these warnings: + # lib/rspec/matchers/english_phrasing.rb:28: warning: default `to_a' will be obsolete + # So it appears that `Array` can trigger that (e.g. by calling `to_a` on the passed object?) + # So here we replace `Kernel#Array` with our own warning-free implementation for 1.8.7. + # @private + # rubocop:disable Style/MethodName + def self.Array(obj) + case obj + when Array then obj + else [obj] + end + end + # rubocop:enable Style/MethodName + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rspec/matchers.rb new/lib/rspec/matchers.rb --- old/lib/rspec/matchers.rb 2015-11-12 08:48:14.000000000 +0100 +++ new/lib/rspec/matchers.rb 2016-07-01 17:45:57.000000000 +0200 @@ -621,6 +621,7 @@ BuiltIn::HaveAttributes.new(expected) end alias_matcher :an_object_having_attributes, :have_attributes + alias_matcher :having_attributes, :have_attributes # Passes if actual includes expected. This works for # collections and Strings. You can also pass in multiple args diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2015-11-12 08:48:14.000000000 +0100 +++ new/metadata 2016-07-01 17:45:57.000000000 +0200 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: rspec-expectations version: !ruby/object:Gem::Version - version: 3.4.0 + version: 3.5.0 platform: ruby authors: - Steven Baker @@ -45,7 +45,7 @@ ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ F3MdtaDehhjC -----END CERTIFICATE----- -date: 2015-11-12 00:00:00.000000000 Z +date: 2016-07-01 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rspec-support @@ -53,14 +53,14 @@ requirements: - - "~>" - !ruby/object:Gem::Version - version: 3.4.0 + version: 3.5.0 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: 3.4.0 + version: 3.5.0 - !ruby/object:Gem::Dependency name: diff-lcs requirement: !ruby/object:Gem::Requirement @@ -196,7 +196,7 @@ - lib/rspec/matchers/generated_descriptions.rb - lib/rspec/matchers/matcher_delegator.rb - lib/rspec/matchers/matcher_protocol.rb -homepage: http://github.com/rspec/rspec-expectations +homepage: https://github.com/rspec/rspec-expectations licenses: - MIT metadata: {} @@ -217,9 +217,9 @@ version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.2.2 +rubygems_version: 2.5.1 signing_key: specification_version: 4 -summary: rspec-expectations-3.4.0 +summary: rspec-expectations-3.5.0 test_files: [] has_rdoc: Files old/metadata.gz.sig and new/metadata.gz.sig differ