From 9940a8656071655b807f772f36101b4d27f1b67d Mon Sep 17 00:00:00 2001 From: Myron Marston Date: Sat, 4 Aug 2018 13:05:24 -0700 Subject: [PATCH 01/91] Bump version to 3.9.0.pre. --- lib/rspec/support/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rspec/support/version.rb b/lib/rspec/support/version.rb index 0b865ee6e..7bbbe5604 100644 --- a/lib/rspec/support/version.rb +++ b/lib/rspec/support/version.rb @@ -1,7 +1,7 @@ module RSpec module Support module Version - STRING = '3.8.0' + STRING = '3.9.0.pre' end end end From 7ff09f9f70dc1bcc151f35e3b017628f694db318 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 19 Sep 2018 14:39:28 +0100 Subject: [PATCH 02/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 2 +- appveyor.yml | 3 +-- script/clone_all_rspec_repos | 2 +- script/functions.sh | 2 +- script/predicate_functions.sh | 2 +- script/run_build | 2 +- script/travis_functions.sh | 2 +- 8 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index db7028464..dd4d6c587 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-04-05T18:41:16+10:00 from the rspec-dev repo. +# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index ebb749925..a16a75093 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-04-05T18:41:16+10:00 from the rspec-dev repo. +# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. language: ruby diff --git a/appveyor.yml b/appveyor.yml index 469175b41..13a498005 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-04-05T18:41:16+10:00 from the rspec-dev repo. +# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" @@ -33,7 +33,6 @@ test_script: environment: matrix: - - ruby_version: 193 - ruby_version: 200 - ruby_version: 21 - ruby_version: 22 diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index cbbef3743..374989f49 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2018-04-05T18:41:16+10:00 from the rspec-dev repo. +# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index 7a769e257..8f53e7557 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-04-05T18:41:16+10:00 from the rspec-dev repo. +# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index 4d592e273..b2b3ce47a 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-04-05T18:41:16+10:00 from the rspec-dev repo. +# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { diff --git a/script/run_build b/script/run_build index 4b42ed37d..05b1b8fee 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2018-04-05T18:41:16+10:00 from the rspec-dev repo. +# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index 7473ae719..d1d9dcf9e 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-04-05T18:41:16+10:00 from the rspec-dev repo. +# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: From 25611ed348cac7193828db9e04d9fdfaf56f10f5 Mon Sep 17 00:00:00 2001 From: Orien Madgwick <_@orien.io> Date: Sat, 20 Oct 2018 01:31:30 +1100 Subject: [PATCH 03/91] Add project metadata to the gemspec --- rspec-support.gemspec | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rspec-support.gemspec b/rspec-support.gemspec index 6699688fa..50f3f8112 100644 --- a/rspec-support.gemspec +++ b/rspec-support.gemspec @@ -13,6 +13,14 @@ Gem::Specification.new do |spec| spec.description = "Support utilities for RSpec gems" spec.license = "MIT" + spec.metadata = { + 'bug_tracker_uri' => 'https://github.com/rspec/rspec-support/issues', + 'changelog_uri' => "https://github.com/rspec/rspec-support/blob/v#{spec.version}/Changelog.md", + 'documentation_uri' => 'https://rspec.info/documentation/', + 'mailing_list_uri' => 'https://groups.google.com/forum/#!forum/rspec', + 'source_code_uri' => 'https://github.com/rspec/rspec-support', + } + spec.files = `git ls-files -- lib/*`.split("\n") spec.files += %w[README.md LICENSE.md Changelog.md] spec.test_files = [] From 2b04f6b96eea39a3afbb4227efb609af6800bc8b Mon Sep 17 00:00:00 2001 From: Juanito Fatas Date: Sun, 11 Nov 2018 00:36:05 +0900 Subject: [PATCH 04/91] Update terminology in BUILD_DETAIL.md --- BUILD_DETAIL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD_DETAIL.md b/BUILD_DETAIL.md index 37ebb3a28..573b24b86 100644 --- a/BUILD_DETAIL.md +++ b/BUILD_DETAIL.md @@ -40,7 +40,7 @@ The spec suite performs a couple extra checks that are worth noting: available for use in any context, we want to minimize how many bits of the standard library we load and use. Otherwise, RSpec's use of part of the standard library could mask a problem where a gem author forgets to load a part of the standard library they - rely on. The spec suite contains a spec that defines a whitelist of allowed loaded + rely on. The spec suite contains a spec that defines a list of allowed loaded stdlibs. In addition, we use [SimpleCov](https://github.com/colszowka/simplecov) From b1dae58a8e4e4010ee08c9c2d4bd826cd4cb4641 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 13 Nov 2018 14:52:29 +0000 Subject: [PATCH 05/91] Prevent Github complaining about FFI --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index 2cf43169f..6f906282e 100644 --- a/Gemfile +++ b/Gemfile @@ -24,6 +24,8 @@ if RUBY_VERSION < '2.0.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|min gem 'ffi', '< 1.9.15' # allow ffi to be installed on older rubies on windows elsif RUBY_VERSION < '1.9' gem 'ffi', '< 1.9.19' # ffi dropped Ruby 1.8 support in 1.9.19 +else + gem 'ffi', '~> 1.9.25' end # No need to run rubocop on earlier versions From b6b90d00f93dada2c266e7374cb3910da1a05978 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Sat, 17 Nov 2018 09:55:46 +0100 Subject: [PATCH 06/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 8 ++++---- appveyor.yml | 3 ++- script/clone_all_rspec_repos | 2 +- script/functions.sh | 2 +- script/predicate_functions.sh | 2 +- script/run_build | 2 +- script/travis_functions.sh | 2 +- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index dd4d6c587..11ed1e362 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. +# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index a16a75093..c86db08bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. +# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. language: ruby @@ -21,9 +21,9 @@ rvm: - 2.0.0 - 2.1 - 2.2.10 - - 2.3.7 - - 2.4.4 - - 2.5.1 + - 2.3.8 + - 2.4.5 + - 2.5.3 - ruby-head - ree - rbx-3 diff --git a/appveyor.yml b/appveyor.yml index 13a498005..beb19554e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. +# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" @@ -38,3 +38,4 @@ environment: - ruby_version: 22 - ruby_version: 23-x64 - ruby_version: 24-x64 + - ruby_version: 25-x64 diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index 374989f49..4f96308ff 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. +# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index 8f53e7557..5fb7bc280 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. +# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index b2b3ce47a..800a53717 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. +# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { diff --git a/script/run_build b/script/run_build index 05b1b8fee..54e85c895 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. +# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index d1d9dcf9e..3dcc3e1ac 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-09-19T14:39:28+01:00 from the rspec-dev repo. +# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: From 35941cde6308559da4507d76653112d07269b9c2 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Fri, 21 Dec 2018 13:15:34 +0000 Subject: [PATCH 07/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 5 +++-- appveyor.yml | 2 +- script/clone_all_rspec_repos | 2 +- script/functions.sh | 2 +- script/predicate_functions.sh | 2 +- script/run_build | 2 +- script/travis_functions.sh | 2 +- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 11ed1e362..03173b28e 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. +# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index c86db08bc..74c7d734a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. +# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. language: ruby @@ -8,7 +8,8 @@ cache: directories: - ../bundle before_install: - - gem update --system # https://github.com/travis-ci/travis-ci/issues/8978#issuecomment-354036443 + # We need to ensure the latest version of Rubygems, unless we're on an old Ruby. + - gem update --system $(ruby -e "puts '2.7.8' if ENV['RUBY_VERSION'] >= '2.3.0'") - gem install bundler - unset _JAVA_OPTIONS - "script/clone_all_rspec_repos" diff --git a/appveyor.yml b/appveyor.yml index beb19554e..49196d0e0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. +# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index 4f96308ff..60a99a7b8 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. +# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index 5fb7bc280..97805afdc 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. +# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index 800a53717..c47a5f9e5 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. +# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { diff --git a/script/run_build b/script/run_build index 54e85c895..774aa86e9 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. +# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index 3dcc3e1ac..b3c34dddb 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-11-17T09:55:46+01:00 from the rspec-dev repo. +# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: From e2b19be0f3347150c6ae5fdb37616af80cbe7851 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 25 Dec 2018 18:01:30 +0000 Subject: [PATCH 08/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 3 ++- appveyor.yml | 2 +- script/clone_all_rspec_repos | 2 +- script/functions.sh | 2 +- script/predicate_functions.sh | 2 +- script/run_build | 2 +- script/travis_functions.sh | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 03173b28e..41bcfc587 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index 74c7d734a..cf4a19fc7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. language: ruby @@ -25,6 +25,7 @@ rvm: - 2.3.8 - 2.4.5 - 2.5.3 + - 2.6.0 - ruby-head - ree - rbx-3 diff --git a/appveyor.yml b/appveyor.yml index 49196d0e0..936b7e80e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index 60a99a7b8..db91dc8af 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index 97805afdc..c54fa76bf 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index c47a5f9e5..b4bea29bb 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { diff --git a/script/run_build b/script/run_build index 774aa86e9..16acda276 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index b3c34dddb..7c867f337 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-21T13:15:34+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: From a0e30cc7c8021067b78510b7cd29a7442adc34cb Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 26 Dec 2018 22:31:28 +0000 Subject: [PATCH 09/91] Update nodes_by_line_number spec for change in Ruby behaviour --- spec/rspec/support/source_spec.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/spec/rspec/support/source_spec.rb b/spec/rspec/support/source_spec.rb index 0e3d56915..56532ced4 100644 --- a/spec/rspec/support/source_spec.rb +++ b/spec/rspec/support/source_spec.rb @@ -79,10 +79,19 @@ module RSpec::Support describe '#nodes_by_line_number' do it 'returns a hash containing nodes for each line number' do expect(source.nodes_by_line_number).to match( - 1 => [ - an_object_having_attributes(:type => :@int), - an_object_having_attributes(:type => :@ident) - ], + 1 => + if RUBY_VERSION >= '2.6.0' + [ + an_object_having_attributes(:type => :@int), + an_object_having_attributes(:type => :@period), + an_object_having_attributes(:type => :@ident) + ] + else + [ + an_object_having_attributes(:type => :@int), + an_object_having_attributes(:type => :@ident) + ] + end, 2 => [ an_object_having_attributes(:type => :@ident), an_object_having_attributes(:type => :@ident) From 1e9466fd035f16f7b19be9a4966beec39e5b46fc Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 30 Dec 2018 16:45:58 +0000 Subject: [PATCH 10/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 2 +- appveyor.yml | 2 +- script/clone_all_rspec_repos | 2 +- script/functions.sh | 4 ++-- script/predicate_functions.sh | 2 +- script/run_build | 2 +- script/travis_functions.sh | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 41bcfc587..4d0b7912a 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index cf4a19fc7..55be0958b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. language: ruby diff --git a/appveyor.yml b/appveyor.yml index 936b7e80e..3a32e7814 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index db91dc8af..419c2c18a 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index c54fa76bf..6f552b473 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -19,7 +19,7 @@ fi function clone_repo { if [ ! -d $1 ]; then # don't clone if the dir is already there - travis_retry eval "git clone git://github.com/rspec/$1 --depth 1 --branch $MAINTENANCE_BRANCH" + travis_retry eval "git clone https://github.com/rspec/$1 --depth 1 --branch $MAINTENANCE_BRANCH" fi; } diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index b4bea29bb..2348b3716 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { diff --git a/script/run_build b/script/run_build index 16acda276..293ba765f 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index 7c867f337..1bc5eccbf 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-25T18:01:30+00:00 from the rspec-dev repo. +# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: From 9a05d15e6e1123bc1b81cd5b5615d8ebcf6fcb14 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 3 Jan 2019 20:34:23 +0000 Subject: [PATCH 11/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 6 ++---- appveyor.yml | 2 +- script/clone_all_rspec_repos | 2 +- script/functions.sh | 2 +- script/predicate_functions.sh | 10 +++++++++- script/run_build | 2 +- script/travis_functions.sh | 2 +- script/update_rubygems_and_install_bundler | 15 +++++++++++++++ 9 files changed, 32 insertions(+), 11 deletions(-) create mode 100755 script/update_rubygems_and_install_bundler diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 4d0b7912a..3130e2676 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index 55be0958b..79f9f1eed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. language: ruby @@ -8,9 +8,7 @@ cache: directories: - ../bundle before_install: - # We need to ensure the latest version of Rubygems, unless we're on an old Ruby. - - gem update --system $(ruby -e "puts '2.7.8' if ENV['RUBY_VERSION'] >= '2.3.0'") - - gem install bundler + - "script/update_rubygems_and_install_bundler" - unset _JAVA_OPTIONS - "script/clone_all_rspec_repos" bundler_args: "--binstubs --standalone --without documentation --path ../bundle" diff --git a/appveyor.yml b/appveyor.yml index 3a32e7814..369422723 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index 419c2c18a..dcd4d914d 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index 6f552b473..1642bdb81 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index 2348b3716..cfdc471f7 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { @@ -57,6 +57,14 @@ function is_mri_2plus { fi } +function is_ruby_23_plus { + if ruby -e "exit(RUBY_VERSION.to_f >= 2.3)"; then + return 0 + else + return 1 + fi +} + function rspec_support_compatible { if [ "$MAINTENANCE_BRANCH" != "2-99-maintenance" ] && [ "$MAINTENANCE_BRANCH" != "2-14-maintenance" ]; then return 0 diff --git a/script/run_build b/script/run_build index 293ba765f..891a05e96 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index 1bc5eccbf..8b89cc8bd 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2018-12-30T16:45:58+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler new file mode 100755 index 000000000..bcf7e86db --- /dev/null +++ b/script/update_rubygems_and_install_bundler @@ -0,0 +1,15 @@ +#!/bin/bash +# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. +# DO NOT modify it by hand as your changes will get lost the next time it is generated. + +set -e +source script/functions.sh + +if is_ruby_23_plus; then + gem update --system + gem install bundler +else + echo "Warning installing older versions of Rubygems / Bundler" + gem update --system '2.7.8' + gem install bundler -v '1.17.3' +fi From de9231e5402716ac9f90984390fdc7b21e9e2da4 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Fri, 4 Jan 2019 10:10:21 +0000 Subject: [PATCH 12/91] Remove hard bundler dependency --- rspec-support.gemspec | 1 - 1 file changed, 1 deletion(-) diff --git a/rspec-support.gemspec b/rspec-support.gemspec index 50f3f8112..cf06bdcc1 100644 --- a/rspec-support.gemspec +++ b/rspec-support.gemspec @@ -35,7 +35,6 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 1.8.7' - spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "rake", "~> 10.0.0" spec.add_development_dependency "thread_order", "~> 1.1.0" end From ce976383522e125f97754e9eb6550cbf69e9033d Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 8 Jan 2019 11:28:05 +0000 Subject: [PATCH 13/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 3 +-- appveyor.yml | 2 +- script/clone_all_rspec_repos | 2 +- script/functions.sh | 2 +- script/predicate_functions.sh | 2 +- script/run_build | 2 +- script/travis_functions.sh | 2 +- script/update_rubygems_and_install_bundler | 2 +- 9 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 3130e2676..77255e27e 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index 79f9f1eed..5a5bf12fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. language: ruby @@ -40,7 +40,6 @@ matrix: - rvm: jruby-head - rvm: ruby-head - rvm: rbx-3 - - rvm: ruby-2.6.0-preview1 fast_finish: true branches: only: diff --git a/appveyor.yml b/appveyor.yml index 369422723..08b759674 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index dcd4d914d..86054c821 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index 1642bdb81..bfefca816 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index cfdc471f7..ca1f19273 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { diff --git a/script/run_build b/script/run_build index 891a05e96..701ca999f 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index 8b89cc8bd..9ae189804 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler index bcf7e86db..b59faab29 100755 --- a/script/update_rubygems_and_install_bundler +++ b/script/update_rubygems_and_install_bundler @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. +# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e From 63e31c2f677eb91c486da836d7c341768b5c76d4 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 3 Mar 2019 13:46:20 +0000 Subject: [PATCH 14/91] Use `send` to get `__getobj__` for `inspect` --- lib/rspec/support/object_formatter.rb | 2 +- spec/rspec/support/object_formatter_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/rspec/support/object_formatter.rb b/lib/rspec/support/object_formatter.rb index 834309a2c..2798a57b7 100644 --- a/lib/rspec/support/object_formatter.rb +++ b/lib/rspec/support/object_formatter.rb @@ -225,7 +225,7 @@ def self.can_inspect?(object) end def inspect - "#<#{object.class}(#{formatter.format(object.__getobj__)})>" + "#<#{object.class}(#{formatter.format(object.send(:__getobj__))})>" end end diff --git a/spec/rspec/support/object_formatter_spec.rb b/spec/rspec/support/object_formatter_spec.rb index 980363cf8..033e34712 100644 --- a/spec/rspec/support/object_formatter_spec.rb +++ b/spec/rspec/support/object_formatter_spec.rb @@ -140,6 +140,15 @@ def with_delegate_loaded end end + it 'includes the delegator class in the description even when protected' do + with_delegate_loaded do + protected_delegator = Class.new(SimpleDelegator) { protected :__getobj__ } + expect( + ObjectFormatter.format(protected_delegator.new(object)) + ).to eq "#<#{protected_delegator.inspect}(#{object.inspect})>" + end + end + it 'does not require Delegator to be defined' do hide_const("Delegator") expect(ObjectFormatter.format(object)).to eq object.inspect From 842c050cae8583f83364640e2de16bcbb1882627 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 3 Mar 2019 20:54:10 +0000 Subject: [PATCH 15/91] Change log for #369 --- Changelog.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Changelog.md b/Changelog.md index 945930415..20289cd1e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,11 @@ +### Development +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.0...master) + +Bug Fixes: + +* Ensure that inspecting a `SimpleDelegator` based object works regardless of + visibilty of the `__getobj__` method. (Jon Rowe, #369) + ### 3.8.0 / 2018-08-04 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.7.1...v3.8.0) From 6bb1d8405936a5039c89f3574055c197ab6b413d Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 3 Mar 2019 22:31:57 +0000 Subject: [PATCH 16/91] Release 3.8.1 --- Changelog.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 20289cd1e..ff4b61e9d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,5 @@ -### Development -[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.0...master) +### 3.8.1 / 2019-03-03 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.0...v3.8.1) Bug Fixes: From fc6cf0306f1727a86b01b7f53c7188e726a59ecf Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 5 Mar 2019 13:47:46 +0000 Subject: [PATCH 17/91] JRuby 9.1.7.0 produces a warning from rubygems, ignore it --- lib/rspec/support/spec/shell_out.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/rspec/support/spec/shell_out.rb b/lib/rspec/support/spec/shell_out.rb index f8268cdf1..e3d459458 100644 --- a/lib/rspec/support/spec/shell_out.rb +++ b/lib/rspec/support/spec/shell_out.rb @@ -59,10 +59,13 @@ def strip_known_warnings(input) l =~ %r{bundler/source/rubygems} || # Ignore bundler + rubygems warning. l =~ %r{site_ruby/\d\.\d\.\d/rubygems} || + l =~ %r{jruby-\d\.\d\.\d\.\d/lib/ruby/stdlib/rubygems} || # This is required for windows for some reason l =~ %r{lib/bundler/rubygems} || # This is a JRuby file that generates warnings on 9.0.3.0 - l =~ %r{lib/ruby/stdlib/jar} + l =~ %r{lib/ruby/stdlib/jar} || + # This is a JRuby file that generates warnings on 9.1.7.0 + l =~ %r{org/jruby/RubyKernel\.java} end.join("\n") end From c29b35b357c907aa769f2869e71d2fb8f56131e6 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 5 Mar 2019 14:46:38 +0000 Subject: [PATCH 18/91] Ignore blank lines when checking for warnings --- lib/rspec/support/spec/shell_out.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/rspec/support/spec/shell_out.rb b/lib/rspec/support/spec/shell_out.rb index e3d459458..28fcb2d49 100644 --- a/lib/rspec/support/spec/shell_out.rb +++ b/lib/rspec/support/spec/shell_out.rb @@ -65,7 +65,9 @@ def strip_known_warnings(input) # This is a JRuby file that generates warnings on 9.0.3.0 l =~ %r{lib/ruby/stdlib/jar} || # This is a JRuby file that generates warnings on 9.1.7.0 - l =~ %r{org/jruby/RubyKernel\.java} + l =~ %r{org/jruby/RubyKernel\.java} || + # Remove blank lines + l == "" || l.nil? end.join("\n") end From ed84b420eb5803b95d95ccf7416f6353bd240229 Mon Sep 17 00:00:00 2001 From: Evgeni Dzhelyov Date: Mon, 4 Mar 2019 10:13:38 +0200 Subject: [PATCH 19/91] Recognize hash as optional arg when optional keyword is present Given a method foo(a, b = {}, x: false) it should recognize that calling foo(1, 'a' => 1, 'b' => 2) is a valid method call. In case when the method has optional arguments and keyword arguments the ruby interpreter will treat the last Hash as keyword arguments if it contains Symbol keys. In the example above calling foo(1, a: 1) will raise an ArgumentError. --- .../support/method_signature_verifier.rb | 4 + .../support/method_signature_verifier_spec.rb | 92 +++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/lib/rspec/support/method_signature_verifier.rb b/lib/rspec/support/method_signature_verifier.rb index ceffceffa..20a537d46 100644 --- a/lib/rspec/support/method_signature_verifier.rb +++ b/lib/rspec/support/method_signature_verifier.rb @@ -85,6 +85,10 @@ def has_kw_args_in?(args) # contain keyword arguments? def could_contain_kw_args?(args) return false if args.count <= min_non_kw_args + return false if args.count <= max_non_kw_args && + Hash === args.last && + args.last.keys.none? { |x| x.is_a?(Symbol) } + @allows_any_kw_args || @allowed_kw_args.any? end diff --git a/spec/rspec/support/method_signature_verifier_spec.rb b/spec/rspec/support/method_signature_verifier_spec.rb index 8d8af8c43..aedb2fc39 100644 --- a/spec/rspec/support/method_signature_verifier_spec.rb +++ b/spec/rspec/support/method_signature_verifier_spec.rb @@ -366,6 +366,98 @@ def arity_kw(x, y:1, z:2); end end end + if RubyFeatures.kw_args_supported? + describe 'a method with optional argument and keyword arguments' do + eval <<-RUBY + def arity_kw(x, y = {}, z:2); end + RUBY + + let(:test_method) { method(:arity_kw) } + + it 'does not require any of the arguments' do + expect(valid?(nil)).to eq(true) + expect(valid?(nil, nil)).to eq(true) + end + + it 'does not allow an invalid keyword arguments' do + expect(valid?(nil, nil, :a => 1)).to eq(false) + expect(valid?(nil, :a => 1)).to eq(false) + end + + it 'allows Hash containing strings as last argument' do + expect(valid?(nil, 'a' => 1)).to eq(true) + end + + it 'mentions the invalid keyword args in the error', :pending => RSpec::Support::Ruby.jruby? && !RSpec::Support::Ruby.jruby_9000? do + expect(error_for(nil, nil, :a => 0)).to \ + eq("Invalid keyword arguments provided: a") + end + + it 'describes invalid arity precisely' do + expect(error_for()).to \ + eq("Wrong number of arguments. Expected 1 to 2, got 0.") + end + + it 'does not blow up when given a BasicObject as the last arg' do + expect(valid?(BasicObject.new)).to eq(true) + end + + it 'does not mutate the provided args array' do + args = [nil, nil, { :y => 1 }] + described_class.new(signature, args).valid? + expect(args).to eq([nil, nil, { :y => 1 }]) + end + + it 'mentions the arity and optional kw args in the description', :pending => RSpec::Support::Ruby.jruby? && !RSpec::Support::Ruby.jruby_9000? do + expect(signature_description).to eq("arity of 1 to 2 and optional keyword args (:z)") + end + + it "indicates the optional keyword args" do + expect(signature.optional_kw_args).to contain_exactly(:z) + end + + it "indicates it has no required keyword args" do + expect(signature.required_kw_args).to eq([]) + end + + describe 'with an expectation object' do + it 'matches the exact arity' do + expect(validate_expectation 0).to eq(false) + expect(validate_expectation 1).to eq(true) + expect(validate_expectation 2).to eq(true) + end + + it 'matches the exact range' do + expect(validate_expectation 0, 1).to eq(false) + expect(validate_expectation 1, 1).to eq(true) + expect(validate_expectation 1, 2).to eq(true) + expect(validate_expectation 1, 3).to eq(false) + end + + it 'does not match unlimited arguments' do + expect(validate_expectation :unlimited_args).to eq(false) + end + + it 'matches optional keywords with the correct arity' do + expect(validate_expectation :z).to eq(false) + expect(validate_expectation 1, :z).to eq(true) # Are we OK with that? + expect(validate_expectation 1, 2, :z).to eq(true) + expect(validate_expectation 1, 2, :y).to eq(false) + end + + it 'does not match invalid keywords' do + expect(validate_expectation :w).to eq(false) + + expect(validate_expectation 2, :w).to eq(false) + end + + it 'does not match arbitrary keywords' do + expect(validate_expectation :arbitrary_kw_args).to eq(false) + end + end + end + end + if RubyFeatures.required_kw_args_supported? describe 'a method with required keyword arguments' do eval <<-RUBY From 778f143da167ed4f3f8e8715543ddec153694aaa Mon Sep 17 00:00:00 2001 From: Evgeni Dzhelyov Date: Mon, 4 Mar 2019 10:32:09 +0200 Subject: [PATCH 20/91] Treat only symbol keys as keyword arguments If you pass key-value pairs to a method only the keys that are Symbols will be treated as keyword arguments. If there are optional arguments the rest of the keys will be passed to the optional one. Given a method foo(x = {}, y: 1): * foo('a' => 1) => will work * foo('a' => 1, :y => 2) => will work * foo('a' => 1, :b => 2) => will raise ArgumentError unknown keyword: b --- lib/rspec/support/method_signature_verifier.rb | 9 ++++++++- spec/rspec/support/method_signature_verifier_spec.rb | 10 +++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/rspec/support/method_signature_verifier.rb b/lib/rspec/support/method_signature_verifier.rb index 20a537d46..8fb6c1b9c 100644 --- a/lib/rspec/support/method_signature_verifier.rb +++ b/lib/rspec/support/method_signature_verifier.rb @@ -361,7 +361,14 @@ def unlimited_args? def split_args(*args) kw_args = if @signature.has_kw_args_in?(args) - args.pop.keys + last = args.pop + non_kw_args = last.reject { |k, _| k.is_a?(Symbol) } + if non_kw_args.empty? + last.keys + else + args << non_kw_args + last.select { |k, _| k.is_a?(Symbol) }.keys + end else [] end diff --git a/spec/rspec/support/method_signature_verifier_spec.rb b/spec/rspec/support/method_signature_verifier_spec.rb index aedb2fc39..9c2a1d61c 100644 --- a/spec/rspec/support/method_signature_verifier_spec.rb +++ b/spec/rspec/support/method_signature_verifier_spec.rb @@ -384,13 +384,17 @@ def arity_kw(x, y = {}, z:2); end expect(valid?(nil, :a => 1)).to eq(false) end - it 'allows Hash containing strings as last argument' do + it 'treats symbols as keyword arguments and the rest as optional argument' do expect(valid?(nil, 'a' => 1)).to eq(true) + expect(valid?(nil, 'a' => 1, :z => 3)).to eq(true) + expect(valid?(nil, 'a' => 1, :b => 3)).to eq(false) + expect(valid?(nil, 'a' => 1, :b => 2, :z => 3)).to eq(false) end it 'mentions the invalid keyword args in the error', :pending => RSpec::Support::Ruby.jruby? && !RSpec::Support::Ruby.jruby_9000? do - expect(error_for(nil, nil, :a => 0)).to \ - eq("Invalid keyword arguments provided: a") + expect(error_for(1, 2, :a => 0)).to eq("Invalid keyword arguments provided: a") + expect(error_for(1, :a => 0)).to eq("Invalid keyword arguments provided: a") + expect(error_for(1, 'a' => 0, :b => 0)).to eq("Invalid keyword arguments provided: b") end it 'describes invalid arity precisely' do From d24df62a1760357bc8c421773fda5b7b12d3ec28 Mon Sep 17 00:00:00 2001 From: Evgeni Dzhelyov Date: Sat, 9 Mar 2019 09:44:28 +0200 Subject: [PATCH 21/91] Move the symbol arguments check in has_kw_args_in? --- lib/rspec/support/method_signature_verifier.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/rspec/support/method_signature_verifier.rb b/lib/rspec/support/method_signature_verifier.rb index 8fb6c1b9c..d23f48684 100644 --- a/lib/rspec/support/method_signature_verifier.rb +++ b/lib/rspec/support/method_signature_verifier.rb @@ -77,17 +77,18 @@ def invalid_kw_args_from(given_kw_args) given_kw_args - @allowed_kw_args end + # If the last argument is Hash, Ruby will treat only symbol keys as keyword arguments + # the rest will be grouped in another Hash and passed as positional argument. def has_kw_args_in?(args) - Hash === args.last && could_contain_kw_args?(args) + Hash === args.last && + could_contain_kw_args?(args) && + args.last.keys.any? { |x| x.is_a?(Symbol) } end # Without considering what the last arg is, could it # contain keyword arguments? def could_contain_kw_args?(args) return false if args.count <= min_non_kw_args - return false if args.count <= max_non_kw_args && - Hash === args.last && - args.last.keys.none? { |x| x.is_a?(Symbol) } @allows_any_kw_args || @allowed_kw_args.any? end From 3a6ec66d32683e99c449a7b2f7f73e2edd7b6036 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 14 Mar 2019 22:02:34 +0000 Subject: [PATCH 22/91] Change log for #366 --- Changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.md b/Changelog.md index ff4b61e9d..9f6d4001f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,8 @@ Bug Fixes: * Ensure that inspecting a `SimpleDelegator` based object works regardless of visibilty of the `__getobj__` method. (Jon Rowe, #369) +* Ensure that optional hash arguments are recognised correctly vs keyword + arguments. (Evgeni Dzhelyov, #366) ### 3.8.0 / 2018-08-04 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.7.1...v3.8.0) From 2dddd6daa194f0670b4b6ed5952dbeee96ba77fc Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Mon, 1 Apr 2019 20:23:57 +0200 Subject: [PATCH 23/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 9 ++++----- appveyor.yml | 2 +- script/clone_all_rspec_repos | 2 +- script/functions.sh | 2 +- script/predicate_functions.sh | 2 +- script/run_build | 2 +- script/travis_functions.sh | 2 +- script/update_rubygems_and_install_bundler | 2 +- 9 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 77255e27e..6a164bbcf 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. +# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index 5a5bf12fd..9eea00e90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,7 @@ -# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. +# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. language: ruby -sudo: false email: false cache: directories: @@ -21,9 +20,9 @@ rvm: - 2.1 - 2.2.10 - 2.3.8 - - 2.4.5 - - 2.5.3 - - 2.6.0 + - 2.4.6 + - 2.5.5 + - 2.6.2 - ruby-head - ree - rbx-3 diff --git a/appveyor.yml b/appveyor.yml index 08b759674..4c3a948b9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. +# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index 86054c821..bdb1a02a1 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. +# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index bfefca816..c4e6fd362 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. +# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index ca1f19273..6edd3f06b 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. +# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { diff --git a/script/run_build b/script/run_build index 701ca999f..9c20410bc 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. +# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index 9ae189804..503fbf3b7 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. +# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler index b59faab29..70a0e2dd6 100755 --- a/script/update_rubygems_and_install_bundler +++ b/script/update_rubygems_and_install_bundler @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-01-08T11:28:05+00:00 from the rspec-dev repo. +# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e From 5633fdea7ff69e56ac568c15bc0ecde980be20b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E4=B8=8A=E5=A4=A7=E6=B2=B3?= Date: Thu, 18 Apr 2019 19:29:19 +0900 Subject: [PATCH 24/91] Fix typo :) --- lib/rspec/support.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rspec/support.rb b/lib/rspec/support.rb index 549a53bc8..4bbbc64cd 100644 --- a/lib/rspec/support.rb +++ b/lib/rspec/support.rb @@ -139,7 +139,7 @@ def self.===(exception) end end - # The Differ is only needed when a a spec fails with a diffable failure. + # The Differ is only needed when a spec fails with a diffable failure. # In the more common case of all specs passing or the only failures being # non-diffable, we can avoid the extra cost of loading the differ, diff-lcs, # pp, etc by avoiding an unnecessary require. Instead, autoload will take From 3950c7ad34eaf06e549a90e5b781f8a171150658 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Thu, 18 Apr 2019 19:41:53 +0200 Subject: [PATCH 25/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 4 ++-- appveyor.yml | 2 +- script/clone_all_rspec_repos | 2 +- script/functions.sh | 2 +- script/predicate_functions.sh | 2 +- script/run_build | 2 +- script/travis_functions.sh | 2 +- script/update_rubygems_and_install_bundler | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 6a164bbcf..2a69e8e97 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. +# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index 9eea00e90..f2f95c8dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. +# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. language: ruby @@ -22,7 +22,7 @@ rvm: - 2.3.8 - 2.4.6 - 2.5.5 - - 2.6.2 + - 2.6.3 - ruby-head - ree - rbx-3 diff --git a/appveyor.yml b/appveyor.yml index 4c3a948b9..a808b1140 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. +# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index bdb1a02a1..7be22baaa 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. +# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index c4e6fd362..c80529881 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. +# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index 6edd3f06b..d88cecc8f 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. +# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { diff --git a/script/run_build b/script/run_build index 9c20410bc..d027713c0 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. +# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index 503fbf3b7..65602d879 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. +# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler index 70a0e2dd6..3af7196d4 100755 --- a/script/update_rubygems_and_install_bundler +++ b/script/update_rubygems_and_install_bundler @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo. +# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e From 2b6a502f43704d3c1bea02a259cf69ae680834fd Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Sat, 20 Apr 2019 20:03:09 -0700 Subject: [PATCH 26/91] Empty last hash matches allow any kwargs --- lib/rspec/support/method_signature_verifier.rb | 2 +- spec/rspec/support/method_signature_verifier_spec.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rspec/support/method_signature_verifier.rb b/lib/rspec/support/method_signature_verifier.rb index d23f48684..12f1119f1 100644 --- a/lib/rspec/support/method_signature_verifier.rb +++ b/lib/rspec/support/method_signature_verifier.rb @@ -82,7 +82,7 @@ def invalid_kw_args_from(given_kw_args) def has_kw_args_in?(args) Hash === args.last && could_contain_kw_args?(args) && - args.last.keys.any? { |x| x.is_a?(Symbol) } + (args.last.empty? || args.last.keys.any? { |x| x.is_a?(Symbol) }) end # Without considering what the last arg is, could it diff --git a/spec/rspec/support/method_signature_verifier_spec.rb b/spec/rspec/support/method_signature_verifier_spec.rb index 9c2a1d61c..dd9b3c6ea 100644 --- a/spec/rspec/support/method_signature_verifier_spec.rb +++ b/spec/rspec/support/method_signature_verifier_spec.rb @@ -732,6 +732,7 @@ def arity_kw_arg_splat(x, **rest); end expect(valid?(nil, :x => 1)).to eq(true) expect(valid?(nil, :x => 1, :y => 2)).to eq(true) expect(valid?(:x => 1)).to eq(true) + expect(valid?(nil, {})).to eq(true) expect(valid?).to eq(false) expect(valid?(nil, nil)).to eq(false) From 4579133922b6fb2a615a0dac0ae8d0b4f6fabfff Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 30 Apr 2019 15:34:04 +0200 Subject: [PATCH 27/91] Change log for #375 --- Changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.md b/Changelog.md index 9f6d4001f..3c30f0da3 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,8 @@ Bug Fixes: visibilty of the `__getobj__` method. (Jon Rowe, #369) * Ensure that optional hash arguments are recognised correctly vs keyword arguments. (Evgeni Dzhelyov, #366) +* Ensure that an empty hash is recognised as empty keyword arguments when + applicable. (Thomas Walpole, #375) ### 3.8.0 / 2018-08-04 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.7.1...v3.8.0) From cbd22df17e54963974b48c6c5fad286e3cf3bba2 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Sat, 18 May 2019 12:05:46 +0200 Subject: [PATCH 28/91] Deal with new ffi Ruby version requirement CI was failing for 1.9.2 and 1.9.3. This is due to https://github.com/ffi/ffi/pull/683 Related: - https://github.com/ffi/ffi/issues/699 --- Gemfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 6f906282e..6223ce890 100644 --- a/Gemfile +++ b/Gemfile @@ -24,10 +24,11 @@ if RUBY_VERSION < '2.0.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|min gem 'ffi', '< 1.9.15' # allow ffi to be installed on older rubies on windows elsif RUBY_VERSION < '1.9' gem 'ffi', '< 1.9.19' # ffi dropped Ruby 1.8 support in 1.9.19 -else - gem 'ffi', '~> 1.9.25' +elsif RUBY_VERSION < '2.0' + gem 'ffi', '< 1.11.0' # ffi dropped Ruby 1.9 support in 1.11.0 end + # No need to run rubocop on earlier versions if RUBY_VERSION >= '2.4' && RUBY_ENGINE == 'ruby' gem "rubocop", "~> 0.52.1" From 396be9dde8210d9e8dac6b65e6252b8f53d00886 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 20 May 2019 12:01:08 +0200 Subject: [PATCH 29/91] Prevent security warning from github --- Gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 6223ce890..c539c8167 100644 --- a/Gemfile +++ b/Gemfile @@ -26,9 +26,10 @@ elsif RUBY_VERSION < '1.9' gem 'ffi', '< 1.9.19' # ffi dropped Ruby 1.8 support in 1.9.19 elsif RUBY_VERSION < '2.0' gem 'ffi', '< 1.11.0' # ffi dropped Ruby 1.9 support in 1.11.0 +else + gem 'ffi', '~> 1.9.25' end - # No need to run rubocop on earlier versions if RUBY_VERSION >= '2.4' && RUBY_ENGINE == 'ruby' gem "rubocop", "~> 0.52.1" From 27566219abb5e910c0057a3b7327667c438ce17d Mon Sep 17 00:00:00 2001 From: Lucas Nestor Date: Fri, 31 May 2019 15:20:29 -0400 Subject: [PATCH 30/91] Check for nil instead of truthiness when diffing When trying to make a diff where either the expected or actual value was false, the diff would be an empty string. This change makes it to diff against the false value. --- lib/rspec/support/differ.rb | 2 +- spec/rspec/support/differ_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/rspec/support/differ.rb b/lib/rspec/support/differ.rb index 442c892ce..73c424cfc 100644 --- a/lib/rspec/support/differ.rb +++ b/lib/rspec/support/differ.rb @@ -11,7 +11,7 @@ class Differ def diff(actual, expected) diff = "" - if actual && expected + unless actual.nil? || expected.nil? if all_strings?(actual, expected) if any_multiline_strings?(actual, expected) diff = diff_as_string(coerce_to_string(actual), coerce_to_string(expected)) diff --git a/spec/rspec/support/differ_spec.rb b/spec/rspec/support/differ_spec.rb index 921cf9b1b..fdddfa7a2 100644 --- a/spec/rspec/support/differ_spec.rb +++ b/spec/rspec/support/differ_spec.rb @@ -468,6 +468,13 @@ def inspect; ""; end expect(diff).to be_diffed_as(expected_diff) end end + + context 'when expected or actual is false' do + it 'generates a diff' do + expect(differ.diff(true, false)).to_not be_empty + expect(differ.diff(false, true)).to_not be_empty + end + end end end end From d70a6dd4d31bb90a9e9066725c0ffa5104d613ca Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sat, 8 Jun 2019 16:52:41 +0200 Subject: [PATCH 31/91] Change log for #377 --- Changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.md b/Changelog.md index 3c30f0da3..03b4308d5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,6 +9,8 @@ Bug Fixes: arguments. (Evgeni Dzhelyov, #366) * Ensure that an empty hash is recognised as empty keyword arguments when applicable. (Thomas Walpole, #375) +* Ensure that diffing truthy values produce diffs consistently. + (#377, #377) ### 3.8.0 / 2018-08-04 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.7.1...v3.8.0) From 7be3801d9f4f43890c3f2ce1de8bef9dd60df2dc Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Mon, 10 Jun 2019 20:01:35 +0100 Subject: [PATCH 32/91] Correct changelog --- Changelog.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Changelog.md b/Changelog.md index 03b4308d5..1bc772a7e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,16 +1,22 @@ -### 3.8.1 / 2019-03-03 -[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.0...v3.8.1) +### Development +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.1...master) Bug Fixes: -* Ensure that inspecting a `SimpleDelegator` based object works regardless of - visibilty of the `__getobj__` method. (Jon Rowe, #369) * Ensure that optional hash arguments are recognised correctly vs keyword arguments. (Evgeni Dzhelyov, #366) * Ensure that an empty hash is recognised as empty keyword arguments when applicable. (Thomas Walpole, #375) * Ensure that diffing truthy values produce diffs consistently. (#377, #377) + +### 3.8.1 / 2019-03-03 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.0...v3.8.1) + +Bug Fixes: + +* Ensure that inspecting a `SimpleDelegator` based object works regardless of + visibilty of the `__getobj__` method. (Jon Rowe, #369) ### 3.8.0 / 2018-08-04 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.7.1...v3.8.0) From 56e96fd8dd656ed12a47b354ecad69dba4583c89 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Mon, 10 Jun 2019 20:03:13 +0100 Subject: [PATCH 33/91] Correctly attribute #377 --- Changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 1bc772a7e..df2cff5ea 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,7 +8,7 @@ Bug Fixes: * Ensure that an empty hash is recognised as empty keyword arguments when applicable. (Thomas Walpole, #375) * Ensure that diffing truthy values produce diffs consistently. - (#377, #377) + (Lucas Nestor, #377) ### 3.8.1 / 2019-03-03 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.0...v3.8.1) From 5a4197af05542415379f6fa207d6674faa2e5e34 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Mon, 10 Jun 2019 20:07:37 +0100 Subject: [PATCH 34/91] Remove whitespace --- Changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index df2cff5ea..86941b5b0 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,7 +9,7 @@ Bug Fixes: applicable. (Thomas Walpole, #375) * Ensure that diffing truthy values produce diffs consistently. (Lucas Nestor, #377) - + ### 3.8.1 / 2019-03-03 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.0...v3.8.1) From 5cda28d6f5ea9b16f579340dfbafa7092c7a0bc6 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Mon, 10 Jun 2019 20:03:13 +0100 Subject: [PATCH 35/91] Changelog for 3.8.2 --- Changelog.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 86941b5b0..f433465ab 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,5 @@ -### Development -[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.1...master) +### 3.8.2 / 2019-06-10 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.1...v3.8.2) Bug Fixes: From 52b07b47732310fc6cdd9a1568f30ab67deeba43 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 11 Jun 2019 20:04:34 +0200 Subject: [PATCH 36/91] \r should be escaped when inside an array --- lib/rspec/support/differ.rb | 2 +- spec/rspec/support/differ_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/rspec/support/differ.rb b/lib/rspec/support/differ.rb index 73c424cfc..b81184239 100644 --- a/lib/rspec/support/differ.rb +++ b/lib/rspec/support/differ.rb @@ -97,7 +97,7 @@ def diffably_stringify(array) if Array === entry entry.inspect else - entry.to_s.gsub("\n", "\\n") + entry.to_s.gsub("\n", "\\n").gsub("\r", "\\r") end end end diff --git a/spec/rspec/support/differ_spec.rb b/spec/rspec/support/differ_spec.rb index fdddfa7a2..b08f48fb4 100644 --- a/spec/rspec/support/differ_spec.rb +++ b/spec/rspec/support/differ_spec.rb @@ -209,6 +209,17 @@ def inspect; ""; end expect(diff).to be_diffed_as(expected_diff) end + it 'outputs unified diff message of strings in arrays' do + diff = differ.diff(["a\r\nb"], ["a\r\nc"]) + expected_diff = <<-EOD + +@@ -1,2 +1,2 @@ +-a\\r\\nc ++a\\r\\nb +EOD + expect(diff).to be_diffed_as(expected_diff) + end + it "outputs unified diff message of two hashes" do expected = { :foo => 'bar', :baz => 'quux', :metasyntactic => 'variable', :delta => 'charlie', :width =>'quite wide' } actual = { :foo => 'bar', :metasyntactic => 'variable', :delta => 'charlotte', :width =>'quite wide' } From e47168fcbfabc51c166f5bdad1351a501acdc381 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 11 Jun 2019 20:47:57 +0200 Subject: [PATCH 37/91] Changelog for #378 --- Changelog.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Changelog.md b/Changelog.md index f433465ab..13f443c44 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,10 @@ +### Development + +Bug Fixes: + +* Escape \r when outputting strings inside arrays. + (Tomita Masahiro, Jon Rowe, #378) + ### 3.8.2 / 2019-06-10 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.1...v3.8.2) From 3826214511c101ba69a173b41db0174319d516df Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Mon, 8 Jul 2019 14:21:41 +0100 Subject: [PATCH 38/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 6 ++++-- appveyor.yml | 2 +- script/clone_all_rspec_repos | 2 +- script/functions.sh | 2 +- script/predicate_functions.sh | 2 +- script/run_build | 2 +- script/travis_functions.sh | 2 +- script/update_rubygems_and_install_bundler | 2 +- 9 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 2a69e8e97..0da3b03eb 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. +# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index f2f95c8dd..060a67b79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ -# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. +# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. +# In order to install old Rubies, we need to use old Ubuntu distibution. +dist: trusty language: ruby email: false cache: @@ -22,7 +24,7 @@ rvm: - 2.3.8 - 2.4.6 - 2.5.5 - - 2.6.3 + - 2.6.2 - ruby-head - ree - rbx-3 diff --git a/appveyor.yml b/appveyor.yml index a808b1140..657caf9b2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. +# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index 7be22baaa..d2fb7ac9d 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. +# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index c80529881..f6cec7d59 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. +# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index d88cecc8f..d375862b9 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. +# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { diff --git a/script/run_build b/script/run_build index d027713c0..ad317f68f 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. +# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index 65602d879..a6b5b70d8 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. +# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler index 3af7196d4..09a510618 100755 --- a/script/update_rubygems_and_install_bundler +++ b/script/update_rubygems_and_install_bundler @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-04-18T19:41:53+02:00 from the rspec-dev repo. +# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e From e7d71df7260b4e2d032c481e75a0c920d303b3ed Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Wed, 24 Jul 2019 15:33:55 +0200 Subject: [PATCH 39/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 2 +- appveyor.yml | 3 ++- script/clone_all_rspec_repos | 2 +- script/functions.sh | 2 +- script/predicate_functions.sh | 2 +- script/run_build | 2 +- script/travis_functions.sh | 2 +- script/update_rubygems_and_install_bundler | 2 +- 9 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 0da3b03eb..1f934401c 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. +# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index 060a67b79..89d199a4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. +# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # In order to install old Rubies, we need to use old Ubuntu distibution. diff --git a/appveyor.yml b/appveyor.yml index 657caf9b2..4adb13538 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. +# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" @@ -39,3 +39,4 @@ environment: - ruby_version: 23-x64 - ruby_version: 24-x64 - ruby_version: 25-x64 + - ruby_version: 26-x64 diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index d2fb7ac9d..32756ab16 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. +# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index f6cec7d59..01375ddcb 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. +# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index d375862b9..5fae415ee 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. +# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { diff --git a/script/run_build b/script/run_build index ad317f68f..5485a0bb6 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. +# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index a6b5b70d8..9cd44dcee 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. +# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler index 09a510618..b2fa25c9c 100755 --- a/script/update_rubygems_and_install_bundler +++ b/script/update_rubygems_and_install_bundler @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-07-08T14:21:41+01:00 from the rspec-dev repo. +# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e From 15ab1e7efeda36bed71d3471c71478ffed399f4b Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Wed, 24 Jul 2019 20:07:11 +0200 Subject: [PATCH 40/91] Avoid failing on Ruby 2.6 on Windows and Appveyor Also avoid installing ffi 1.11.0 on Ruby 1.9.x Related: https://github.com/rspec/rspec-core/pull/2651 --- Gemfile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index c539c8167..f10540d21 100644 --- a/Gemfile +++ b/Gemfile @@ -20,14 +20,13 @@ if RUBY_VERSION < '2.0.0' || RUBY_ENGINE == 'java' gem 'json', '< 2.0.0' # is a dependency of simplecov end -if RUBY_VERSION < '2.0.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/) - gem 'ffi', '< 1.9.15' # allow ffi to be installed on older rubies on windows -elsif RUBY_VERSION < '1.9' - gem 'ffi', '< 1.9.19' # ffi dropped Ruby 1.8 support in 1.9.19 +if RUBY_VERSION < '2.2.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/) + gem 'ffi', '< 1.10' elsif RUBY_VERSION < '2.0' - gem 'ffi', '< 1.11.0' # ffi dropped Ruby 1.9 support in 1.11.0 + # ffi dropped Ruby 1.8 support in 1.9.19 and Ruby 1.9 support in 1.11.0 + gem 'ffi', '< 1.9.19' else - gem 'ffi', '~> 1.9.25' + gem 'ffi', '~> 1.11.0' end # No need to run rubocop on earlier versions From e179d8f208a4a8a5413e7fe10cb36ba20331bf23 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 2 Oct 2019 14:35:46 +0100 Subject: [PATCH 41/91] Release 3.8.3 --- Changelog.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index 13f443c44..787bfb6f8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,17 +1,17 @@ -### Development +### 3.8.3 / 2019-10-02 Bug Fixes: * Escape \r when outputting strings inside arrays. (Tomita Masahiro, Jon Rowe, #378) +* Ensure that optional hash arguments are recognised correctly vs keyword + arguments. (Evgeni Dzhelyov, #366) ### 3.8.2 / 2019-06-10 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.1...v3.8.2) Bug Fixes: -* Ensure that optional hash arguments are recognised correctly vs keyword - arguments. (Evgeni Dzhelyov, #366) * Ensure that an empty hash is recognised as empty keyword arguments when applicable. (Thomas Walpole, #375) * Ensure that diffing truthy values produce diffs consistently. From 3d227e50f7a3c1e88e3cb113a93537f7d524c1be Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 8 Oct 2019 10:02:57 +0100 Subject: [PATCH 42/91] Version 3.9.0 --- Changelog.md | 8 ++++++++ lib/rspec/support/version.rb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 787bfb6f8..f722193cf 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,12 @@ +### 3.9.0 / 2019-10-07 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.3...v3.9.0) + +*NO CHANGES* + +Version 3.9.0 was released to allow other RSpec gems to release 3.9.0. + ### 3.8.3 / 2019-10-02 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.2...v3.8.3) Bug Fixes: diff --git a/lib/rspec/support/version.rb b/lib/rspec/support/version.rb index 7bbbe5604..585c205ad 100644 --- a/lib/rspec/support/version.rb +++ b/lib/rspec/support/version.rb @@ -1,7 +1,7 @@ module RSpec module Support module Version - STRING = '3.9.0.pre' + STRING = '3.10.0.pre' end end end From 1e4f9af88f274e8ea0fef24d7a52a014f4c69401 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Mon, 21 Oct 2019 09:35:11 +0100 Subject: [PATCH 43/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 2 +- appveyor.yml | 2 +- script/clone_all_rspec_repos | 2 +- script/functions.sh | 7 +++++-- script/predicate_functions.sh | 10 +++++++++- script/run_build | 2 +- script/travis_functions.sh | 2 +- script/update_rubygems_and_install_bundler | 2 +- 9 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 1f934401c..972219505 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. +# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index 89d199a4c..f353e5ccc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. +# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # In order to install old Rubies, we need to use old Ubuntu distibution. diff --git a/appveyor.yml b/appveyor.yml index 4adb13538..1f3f92c41 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. +# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index 32756ab16..988307c78 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. +# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index 01375ddcb..58bdf780d 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. +# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -187,7 +187,10 @@ function run_all_spec_suites { fold "rspec-core specs" run_spec_suite_for "rspec-core" fold "rspec-expectations specs" run_spec_suite_for "rspec-expectations" fold "rspec-mocks specs" run_spec_suite_for "rspec-mocks" - fold "rspec-rails specs" run_spec_suite_for "rspec-rails" + + if rspec_rails_compatible; then + fold "rspec-rails specs" run_spec_suite_for "rspec-rails" + fi if rspec_support_compatible; then fold "rspec-support specs" run_spec_suite_for "rspec-support" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index 5fae415ee..f2f72b56a 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. +# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { @@ -65,6 +65,14 @@ function is_ruby_23_plus { fi } +function rspec_rails_compatible { + if is_ruby_23_plus; then + return 0 + else + return 1 + fi +} + function rspec_support_compatible { if [ "$MAINTENANCE_BRANCH" != "2-99-maintenance" ] && [ "$MAINTENANCE_BRANCH" != "2-14-maintenance" ]; then return 0 diff --git a/script/run_build b/script/run_build index 5485a0bb6..d39a91e71 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. +# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index 9cd44dcee..a86ea2f58 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. +# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler index b2fa25c9c..0abbafdea 100755 --- a/script/update_rubygems_and_install_bundler +++ b/script/update_rubygems_and_install_bundler @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-07-24T15:33:55+02:00 from the rspec-dev repo. +# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e From 9eafb6eeae949ed4e0a09af7509a81768927bb83 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 27 Nov 2019 18:54:20 +0000 Subject: [PATCH 44/91] Updated common plaintext files (from rspec-dev) [ci skip] --- .github/FUNDING.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..0e4dc862c --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,7 @@ + + +github: [JonRowe] +open_collective: rspec From 54fdb00965246cbcee09a908ceb430a7290daba5 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 5 Dec 2019 21:25:48 +0000 Subject: [PATCH 45/91] Updated common plaintext files (from rspec-dev) [ci skip] --- .github/FUNDING.yml | 7 ++----- BUILD_DETAIL.md | 4 ++-- CODE_OF_CONDUCT.md | 2 +- CONTRIBUTING.md | 2 +- DEVELOPMENT.md | 2 +- REPORT_TEMPLATE.md | 2 +- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 0e4dc862c..7aaa7c9ec 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,7 +1,4 @@ - - +# This file was generated on 2019-12-05T21:25:48+00:00 from the rspec-dev repo. +# DO NOT modify it by hand as your changes will get lost the next time it is generated. github: [JonRowe] open_collective: rspec diff --git a/BUILD_DETAIL.md b/BUILD_DETAIL.md index 573b24b86..9d8a9f8db 100644 --- a/BUILD_DETAIL.md +++ b/BUILD_DETAIL.md @@ -1,5 +1,5 @@ @@ -40,7 +40,7 @@ The spec suite performs a couple extra checks that are worth noting: available for use in any context, we want to minimize how many bits of the standard library we load and use. Otherwise, RSpec's use of part of the standard library could mask a problem where a gem author forgets to load a part of the standard library they - rely on. The spec suite contains a spec that defines a list of allowed loaded + rely on. The spec suite contains a spec that defines a whitelist of allowed loaded stdlibs. In addition, we use [SimpleCov](https://github.com/colszowka/simplecov) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 9b73017c4..25692805e 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,5 +1,5 @@ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dbb9e7560..1c50f8468 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index a31c1c796..d7c12f16b 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -1,5 +1,5 @@ diff --git a/REPORT_TEMPLATE.md b/REPORT_TEMPLATE.md index eff8136ce..be45e9e7e 100644 --- a/REPORT_TEMPLATE.md +++ b/REPORT_TEMPLATE.md @@ -1,5 +1,5 @@ From 664288dcf3f4a579d6eedd2539ce208bb5324b29 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 5 Dec 2019 21:32:24 +0000 Subject: [PATCH 46/91] Updated common plaintext files (from rspec-dev) [ci skip] --- .github/FUNDING.yml | 3 ++- BUILD_DETAIL.md | 8 ++++---- CODE_OF_CONDUCT.md | 10 +++++----- CONTRIBUTING.md | 6 +++--- DEVELOPMENT.md | 10 +++++----- REPORT_TEMPLATE.md | 2 +- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 7aaa7c9ec..d31906b2f 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,4 +1,5 @@ -# This file was generated on 2019-12-05T21:25:48+00:00 from the rspec-dev repo. +# This file was generated on 2019-12-05T21:32:24+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. + github: [JonRowe] open_collective: rspec diff --git a/BUILD_DETAIL.md b/BUILD_DETAIL.md index 9d8a9f8db..cdf1c0566 100644 --- a/BUILD_DETAIL.md +++ b/BUILD_DETAIL.md @@ -1,5 +1,5 @@ @@ -40,7 +40,7 @@ The spec suite performs a couple extra checks that are worth noting: available for use in any context, we want to minimize how many bits of the standard library we load and use. Otherwise, RSpec's use of part of the standard library could mask a problem where a gem author forgets to load a part of the standard library they - rely on. The spec suite contains a spec that defines a whitelist of allowed loaded + rely on. The spec suite contains a spec that defines a list of allowed loaded stdlibs. In addition, we use [SimpleCov](https://github.com/colszowka/simplecov) @@ -68,8 +68,8 @@ $ bin/cucumber ## YARD documentation -RSpec uses [YARD](http://yardoc.org/) for API documentation on the [rspec.info site](http://rspec.info/). -Our commitment to [SemVer](htp://semver.org) requires that we explicitly +RSpec uses [YARD](https://yardoc.org/) for API documentation on the [rspec.info site](https://rspec.info/). +Our commitment to [SemVer](https://semver.org) requires that we explicitly declare our public API, and our build uses YARD to ensure that every class, module and method has either been labeled `@private` or has at least some level of documentation. For new APIs, this forces us to make diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 25692805e..e36c3b110 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,5 +1,5 @@ @@ -46,14 +46,14 @@ when an individual is representing the project or its community. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting one of the project maintainers listed at -http://rspec.info/about/. All complaints will be reviewed and investigated +https://rspec.info/about/. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Maintainers are obligated to maintain confidentiality with regard to the reporter of an incident. This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.3.0, available at -[http://contributor-covenant.org/version/1/3/0/][version] +[https://contributor-covenant.org/version/1/3/0/][version] -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/3/0/ +[homepage]: https://contributor-covenant.org +[version]: https://contributor-covenant.org/version/1/3/0/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c50f8468..0b073f037 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ @@ -13,8 +13,8 @@ If you'd like to help make RSpec better, here are some ways you can contribute: - by running RSpec HEAD to help us catch bugs before new releases - by [reporting bugs you encounter](https://github.com/rspec/rspec-support/issues/new) with [report template](#report-template) - by [suggesting new features](https://github.com/rspec/rspec-support/issues/new) - - by improving RSpec's [Relish](https://relishapp.com/rspec) or [API](http://rspec.info/documentation/) documentation - - by improving [RSpec's website](http://rspec.info/) ([source](https://github.com/rspec/rspec.github.io)) + - by improving RSpec's [Relish](https://relishapp.com/rspec) or [API](https://rspec.info/documentation/) documentation + - by improving [RSpec's website](https://rspec.info/) ([source](https://github.com/rspec/rspec.github.io)) - by taking part in [feature and issue discussions](https://github.com/rspec/rspec-support/issues) - by adding a failing test for reproducible [reported bugs](https://github.com/rspec/rspec-support/issues) - by reviewing [pull requests](https://github.com/rspec/rspec-support/pulls) and suggesting improvements diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index d7c12f16b..d9a596d22 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -1,12 +1,12 @@ # Development Setup Generally speaking, you only need to clone the project and install -the dependencies with [Bundler](http://bundler.io/). You can either +the dependencies with [Bundler](https://bundler.io/). You can either get a full RSpec development environment using [rspec-dev](https://github.com/rspec/rspec-dev#README) or you can set this project up individually. @@ -22,7 +22,7 @@ Clone the repo: $ git clone git@github.com:rspec/rspec-support.git ``` -Install the dependencies using [Bundler](http://bundler.io/): +Install the dependencies using [Bundler](https://bundler.io/): ``` $ cd rspec-support @@ -31,7 +31,7 @@ $ bundle install To minimize boot time and to ensure we don't depend upon any extra dependencies loaded by Bundler, our CI builds avoid loading Bundler at runtime -by using Bundler's [`--standalone option`](http://myronmars.to/n/dev-blog/2012/03/faster-test-boot-times-with-bundler-standalone). +by using Bundler's [`--standalone option`](https://myronmars.to/n/dev-blog/2012/03/faster-test-boot-times-with-bundler-standalone). While not strictly necessary (many/most of our contributors do not do this!), if you want to exactly reproduce our CI builds you'll want to do the same: @@ -114,7 +114,7 @@ Here's a short, non-exhaustive checklist of things we typically ask contributors # Adding Docs -RSpec uses [YARD](http://yardoc.org/) for its API documentation. To +RSpec uses [YARD](https://yardoc.org/) for its API documentation. To ensure the docs render well, we recommend running a YARD server and viewing your edits in a browser. diff --git a/REPORT_TEMPLATE.md b/REPORT_TEMPLATE.md index be45e9e7e..d07c0d46c 100644 --- a/REPORT_TEMPLATE.md +++ b/REPORT_TEMPLATE.md @@ -1,5 +1,5 @@ From 17963db63ad296cd46218f2533060706853b86e9 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 18 Dec 2019 14:01:39 +0000 Subject: [PATCH 47/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 2 +- appveyor.yml | 2 +- script/clone_all_rspec_repos | 2 +- script/functions.sh | 5 ++--- script/predicate_functions.sh | 2 +- script/run_build | 2 +- script/travis_functions.sh | 2 +- script/update_rubygems_and_install_bundler | 6 +++--- 9 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 972219505..3f6d6a2fa 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. +# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index f353e5ccc..598151910 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. +# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # In order to install old Rubies, we need to use old Ubuntu distibution. diff --git a/appveyor.yml b/appveyor.yml index 1f3f92c41..68756416f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. +# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index 988307c78..64f4ee8f5 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. +# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index 58bdf780d..e8c6a5af4 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. +# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -6,7 +6,7 @@ source $SCRIPT_DIR/travis_functions.sh source $SCRIPT_DIR/predicate_functions.sh # If JRUBY_OPTS isn't set, use these. -# see http://docs.travis-ci.com/user/ci-environment/ +# see https://docs.travis-ci.com/user/ci-environment/ export JRUBY_OPTS=${JRUBY_OPTS:-"--server -Xcompile.invokedynamic=false"} SPECS_HAVE_RUN_FILE=specs.out MAINTENANCE_BRANCH=`cat maintenance-branch` @@ -187,7 +187,6 @@ function run_all_spec_suites { fold "rspec-core specs" run_spec_suite_for "rspec-core" fold "rspec-expectations specs" run_spec_suite_for "rspec-expectations" fold "rspec-mocks specs" run_spec_suite_for "rspec-mocks" - if rspec_rails_compatible; then fold "rspec-rails specs" run_spec_suite_for "rspec-rails" fi diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index f2f72b56a..746a4985f 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. +# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { diff --git a/script/run_build b/script/run_build index d39a91e71..e20840e3c 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. +# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index a86ea2f58..4a86428a6 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. +# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler index 0abbafdea..ba2ac2560 100755 --- a/script/update_rubygems_and_install_bundler +++ b/script/update_rubygems_and_install_bundler @@ -1,13 +1,13 @@ #!/bin/bash -# This file was generated on 2019-10-21T09:35:11+01:00 from the rspec-dev repo. +# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e source script/functions.sh if is_ruby_23_plus; then - gem update --system - gem install bundler + yes | gem update --system + yes | gem install bundler else echo "Warning installing older versions of Rubygems / Bundler" gem update --system '2.7.8' From 3d5ee2df07c0551f887e4ce37ca85f498b0da1e8 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 26 Dec 2019 17:20:33 +0000 Subject: [PATCH 48/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 9 +++++---- appveyor.yml | 2 +- script/clone_all_rspec_repos | 2 +- script/functions.sh | 2 +- script/predicate_functions.sh | 2 +- script/run_build | 2 +- script/travis_functions.sh | 2 +- script/update_rubygems_and_install_bundler | 2 +- 9 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 3f6d6a2fa..4e00c2c55 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. +# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index 598151910..cd2c8230f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. +# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # In order to install old Rubies, we need to use old Ubuntu distibution. @@ -22,9 +22,10 @@ rvm: - 2.1 - 2.2.10 - 2.3.8 - - 2.4.6 - - 2.5.5 - - 2.6.2 + - 2.4.9 + - 2.5.7 + - 2.6.5 + - 2.7.0 - ruby-head - ree - rbx-3 diff --git a/appveyor.yml b/appveyor.yml index 68756416f..fb9dfcf0d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. +# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index 64f4ee8f5..72fa6df32 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. +# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index e8c6a5af4..16d5a2bad 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. +# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index 746a4985f..d4736724d 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. +# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { diff --git a/script/run_build b/script/run_build index e20840e3c..f8ce7a4cd 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. +# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index 4a86428a6..3770b23d8 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. +# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler index ba2ac2560..1b4ff8b04 100755 --- a/script/update_rubygems_and_install_bundler +++ b/script/update_rubygems_and_install_bundler @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo. +# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e From b2f4a683f163cfbb663595464caed99a09f16bd1 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 26 Dec 2019 19:58:59 +0000 Subject: [PATCH 49/91] Make usage of keyword arguments for String#encode explicit to avoid warning on 2.7.0 --- lib/rspec/support/encoded_string.rb | 33 +++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/lib/rspec/support/encoded_string.rb b/lib/rspec/support/encoded_string.rb index a6ca0cb64..66f75ca1d 100644 --- a/lib/rspec/support/encoded_string.rb +++ b/lib/rspec/support/encoded_string.rb @@ -112,11 +112,40 @@ def matching_encoding(string) string = remove_invalid_bytes(string) string.encode(@encoding) rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError - string.encode(@encoding, ENCODE_UNCONVERTABLE_BYTES) + encode_unconvertable_bytes(string) rescue Encoding::ConverterNotFoundError - string.dup.force_encoding(@encoding).encode(ENCODE_NO_CONVERTER) + encode_no_converter(string.dup.force_encoding(@encoding)) end + private + + # On Ruby 2.7.0 keyword arguments mixed with conventional cause a warning to + # be issued requiring us to be explicit by using a ** to pass the hash as + # keyword arguments. Any keyword argument supporting Ruby supports this. + if RubyFeatures.kw_args_supported? + # Note on non keyword supporting Ruby ** causes a syntax error hence + # we must use eval. To be removed in RSpec 4. + binding.eval(<<-CODE, __FILE__, __LINE__) + def encode_unconvertable_bytes(string) + string.encode(@encoding, **ENCODE_UNCONVERTABLE_BYTES) + end + + def encode_no_converter(string) + string.encode(**ENCODE_NO_CONVERTER) + end + CODE + else + def encode_unconvertable_bytes(string) + string.encode(@encoding, ENCODE_UNCONVERTABLE_BYTES) + end + + def encode_no_converter(string) + string.encode(ENCODE_NO_CONVERTER) + end + end + + public + # Prevents raising ArgumentError if String.method_defined?(:scrub) # https://github.com/ruby/ruby/blob/eeb05e8c11/doc/NEWS-2.1.0#L120-L123 From 3af7bae1d4e21ebaa177317d4fd1743d42ab9e61 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 26 Dec 2019 21:44:09 +0000 Subject: [PATCH 50/91] Add RubyFeatures#supports_taint? --- lib/rspec/support/ruby_features.rb | 9 +++++++++ spec/rspec/support/ruby_features_spec.rb | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/lib/rspec/support/ruby_features.rb b/lib/rspec/support/ruby_features.rb index 52aa37ec5..20e58075a 100644 --- a/lib/rspec/support/ruby_features.rb +++ b/lib/rspec/support/ruby_features.rb @@ -90,6 +90,15 @@ def supports_exception_cause? end end + if RUBY_VERSION.to_f >= 2.7 + def supports_taint? + false + end + else + def supports_taint? + true + end + end ripper_requirements = [ComparableVersion.new(RUBY_VERSION) >= '1.9.2'] ripper_requirements.push(false) if Ruby.rbx? diff --git a/spec/rspec/support/ruby_features_spec.rb b/spec/rspec/support/ruby_features_spec.rb index 0dcb1d2f1..10fc1525e 100644 --- a/spec/rspec/support/ruby_features_spec.rb +++ b/spec/rspec/support/ruby_features_spec.rb @@ -95,6 +95,10 @@ module Support RubyFeatures.supports_rebinding_module_methods? end + specify "#supports_taint?" do + RubyFeatures.supports_taint? + end + specify "#caller_locations_supported? exists" do RubyFeatures.caller_locations_supported? if Ruby.mri? From 0930546337a7548d55687e4d085ba2a4e472561e Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 26 Dec 2019 22:47:02 +0000 Subject: [PATCH 51/91] Ignore Aruba warning --- lib/rspec/support/spec/stderr_splitter.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/rspec/support/spec/stderr_splitter.rb b/lib/rspec/support/spec/stderr_splitter.rb index f797a2362..b2e3ee028 100644 --- a/lib/rspec/support/spec/stderr_splitter.rb +++ b/lib/rspec/support/spec/stderr_splitter.rb @@ -38,6 +38,10 @@ def to_io def write(line) return if line =~ %r{^\S+/gems/\S+:\d+: warning:} # http://rubular.com/r/kqeUIZOfPG + # Ruby 2.7.0 complains about hashes used in place of keyword arguments + # Aruba 0.14.2 uses this internally triggering that here + return if line =~ %r{lib/ruby/2\.7\.0/fileutils\.rb:622: warning:} + @orig_stderr.write(line) @output_tracker.write(line) end From bbd38cd816fa63f19e6106f562ef251bc27d1b58 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sat, 28 Dec 2019 17:26:18 +0000 Subject: [PATCH 52/91] Version 3.9.1 --- Changelog.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Changelog.md b/Changelog.md index f722193cf..2431408e7 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,11 @@ +### 3.9.1 / 2019-12-28 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.9.0...v3.9.1) + +Bug Fixes: + +* Remove warning caused by keyword arguments on Ruby 2.7.0. + (Jon Rowe, #392) + ### 3.9.0 / 2019-10-07 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.3...v3.9.0) From 92621b1444a5414091d5c5cf8e606e062640f7c2 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 29 Dec 2019 14:09:20 +0000 Subject: [PATCH 53/91] Remove unneeded public/private declarations --- lib/rspec/support/encoded_string.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/rspec/support/encoded_string.rb b/lib/rspec/support/encoded_string.rb index 66f75ca1d..50210053c 100644 --- a/lib/rspec/support/encoded_string.rb +++ b/lib/rspec/support/encoded_string.rb @@ -117,8 +117,6 @@ def matching_encoding(string) encode_no_converter(string.dup.force_encoding(@encoding)) end - private - # On Ruby 2.7.0 keyword arguments mixed with conventional cause a warning to # be issued requiring us to be explicit by using a ** to pass the hash as # keyword arguments. Any keyword argument supporting Ruby supports this. @@ -144,8 +142,6 @@ def encode_no_converter(string) end end - public - # Prevents raising ArgumentError if String.method_defined?(:scrub) # https://github.com/ruby/ruby/blob/eeb05e8c11/doc/NEWS-2.1.0#L120-L123 From 29c167da99180178f0596ce043757b1f7f370ccf Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 29 Dec 2019 15:17:47 +0100 Subject: [PATCH 54/91] Revert "Make usage of keyword arguments for String#encode explicit to avoid warning on 2.7.0" This reverts commit b2f4a683f163cfbb663595464caed99a09f16bd1. --- lib/rspec/support/encoded_string.rb | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/lib/rspec/support/encoded_string.rb b/lib/rspec/support/encoded_string.rb index 50210053c..a6ca0cb64 100644 --- a/lib/rspec/support/encoded_string.rb +++ b/lib/rspec/support/encoded_string.rb @@ -112,34 +112,9 @@ def matching_encoding(string) string = remove_invalid_bytes(string) string.encode(@encoding) rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError - encode_unconvertable_bytes(string) + string.encode(@encoding, ENCODE_UNCONVERTABLE_BYTES) rescue Encoding::ConverterNotFoundError - encode_no_converter(string.dup.force_encoding(@encoding)) - end - - # On Ruby 2.7.0 keyword arguments mixed with conventional cause a warning to - # be issued requiring us to be explicit by using a ** to pass the hash as - # keyword arguments. Any keyword argument supporting Ruby supports this. - if RubyFeatures.kw_args_supported? - # Note on non keyword supporting Ruby ** causes a syntax error hence - # we must use eval. To be removed in RSpec 4. - binding.eval(<<-CODE, __FILE__, __LINE__) - def encode_unconvertable_bytes(string) - string.encode(@encoding, **ENCODE_UNCONVERTABLE_BYTES) - end - - def encode_no_converter(string) - string.encode(**ENCODE_NO_CONVERTER) - end - CODE - else - def encode_unconvertable_bytes(string) - string.encode(@encoding, ENCODE_UNCONVERTABLE_BYTES) - end - - def encode_no_converter(string) - string.encode(ENCODE_NO_CONVERTER) - end + string.dup.force_encoding(@encoding).encode(ENCODE_NO_CONVERTER) end # Prevents raising ArgumentError From 3633d3906adf0511bfaf47de750537f51916bb60 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 29 Dec 2019 15:23:27 +0100 Subject: [PATCH 55/91] Inline hashes to silence warnings --- lib/rspec/support/encoded_string.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/rspec/support/encoded_string.rb b/lib/rspec/support/encoded_string.rb index a6ca0cb64..6ef070d2e 100644 --- a/lib/rspec/support/encoded_string.rb +++ b/lib/rspec/support/encoded_string.rb @@ -112,9 +112,15 @@ def matching_encoding(string) string = remove_invalid_bytes(string) string.encode(@encoding) rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError - string.encode(@encoding, ENCODE_UNCONVERTABLE_BYTES) + # ENCODE_UNCONVERTABLE_BYTES inlined here to avoid warnings on Ruby 2.7 + string.encode(@encoding, + :invalid => :replace, + :undef => :replace, + :replace => REPLACE) rescue Encoding::ConverterNotFoundError - string.dup.force_encoding(@encoding).encode(ENCODE_NO_CONVERTER) + # ENCODE_NO_CONVERTER inlined here to avoid warnings on Ruby 2.7 + string.dup.force_encoding(@encoding).encode(:invalid => :replace, + :replace => REPLACE) end # Prevents raising ArgumentError From e8ffc7246016a84cfcdf9cbd1ef7463abefdbcb9 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 29 Dec 2019 17:22:48 +0000 Subject: [PATCH 56/91] Remove unneeded constants and update docs --- lib/rspec/support/encoded_string.rb | 48 ++++++++++++----------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/lib/rspec/support/encoded_string.rb b/lib/rspec/support/encoded_string.rb index 6ef070d2e..13c323503 100644 --- a/lib/rspec/support/encoded_string.rb +++ b/lib/rspec/support/encoded_string.rb @@ -5,31 +5,11 @@ class EncodedString # Reduce allocations by storing constants. UTF_8 = "UTF-8" US_ASCII = "US-ASCII" - # - # In MRI 2.1 'invalid: :replace' changed to also replace an invalid byte sequence - # see https://github.com/ruby/ruby/blob/v2_1_0/NEWS#L176 - # https://www.ruby-forum.com/topic/6861247 - # https://twitter.com/nalsh/status/553413844685438976 - # - # For example, given: - # "\x80".force_encoding("Emacs-Mule").encode(:invalid => :replace).bytes.to_a - # - # On MRI 2.1 or above: 63 # '?' - # else : 128 # "\x80" - # + # Ruby's default replacement string is: # U+FFFD ("\xEF\xBF\xBD"), for Unicode encoding forms, else # ? ("\x3F") REPLACE = "?" - ENCODE_UNCONVERTABLE_BYTES = { - :invalid => :replace, - :undef => :replace, - :replace => REPLACE - } - ENCODE_NO_CONVERTER = { - :invalid => :replace, - :replace => REPLACE - } def initialize(string, encoding=nil) @encoding = encoding @@ -112,15 +92,25 @@ def matching_encoding(string) string = remove_invalid_bytes(string) string.encode(@encoding) rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError - # ENCODE_UNCONVERTABLE_BYTES inlined here to avoid warnings on Ruby 2.7 - string.encode(@encoding, - :invalid => :replace, - :undef => :replace, - :replace => REPLACE) + # Originally defined as a constant to avoid uneeded allocations, this hash must + # be defined inline (without {}) to avoid warnings on Ruby 2.7 + # + # In MRI 2.1 'invalid: :replace' changed to also replace an invalid byte sequence + # see https://github.com/ruby/ruby/blob/v2_1_0/NEWS#L176 + # https://www.ruby-forum.com/topic/6861247 + # https://twitter.com/nalsh/status/553413844685438976 + # + # For example, given: + # "\x80".force_encoding("Emacs-Mule").encode(:invalid => :replace).bytes.to_a + # + # On MRI 2.1 or above: 63 # '?' + # else : 128 # "\x80" + # + string.encode(@encoding, :invalid => :replace, :undef => :replace, :replace => REPLACE) rescue Encoding::ConverterNotFoundError - # ENCODE_NO_CONVERTER inlined here to avoid warnings on Ruby 2.7 - string.dup.force_encoding(@encoding).encode(:invalid => :replace, - :replace => REPLACE) + # Originally defined as a constant to avoid uneeded allocations, this hash must + # be defined inline (without {}) to avoid warnings on Ruby 2.7 + string.dup.force_encoding(@encoding).encode(:invalid => :replace, :replace => REPLACE) end # Prevents raising ArgumentError From 596198a74e6942fb9de253e590aaa71e1bf3b9d4 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Mon, 30 Dec 2019 09:20:34 +0000 Subject: [PATCH 57/91] Changelog for 3.9.2 --- Changelog.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Changelog.md b/Changelog.md index 2431408e7..0fe0eb26b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,10 @@ +### 3.9.2 / 2019-12-30 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.9.1...v3.9.2) + +Bug Fixes: + +* Remove unneeded eval. (Matijs van Zuijlen, #394) + ### 3.9.1 / 2019-12-28 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.9.0...v3.9.1) From e31aa346ca1053ca6892bc124260aa43e44a8c96 Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Fri, 10 Jan 2020 10:53:23 -0600 Subject: [PATCH 58/91] Prevent Rakefile from loading rubocop when dependency is not present --- Rakefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index 6756730f1..71c762a86 100644 --- a/Rakefile +++ b/Rakefile @@ -23,8 +23,12 @@ end task :build => :verify_private_key_present -require 'rubocop/rake_task' -desc 'Run RuboCop on the lib directory' -RuboCop::RakeTask.new(:rubocop) do |task| - task.patterns = ['lib/**/*.rb'] +begin + require 'rubocop/rake_task' + desc 'Run RuboCop on the lib directory' + RuboCop::RakeTask.new(:rubocop) do |task| + task.patterns = ['lib/**/*.rb'] + end +rescue LoadError + # No rubocop means no rubocop rake task end From 6ae55402d4bbfb772b704a24a0187040ffe96a68 Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Fri, 10 Jan 2020 10:48:07 -0600 Subject: [PATCH 59/91] Update ripper_supported? for truffleruby and specs ripper_is_implemented? --- lib/rspec/support/ruby_features.rb | 6 +++++- spec/rspec/support/ruby_features_spec.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/rspec/support/ruby_features.rb b/lib/rspec/support/ruby_features.rb index 20e58075a..ea4033df6 100644 --- a/lib/rspec/support/ruby_features.rb +++ b/lib/rspec/support/ruby_features.rb @@ -47,6 +47,10 @@ def non_mri? def mri? !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby' end + + def truffleruby? + defined?(RUBY_ENGINE) && RUBY_ENGINE == 'truffleruby' + end end # @api private @@ -101,7 +105,7 @@ def supports_taint? end ripper_requirements = [ComparableVersion.new(RUBY_VERSION) >= '1.9.2'] - ripper_requirements.push(false) if Ruby.rbx? + ripper_requirements.push(false) if Ruby.rbx? || Ruby.truffleruby? if Ruby.jruby? ripper_requirements.push(Ruby.jruby_version >= '1.7.5') diff --git a/spec/rspec/support/ruby_features_spec.rb b/spec/rspec/support/ruby_features_spec.rb index 10fc1525e..fd53035ab 100644 --- a/spec/rspec/support/ruby_features_spec.rb +++ b/spec/rspec/support/ruby_features_spec.rb @@ -111,7 +111,7 @@ def ripper_is_implemented? in_sub_process_if_possible do begin require 'ripper' - !!defined?(::Ripper) + !!defined?(::Ripper) && Ripper.respond_to?(:lex) rescue LoadError false end From 8c2ca4a13471e4ef2c6275990fc5f4c5b40fba6e Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 14 Jan 2020 11:17:16 +0000 Subject: [PATCH 60/91] Change log for #395 --- Changelog.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Changelog.md b/Changelog.md index 0fe0eb26b..c2d8fca50 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,10 @@ +### Development +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.9.2...master) + +Bug Fixes: + +* Mark ripper as unsupported on Truffle Ruby. (Brandon Fish, #395) + ### 3.9.2 / 2019-12-30 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.9.1...v3.9.2) From b87a05499eaa70f779a45bef2b25cc2007ce19ee Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Thu, 23 Jan 2020 22:37:16 +0300 Subject: [PATCH 61/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 2 +- appveyor.yml | 2 +- script/clone_all_rspec_repos | 2 +- script/functions.sh | 2 +- script/predicate_functions.sh | 30 +++++++++++++++++++--- script/run_build | 2 +- script/travis_functions.sh | 2 +- script/update_rubygems_and_install_bundler | 2 +- 9 files changed, 35 insertions(+), 11 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 4e00c2c55..852893b2a 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. +# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index cd2c8230f..41253a3ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. +# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # In order to install old Rubies, we need to use old Ubuntu distibution. diff --git a/appveyor.yml b/appveyor.yml index fb9dfcf0d..d5eb832c7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. +# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index 72fa6df32..bd137b3a7 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. +# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index 16d5a2bad..505563f04 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. +# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index d4736724d..17516df41 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. +# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { @@ -65,8 +65,28 @@ function is_ruby_23_plus { fi } +function is_ruby_25_plus { + if ruby -e "exit(RUBY_VERSION.to_f >= 2.5)"; then + return 0 + else + return 1 + fi +} + +function is_mri_27 { + if is_mri; then + if ruby -e "exit(RUBY_VERSION.to_f == 2.7)"; then + return 0 + else + return 1 + fi + else + return 1 + fi +} + function rspec_rails_compatible { - if is_ruby_23_plus; then + if is_ruby_25_plus; then return 0 else return 1 @@ -89,7 +109,11 @@ function additional_specs_available { function documentation_enforced { if [ -x ./bin/yard ]; then if is_mri_2plus; then - return 0 + if is_mri_27; then + return 1 + else + return 0 + fi else return 1 fi diff --git a/script/run_build b/script/run_build index f8ce7a4cd..f1b755274 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. +# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index 3770b23d8..9574746a3 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. +# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler index 1b4ff8b04..b569ac0aa 100755 --- a/script/update_rubygems_and_install_bundler +++ b/script/update_rubygems_and_install_bundler @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo. +# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e From 39de8fbd838551f2178cd3a54de6e3a19b848396 Mon Sep 17 00:00:00 2001 From: Brian Hawley Date: Fri, 24 Jan 2020 11:39:23 -0800 Subject: [PATCH 62/91] Don't raise exception on JRuby 9k < 9.2.1.0 JRuby 9k 9.2.0.0 and lower will has a bug in Ripper.sexp that raises a NoMethodError when analyzing code that even references a method with keyword arguments. This makes failure formatting raise that exception. Best to just not use Ripper on JRuby 9k < 9.2.1.0. [Fixes #399] --- lib/rspec/support/ruby_features.rb | 3 ++- spec/rspec/support/ruby_features_spec.rb | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/rspec/support/ruby_features.rb b/lib/rspec/support/ruby_features.rb index ea4033df6..3fdcbb563 100644 --- a/lib/rspec/support/ruby_features.rb +++ b/lib/rspec/support/ruby_features.rb @@ -111,7 +111,8 @@ def supports_taint? ripper_requirements.push(Ruby.jruby_version >= '1.7.5') # Ripper on JRuby 9.0.0.0.rc1 - 9.1.8.0 reports wrong line number # or cannot parse source including `:if`. - ripper_requirements.push(!Ruby.jruby_version.between?('9.0.0.0.rc1', '9.1.8.0')) + # Ripper on JRuby 9.x.x.x < 9.2.1.0 can't handle keyword arguments. + ripper_requirements.push(!Ruby.jruby_version.between?('9.0.0.0.rc1', '9.2.0.0')) end if ripper_requirements.all? diff --git a/spec/rspec/support/ruby_features_spec.rb b/spec/rspec/support/ruby_features_spec.rb index fd53035ab..0f368cbcf 100644 --- a/spec/rspec/support/ruby_features_spec.rb +++ b/spec/rspec/support/ruby_features_spec.rb @@ -120,7 +120,8 @@ def ripper_is_implemented? def ripper_works_correctly? ripper_reports_correct_line_number? && - ripper_can_parse_source_including_keywordish_symbol? + ripper_can_parse_source_including_keywordish_symbol? && + ripper_can_parse_source_referencing_keyword_arguments? end # https://github.com/jruby/jruby/issues/3386 @@ -144,6 +145,25 @@ def ripper_can_parse_source_including_keywordish_symbol? end end + # https://github.com/jruby/jruby/issues/5209 + def ripper_can_parse_source_referencing_keyword_arguments? + in_sub_process_if_possible do + require 'ripper' + # It doesn't matter if keyword arguments don't exist. + if Ruby.mri? || Ruby.jruby? + if RUBY_VERSION < '2.0' + true + else + begin + !::Ripper.sexp('def a(**kw_args); end').nil? + rescue NoMethodError + false + end + end + end + end + end + it 'returns whether Ripper is correctly implemented in the current environment' do expect(RubyFeatures.ripper_supported?).to eq(ripper_is_implemented? && ripper_works_correctly?) end From 9cec8e858228ee1d1395e4e6186ac39c2a83d705 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sat, 25 Jan 2020 08:52:29 +0000 Subject: [PATCH 63/91] Changelog for #400 --- Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.md b/Changelog.md index c2d8fca50..6b9819e15 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,7 @@ Bug Fixes: * Mark ripper as unsupported on Truffle Ruby. (Brandon Fish, #395) +* Mark ripper as unsupported on JRuby 9.2.0.0. (Brian Hawley, #400) ### 3.9.2 / 2019-12-30 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.9.1...v3.9.2) From 49d059572b440d46c1bfe433313ef865d1f371c4 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sat, 21 Mar 2020 19:08:01 +0000 Subject: [PATCH 64/91] Ignore Ruby 2.7 multiline warnings from gems --- lib/rspec/support/spec/stderr_splitter.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/rspec/support/spec/stderr_splitter.rb b/lib/rspec/support/spec/stderr_splitter.rb index b2e3ee028..03b50e939 100644 --- a/lib/rspec/support/spec/stderr_splitter.rb +++ b/lib/rspec/support/spec/stderr_splitter.rb @@ -6,6 +6,7 @@ class StdErrSplitter def initialize(original) @orig_stderr = original @output_tracker = ::StringIO.new + @last_line = nil end respond_to_name = (::RUBY_VERSION.to_f < 1.9) ? :respond_to? : :respond_to_missing? @@ -38,12 +39,19 @@ def to_io def write(line) return if line =~ %r{^\S+/gems/\S+:\d+: warning:} # http://rubular.com/r/kqeUIZOfPG + # Ruby 2.7.0 warnings from keyword argments span multiple lines, extend check above + # to look for the next line. + return if @last_line =~ %r{^\S+/gems/\S+:\d+: warning:} && + line =~ %r{warning: The called method .* is defined here} + # Ruby 2.7.0 complains about hashes used in place of keyword arguments # Aruba 0.14.2 uses this internally triggering that here return if line =~ %r{lib/ruby/2\.7\.0/fileutils\.rb:622: warning:} @orig_stderr.write(line) @output_tracker.write(line) + ensure + @last_line = line end def has_output? From f5d9bf91e9a2158f450f0f90979b35158f879b40 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Mon, 30 Mar 2020 16:31:26 +0200 Subject: [PATCH 65/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 2 +- appveyor.yml | 2 +- script/clone_all_rspec_repos | 2 +- script/functions.sh | 2 +- script/predicate_functions.sh | 20 ++------------------ script/run_build | 2 +- script/travis_functions.sh | 2 +- script/update_rubygems_and_install_bundler | 2 +- 9 files changed, 10 insertions(+), 26 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 852893b2a..afb4675d3 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. +# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index 41253a3ef..bf7383ede 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. +# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # In order to install old Rubies, we need to use old Ubuntu distibution. diff --git a/appveyor.yml b/appveyor.yml index d5eb832c7..5585247f0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. +# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index bd137b3a7..07f0ad877 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. +# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index 505563f04..d1afdd9a4 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. +# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index 17516df41..352fef84e 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. +# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { @@ -73,18 +73,6 @@ function is_ruby_25_plus { fi } -function is_mri_27 { - if is_mri; then - if ruby -e "exit(RUBY_VERSION.to_f == 2.7)"; then - return 0 - else - return 1 - fi - else - return 1 - fi -} - function rspec_rails_compatible { if is_ruby_25_plus; then return 0 @@ -109,11 +97,7 @@ function additional_specs_available { function documentation_enforced { if [ -x ./bin/yard ]; then if is_mri_2plus; then - if is_mri_27; then - return 1 - else - return 0 - fi + return 0 else return 1 fi diff --git a/script/run_build b/script/run_build index f1b755274..7aed3c40b 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. +# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index 9574746a3..2bde2e883 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. +# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler index b569ac0aa..4128e54f7 100755 --- a/script/update_rubygems_and_install_bundler +++ b/script/update_rubygems_and_install_bundler @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2020-01-23T22:37:16+03:00 from the rspec-dev repo. +# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e From eb6636585526de4b4306495290655c1f3d9e8026 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Fri, 3 Apr 2020 18:53:24 +0300 Subject: [PATCH 66/91] Updated travis build scripts (from rspec-dev) --- .rubocop_rspec_base.yml | 2 +- .travis.yml | 10 +++++----- appveyor.yml | 2 +- script/clone_all_rspec_repos | 2 +- script/functions.sh | 2 +- script/predicate_functions.sh | 2 +- script/run_build | 2 +- script/travis_functions.sh | 2 +- script/update_rubygems_and_install_bundler | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index afb4675d3..27144799e 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. +# This file was generated on 2020-04-03T18:53:24+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index bf7383ede..b455d4c9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. +# This file was generated on 2020-04-03T18:53:24+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # In order to install old Rubies, we need to use old Ubuntu distibution. @@ -22,10 +22,10 @@ rvm: - 2.1 - 2.2.10 - 2.3.8 - - 2.4.9 - - 2.5.7 - - 2.6.5 - - 2.7.0 + - 2.4.10 + - 2.5.8 + - 2.6.6 + - 2.7.1 - ruby-head - ree - rbx-3 diff --git a/appveyor.yml b/appveyor.yml index 5585247f0..6fc48f7db 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. +# This file was generated on 2020-04-03T18:53:24+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: "{build}" diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index 07f0ad877..2e97bc8f1 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. +# This file was generated on 2020-04-03T18:53:24+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index d1afdd9a4..0242a15c4 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. +# This file was generated on 2020-04-03T18:53:24+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index 352fef84e..82ef9baaf 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. +# This file was generated on 2020-04-03T18:53:24+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. function is_mri { diff --git a/script/run_build b/script/run_build index 7aed3c40b..8d4e9fbc0 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. +# This file was generated on 2020-04-03T18:53:24+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/travis_functions.sh b/script/travis_functions.sh index 2bde2e883..e34a04ecd 100644 --- a/script/travis_functions.sh +++ b/script/travis_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. +# This file was generated on 2020-04-03T18:53:24+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler index 4128e54f7..bf376353d 100755 --- a/script/update_rubygems_and_install_bundler +++ b/script/update_rubygems_and_install_bundler @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2020-03-30T16:31:26+02:00 from the rspec-dev repo. +# This file was generated on 2020-04-03T18:53:24+03:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e From 21558687b804b84764df82ae576bf825c5be06fe Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 7 Apr 2020 09:57:15 +0100 Subject: [PATCH 67/91] Update rake dependency to avoid security warning --- Gemfile | 8 ++++++++ rspec-support.gemspec | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index f10540d21..1d5e48388 100644 --- a/Gemfile +++ b/Gemfile @@ -13,6 +13,14 @@ branch = File.read(File.expand_path("../maintenance-branch", __FILE__)).chomp end end +if RUBY_VERSION < '1.9.3' + gem 'rake', '< 11.0.0' # rake 11 requires Ruby 1.9.3 or later +elsif RUBY_VERSION < '2.0.0' + gem 'rake', '< 12.0.0' # rake 12 requires Ruby 2.0.0 or later +else + gem 'rake', '>= 12.3.2' +end + ### dep for ci/coverage gem 'simplecov', '~> 0.8' diff --git a/rspec-support.gemspec b/rspec-support.gemspec index cf06bdcc1..c32cd57d4 100644 --- a/rspec-support.gemspec +++ b/rspec-support.gemspec @@ -35,6 +35,6 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 1.8.7' - spec.add_development_dependency "rake", "~> 10.0.0" + spec.add_development_dependency "rake", "> 10.0.0" spec.add_development_dependency "thread_order", "~> 1.1.0" end From 1e0a508dc5973f7a97d7030a120cea1c0d553039 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 7 Apr 2020 12:56:57 +0100 Subject: [PATCH 68/91] Actually specify correct version of rake to avoid warning --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 1d5e48388..d2ef6321f 100644 --- a/Gemfile +++ b/Gemfile @@ -18,7 +18,7 @@ if RUBY_VERSION < '1.9.3' elsif RUBY_VERSION < '2.0.0' gem 'rake', '< 12.0.0' # rake 12 requires Ruby 2.0.0 or later else - gem 'rake', '>= 12.3.2' + gem 'rake', '>= 12.3.3' end ### dep for ci/coverage From 8c3a1bb9e198a816136c3dd891eebcbc600bc825 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Mon, 6 Apr 2020 08:56:35 +0100 Subject: [PATCH 69/91] Add helper for running class_exec with keywords when needed --- .../support/with_keywords_when_needed.rb | 33 +++++++++++++ .../support/with_keywords_when_needed_spec.rb | 48 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 lib/rspec/support/with_keywords_when_needed.rb create mode 100644 spec/rspec/support/with_keywords_when_needed_spec.rb diff --git a/lib/rspec/support/with_keywords_when_needed.rb b/lib/rspec/support/with_keywords_when_needed.rb new file mode 100644 index 000000000..56b67e70b --- /dev/null +++ b/lib/rspec/support/with_keywords_when_needed.rb @@ -0,0 +1,33 @@ +RSpec::Support.require_rspec_support("method_signature_verifier") + +module RSpec + module Support + module WithKeywordsWhenNeeded + # This module adds keyword sensitive support for core ruby methods + # where we cannot use `ruby2_keywords` directly. + + module_function + + if RSpec::Support::RubyFeatures.kw_args_supported? + # Remove this in RSpec 4 in favour of explictly passed in kwargs where + # this is used. Works around a warning in Ruby 2.7 + + def class_exec(klass, *args, &block) + if MethodSignature.new(block).has_kw_args_in?(args) + binding.eval(<<-CODE, __FILE__, __LINE__) + kwargs = args.pop + klass.class_exec(*args, **kwargs, &block) + CODE + else + klass.class_exec(*args, &block) + end + end + ruby2_keywords :class_exec if respond_to?(:ruby2_keywords, true) + else + def class_exec(klass, *args, &block) + klass.class_exec(*args, &block) + end + end + end + end +end diff --git a/spec/rspec/support/with_keywords_when_needed_spec.rb b/spec/rspec/support/with_keywords_when_needed_spec.rb new file mode 100644 index 000000000..50a069fd4 --- /dev/null +++ b/spec/rspec/support/with_keywords_when_needed_spec.rb @@ -0,0 +1,48 @@ +require 'rspec/support/with_keywords_when_needed' + +module RSpec::Support + RSpec.describe "WithKeywordsWhenNeeded" do + + describe ".class_exec" do + extend RubyFeatures + + let(:klass) do + Class.new do + def self.check_argument(argument) + raise ArgumentError unless argument == 42 + end + end + end + + def run(klass, *args, &block) + WithKeywordsWhenNeeded.class_exec(klass, *args, &block) + end + + it "will run a block without keyword arguments" do + run(klass, 42) { |arg| check_argument(arg) } + end + + it "will run a block with a hash with out keyword arguments" do + run(klass, "value" => 42) { |arg| check_argument(arg["value"]) } + end + + it "will run a block with optional keyword arguments when none are provided", :if => kw_args_supported? do + binding.eval(<<-CODE, __FILE__, __LINE__) + run(klass, 42) { |arg, val: nil| check_argument(arg) } + CODE + end + + it "will run a block with optional keyword arguments when they are provided", :if => required_kw_args_supported? do + binding.eval(<<-CODE, __FILE__, __LINE__) + run(klass, val: 42) { |val: nil| check_argument(val) } + CODE + end + + it "will run a block with required keyword arguments", :if => required_kw_args_supported? do + binding.eval(<<-CODE, __FILE__, __LINE__) + run(klass, val: 42) { |val:| check_argument(val) } + CODE + end + end + end +end From 6ffbd71c8d420bbd0ac475a250615cb35f0e98af Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 8 Apr 2020 18:03:17 +0100 Subject: [PATCH 70/91] With out => without --- spec/rspec/support/with_keywords_when_needed_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/rspec/support/with_keywords_when_needed_spec.rb b/spec/rspec/support/with_keywords_when_needed_spec.rb index 50a069fd4..588bf385c 100644 --- a/spec/rspec/support/with_keywords_when_needed_spec.rb +++ b/spec/rspec/support/with_keywords_when_needed_spec.rb @@ -22,7 +22,7 @@ def run(klass, *args, &block) run(klass, 42) { |arg| check_argument(arg) } end - it "will run a block with a hash with out keyword arguments" do + it "will run a block with a hash without keyword arguments" do run(klass, "value" => 42) { |arg| check_argument(arg["value"]) } end From e90272532bd765cb14724ffe01eda65ff98dc692 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 26 Apr 2020 10:13:24 +0100 Subject: [PATCH 71/91] Allow mocking Mutex.new --- lib/rspec/support/reentrant_mutex.rb | 10 +++++++++- spec/rspec/support/mutex_spec.rb | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 spec/rspec/support/mutex_spec.rb diff --git a/lib/rspec/support/reentrant_mutex.rb b/lib/rspec/support/reentrant_mutex.rb index 13ee22bd5..361135942 100644 --- a/lib/rspec/support/reentrant_mutex.rb +++ b/lib/rspec/support/reentrant_mutex.rb @@ -43,7 +43,15 @@ def exit if defined? ::Mutex # On 1.9 and up, this is in core, so we just use the real one - Mutex = ::Mutex + class Mutex < ::Mutex + # If you mock Mutex.new you break our usage of Mutex, so + # instead we capture the original method to return Mutexs. + NEW_MUTEX_METHOD = Mutex.method(:new) + + def self.new + NEW_MUTEX_METHOD.call + end + end else # For 1.8.7 # :nocov: RSpec::Support.require_rspec_support "mutex" diff --git a/spec/rspec/support/mutex_spec.rb b/spec/rspec/support/mutex_spec.rb new file mode 100644 index 000000000..a600ed695 --- /dev/null +++ b/spec/rspec/support/mutex_spec.rb @@ -0,0 +1,8 @@ +require 'rspec/support/mutex' + +RSpec.describe RSpec::Support::Mutex do + it "allows ::Mutex to be mocked", :if => defined?(::Mutex) do + expect(Mutex).to receive(:new) + ::Mutex.new + end +end From e264cda0295e235344910ee9f64b2404c09a5541 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 26 Apr 2020 12:45:15 +0100 Subject: [PATCH 72/91] Update Changelog.md --- Changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.md b/Changelog.md index 6b9819e15..607b295f4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,8 @@ Bug Fixes: * Mark ripper as unsupported on Truffle Ruby. (Brandon Fish, #395) * Mark ripper as unsupported on JRuby 9.2.0.0. (Brian Hawley, #400) +* Capture `Mutex.new` for our `RSpec::Support:Mutex` in order to + allow stubbing `Mutex.new`. (Jon Rowe, #411) ### 3.9.2 / 2019-12-30 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.9.1...v3.9.2) From a816ca10e87ccf68023752af6a8824496d336f85 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Fri, 1 May 2020 09:57:47 +0100 Subject: [PATCH 73/91] Pin childprocess on older rubies --- Gemfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Gemfile b/Gemfile index d2ef6321f..d8b30d910 100644 --- a/Gemfile +++ b/Gemfile @@ -21,6 +21,14 @@ else gem 'rake', '>= 12.3.3' end +if RUBY_VERSION < '2.2.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/) + gem "childprocess", "< 1.0.0" +elsif RUBY_VERSION < '2.3.0' + gem "childprocess", "< 3.0.0" +else + gem "childprocess", ">= 3.0.0" +end + ### dep for ci/coverage gem 'simplecov', '~> 0.8' From 7961de6ac3af2b7398f42ca851ad81c0f5da515a Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Mon, 1 Jun 2020 17:33:46 +0100 Subject: [PATCH 74/91] Ignore JRuby warning --- lib/rspec/support/spec/shell_out.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/rspec/support/spec/shell_out.rb b/lib/rspec/support/spec/shell_out.rb index 28fcb2d49..9fc76c5f3 100644 --- a/lib/rspec/support/spec/shell_out.rb +++ b/lib/rspec/support/spec/shell_out.rb @@ -66,6 +66,8 @@ def strip_known_warnings(input) l =~ %r{lib/ruby/stdlib/jar} || # This is a JRuby file that generates warnings on 9.1.7.0 l =~ %r{org/jruby/RubyKernel\.java} || + # This is a JRuby gem that generates warnings on 9.1.7.0 + l =~ %r{ffi-1\.13\.\d-java} || # Remove blank lines l == "" || l.nil? end.join("\n") From f73ed4eedfc4ecc622f1fb3161daeaf652f5a286 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 3 Jun 2020 16:15:21 +0100 Subject: [PATCH 75/91] Change JRuby fix to be more permissive --- lib/rspec/support/spec/shell_out.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rspec/support/spec/shell_out.rb b/lib/rspec/support/spec/shell_out.rb index 9fc76c5f3..4caa87476 100644 --- a/lib/rspec/support/spec/shell_out.rb +++ b/lib/rspec/support/spec/shell_out.rb @@ -67,7 +67,7 @@ def strip_known_warnings(input) # This is a JRuby file that generates warnings on 9.1.7.0 l =~ %r{org/jruby/RubyKernel\.java} || # This is a JRuby gem that generates warnings on 9.1.7.0 - l =~ %r{ffi-1\.13\.\d-java} || + l =~ %r{uninitialized constant FFI\nio/console on JRuby shells out to stty} || # Remove blank lines l == "" || l.nil? end.join("\n") From 1b5ac96181cea0e8540e694cfd60dc815b5e5726 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 3 Jun 2020 17:13:32 +0100 Subject: [PATCH 76/91] Further change JRuby fix to be more permissive --- lib/rspec/support/spec/shell_out.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rspec/support/spec/shell_out.rb b/lib/rspec/support/spec/shell_out.rb index 4caa87476..d5a639ab8 100644 --- a/lib/rspec/support/spec/shell_out.rb +++ b/lib/rspec/support/spec/shell_out.rb @@ -67,7 +67,8 @@ def strip_known_warnings(input) # This is a JRuby file that generates warnings on 9.1.7.0 l =~ %r{org/jruby/RubyKernel\.java} || # This is a JRuby gem that generates warnings on 9.1.7.0 - l =~ %r{uninitialized constant FFI\nio/console on JRuby shells out to stty} || + l =~ %r{uninitialized constant FFI} || + l =~ %r{io/console on JRuby shells out to stty for most operations} || # Remove blank lines l == "" || l.nil? end.join("\n") From 70fac14799fd32484a96dca10be4b1cb0d7b2a61 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 3 Jun 2020 19:37:05 +0100 Subject: [PATCH 77/91] More filtering of JRuby (#417) * Add back ffi line explicitly * Add any jruby io line * Refactor to remove cyclomatic complexity --- lib/rspec/support/spec/shell_out.rb | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/rspec/support/spec/shell_out.rb b/lib/rspec/support/spec/shell_out.rb index d5a639ab8..d7409113a 100644 --- a/lib/rspec/support/spec/shell_out.rb +++ b/lib/rspec/support/spec/shell_out.rb @@ -53,22 +53,30 @@ def run_ruby_with_current_load_path(ruby_command, *flags) end end - def strip_known_warnings(input) - input.split("\n").reject do |l| + LINES_TO_IGNORE = + [ # Ignore bundler warning. - l =~ %r{bundler/source/rubygems} || + %r{bundler/source/rubygems}, # Ignore bundler + rubygems warning. - l =~ %r{site_ruby/\d\.\d\.\d/rubygems} || - l =~ %r{jruby-\d\.\d\.\d\.\d/lib/ruby/stdlib/rubygems} || + %r{site_ruby/\d\.\d\.\d/rubygems}, + %r{jruby-\d\.\d\.\d\.\d/lib/ruby/stdlib/rubygems}, # This is required for windows for some reason - l =~ %r{lib/bundler/rubygems} || + %r{lib/bundler/rubygems}, # This is a JRuby file that generates warnings on 9.0.3.0 - l =~ %r{lib/ruby/stdlib/jar} || + %r{lib/ruby/stdlib/jar}, # This is a JRuby file that generates warnings on 9.1.7.0 - l =~ %r{org/jruby/RubyKernel\.java} || + %r{org/jruby/RubyKernel\.java}, # This is a JRuby gem that generates warnings on 9.1.7.0 - l =~ %r{uninitialized constant FFI} || - l =~ %r{io/console on JRuby shells out to stty for most operations} || + %r{ffi-1\.13\.\d+-java}, + %r{uninitialized constant FFI}, + # These are related to the above, there is a warning about io from FFI + %r{jruby-\d\.\d\.\d\.\d/lib/ruby/stdlib/io}, + %r{io/console on JRuby shells out to stty for most operations}, + ] + + def strip_known_warnings(input) + input.split("\n").reject do |l| + LINES_TO_IGNORE.any? { |to_ignore| l =~ to_ignore } || # Remove blank lines l == "" || l.nil? end.join("\n") From abbdc93314d9a4f6a312f855781195a9c24778bc Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 3 Jun 2020 19:51:27 +0100 Subject: [PATCH 78/91] Add bench mark for keywords class exec --- benchmarks/class_exec_vs_klass_exec.rb | 43 ++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 benchmarks/class_exec_vs_klass_exec.rb diff --git a/benchmarks/class_exec_vs_klass_exec.rb b/benchmarks/class_exec_vs_klass_exec.rb new file mode 100644 index 000000000..9cb594d28 --- /dev/null +++ b/benchmarks/class_exec_vs_klass_exec.rb @@ -0,0 +1,43 @@ +require 'benchmark/ips' +require 'rspec/support' +require 'rspec/support/with_keywords_when_needed' + +Klass = Class.new do + def test(*args, **kwargs) + end +end + +def class_exec_args + Klass.class_exec(:a, :b) { } +end + +def klass_exec_args + RSpec::Support::WithKeywordsWhenNeeded.class_exec(Klass, :a, :b) { } +end + +def class_exec_kw_args + Klass.class_exec(a: :b) { |a:| } +end + +def klass_exec_kw_args + RSpec::Support::WithKeywordsWhenNeeded.class_exec(Klass, a: :b) { |a:| } +end + +Benchmark.ips do |x| + x.report("class_exec(*args) ") { class_exec_args } + x.report("klass_exec(*args) ") { klass_exec_args } + x.report("class_exec(*args, **kwargs)") { class_exec_kw_args } + x.report("klass_exec(*args, **kwargs)") { klass_exec_kw_args } +end + +__END__ + +Calculating ------------------------------------- +class_exec(*args) + 5.555M (± 1.6%) i/s - 27.864M in 5.017682s +klass_exec(*args) + 657.945k (± 4.6%) i/s - 3.315M in 5.051511s +class_exec(*args, **kwargs) + 2.882M (± 3.3%) i/s - 14.555M in 5.056905s +klass_exec(*args, **kwargs) + 52.710k (± 4.1%) i/s - 265.188k in 5.041218s From c221faad41abf22d0ca610e20c6c198a52797173 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Wed, 10 Jun 2020 14:51:45 +0200 Subject: [PATCH 79/91] Fix #233 conflicts -> Update rubocop (#350) Updated rubocop rules see: https://github.com/rspec/rspec-support/pull/350 --- .rubocop.yml | 8 ++++++++ lib/rspec/support/caller_filter.rb | 2 +- lib/rspec/support/comparable_version.rb | 2 +- lib/rspec/support/method_signature_verifier.rb | 4 ++-- lib/rspec/support/ruby_features.rb | 6 +++--- lib/rspec/support/spec/in_sub_process.rb | 4 +--- lib/rspec/support/spec/string_matcher.rb | 1 - 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index e51d1ea46..e6d4f3a13 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,3 +23,11 @@ Lint/AssignmentInCondition: Exclude: # The pattern makes sense here - 'lib/rspec/support/mutex.rb' + +# Over time we'd like to get this down, but this is what we're at now. +Metrics/AbcSize: + Max: 22 + +# Over time we'd like to get this down, but this is what we're at now. +Metrics/PerceivedComplexity: + Max: 9 diff --git a/lib/rspec/support/caller_filter.rb b/lib/rspec/support/caller_filter.rb index eb6f4dca9..cd59a30f8 100644 --- a/lib/rspec/support/caller_filter.rb +++ b/lib/rspec/support/caller_filter.rb @@ -69,7 +69,7 @@ def self.first_non_rspec_line(skip_frames=3, increment=5) return line.to_s if line skip_frames += increment - increment *= 2 # The choice of two here is arbitrary. + increment *= 2 # The choice of two here is arbitrary. end end else diff --git a/lib/rspec/support/comparable_version.rb b/lib/rspec/support/comparable_version.rb index d17b713f9..2afa0a4f2 100644 --- a/lib/rspec/support/comparable_version.rb +++ b/lib/rspec/support/comparable_version.rb @@ -10,7 +10,7 @@ def initialize(string) @string = string end - def <=>(other) + def <=>(other) # rubocop:disable Metrics/AbcSize other = self.class.new(other) unless other.is_a?(self.class) return 0 if string == other.string diff --git a/lib/rspec/support/method_signature_verifier.rb b/lib/rspec/support/method_signature_verifier.rb index 12f1119f1..16736224e 100644 --- a/lib/rspec/support/method_signature_verifier.rb +++ b/lib/rspec/support/method_signature_verifier.rb @@ -122,7 +122,7 @@ def classify_parameters end end - @max_non_kw_args = @min_non_kw_args + optional_non_kw_args + @max_non_kw_args = @min_non_kw_args + optional_non_kw_args @allowed_kw_args = @required_kw_args + @optional_kw_args end else @@ -285,7 +285,7 @@ def initialize(signature, args=[]) @arbitrary_kw_args = @unlimited_args = false end - def with_expectation(expectation) # rubocop:disable MethodLength + def with_expectation(expectation) # rubocop:disable MethodLength, Metrics/PerceivedComplexity return self unless MethodSignatureExpectation === expectation if expectation.empty? diff --git a/lib/rspec/support/ruby_features.rb b/lib/rspec/support/ruby_features.rb index 3fdcbb563..6f784e36d 100644 --- a/lib/rspec/support/ruby_features.rb +++ b/lib/rspec/support/ruby_features.rb @@ -7,7 +7,7 @@ module Support # # Provides query methods for different OS or OS features. module OS - module_function + module_function def windows? !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/) @@ -22,7 +22,7 @@ def windows_file_path? # # Provides query methods for different rubies module Ruby - module_function + module_function def jruby? RUBY_PLATFORM == 'java' @@ -58,7 +58,7 @@ def truffleruby? # Provides query methods for ruby features that differ among # implementations. module RubyFeatures - module_function + module_function if Ruby.jruby? # On JRuby 1.7 `--1.8` mode, `Process.respond_to?(:fork)` returns true, diff --git a/lib/rspec/support/spec/in_sub_process.rb b/lib/rspec/support/spec/in_sub_process.rb index aadb3de55..85196997c 100644 --- a/lib/rspec/support/spec/in_sub_process.rb +++ b/lib/rspec/support/spec/in_sub_process.rb @@ -7,8 +7,7 @@ module InSubProcess # Useful as a way to isolate a global change to a subprocess. - # rubocop:disable MethodLength - def in_sub_process(prevent_warnings=true) + def in_sub_process(prevent_warnings=true) # rubocop:disable MethodLength, Metrics/AbcSize exception_reader, exception_writer = IO.pipe result_reader, result_writer = IO.pipe @@ -46,7 +45,6 @@ def in_sub_process(prevent_warnings=true) result_reader.close result end - # rubocop:enable MethodLength alias :in_sub_process_if_possible :in_sub_process def marshal_dump_with_unmarshable_object_handling(object) diff --git a/lib/rspec/support/spec/string_matcher.rb b/lib/rspec/support/spec/string_matcher.rb index 9e1623178..7df319918 100644 --- a/lib/rspec/support/spec/string_matcher.rb +++ b/lib/rspec/support/spec/string_matcher.rb @@ -4,7 +4,6 @@ # which also relies on EncodedString. Instead, confirm the # strings have the same bytes. RSpec::Matchers.define :be_identical_string do |expected| - if String.method_defined?(:encoding) match do expected_encoding? && From 47c9ea9479e65c9f719a3bbdb20f516b773cad97 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sat, 2 May 2020 21:26:07 +0100 Subject: [PATCH 80/91] tVersion 3.9.3 --- Changelog.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 607b295f4..094197b34 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,5 @@ -### Development -[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.9.2...master) +### 3.9.3 / 2020-05-02 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.9.2...v3.9.3) Bug Fixes: From 357cc8b8a5b1b7bd278a77d5151a33a03871c34d Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sat, 27 Jun 2020 21:47:01 +0100 Subject: [PATCH 81/91] In version 1.4 `diff-lcs` has minorly changed its format This commit deals with both versions, as its just header notation thats changed. I'm not sure either is more correct than the other but its harmless to our diffing process. Some additional `\n` changes are due to the string type change, `"\\n"` is the same as `'\n'`. --- spec/rspec/support/differ_spec.rb | 137 ++++++++++++++++++++---------- 1 file changed, 94 insertions(+), 43 deletions(-) diff --git a/spec/rspec/support/differ_spec.rb b/spec/rspec/support/differ_spec.rb index b08f48fb4..524e815fa 100644 --- a/spec/rspec/support/differ_spec.rb +++ b/spec/rspec/support/differ_spec.rb @@ -7,6 +7,17 @@ module RSpec module Support describe Differ do + + # In the updated version of diff-lcs several diff headers change format slightly + # compensate for this and change minimum version in RSpec 4 + if Diff::LCS::VERSION.to_f < 1.4 + one_line_header = "-1,2 +1,2" + removing_two_line_header = "-1,3 +1" + else + one_line_header = "-1 +1" + removing_two_line_header = "-1,3 +1,5" + end + describe '#diff' do let(:differ) { RSpec::Support::Differ.new } @@ -14,7 +25,8 @@ module Support expected = "foo\nzap\nbar\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nanother\nline\n" actual = "foo\nbar\nzap\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nline\n" - expected_diff = <<-'EOD' + if Diff::LCS::VERSION.to_f < 1.4 + expected_diff = <<-'EOD' @@ -1,6 +1,6 @@ @@ -32,6 +44,25 @@ module Support -another line EOD + else + expected_diff = <<-'EOD' + + +@@ -1,4 +1,6 @@ + foo +-zap + bar ++zap + this +@@ -9,6 +11,7 @@ + equal + insert + a +-another + line +EOD + end + diff = differ.diff(actual, expected) expect(diff).to be_diffed_as(expected_diff) @@ -41,25 +72,45 @@ module Support expected = "foo\nzap\nbar\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nanother\nline\n" actual = "foo\nbar\nzap\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nline\n" - expected_diff = dedent(<<-'EOS') - | - | - |@@ -1,6 +1,6 @@ - | foo - |-zap - | bar - |+zap - | this - | is - | soo - |@@ -9,6 +9,5 @@ - | equal - | insert - | a - |-another - | line - | - EOS + if Diff::LCS::VERSION.to_f < 1.4 + expected_diff = dedent(<<-'EOS') + | + | + |@@ -1,6 +1,6 @@ + | foo + |-zap + | bar + |+zap + | this + | is + | soo + |@@ -9,6 +9,5 @@ + | equal + | insert + | a + |-another + | line + | + EOS + else + expected_diff = dedent(<<-'EOS') + | + | + |@@ -1,4 +1,6 @@ + | foo + |-zap + | bar + |+zap + | this + |@@ -9,6 +11,7 @@ + | equal + | insert + | a + |-another + | line + | + EOS + end diff = differ.diff(actual, expected) expect(diff).to be_diffed_as(expected_diff) @@ -94,7 +145,7 @@ def differ_ivars actual = "Tu avec carté {count} itém has\n".encode('UTF-16LE') expected_diff = <<-EOD.encode('UTF-16LE') -@@ -1,2 +1,2 @@ +@@ #{one_line_header} @@ -Tu avec carte {count} item has +Tu avec carté {count} itém has EOD @@ -106,7 +157,7 @@ def differ_ivars it 'handles differently encoded strings that are compatible' do expected = "abc\n".encode('us-ascii') actual = "강인철\n".encode('UTF-8') - expected_diff = "\n@@ -1,2 +1,2 @@\n-abc\n+강인철\n" + expected_diff = "\n@@ #{one_line_header} @@\n-abc\n+강인철\n" diff = differ.diff(actual, expected) expect(diff).to be_diffed_as(expected_diff) end @@ -114,7 +165,7 @@ def differ_ivars it 'uses the default external encoding when the two strings have incompatible encodings', :failing_on_appveyor do expected = "Tu avec carte {count} item has\n" actual = "Tu avec carté {count} itém has\n".encode('UTF-16LE') - expected_diff = "\n@@ -1,2 +1,2 @@\n-Tu avec carte {count} item has\n+Tu avec carté {count} itém has\n" + expected_diff = "\n@@ #{one_line_header} @@\n-Tu avec carte {count} item has\n+Tu avec carté {count} itém has\n" diff = differ.diff(actual, expected) expect(diff).to be_diffed_as(expected_diff) @@ -202,7 +253,7 @@ def inspect; ""; end expected_diff = <<-EOD -@@ -1,2 +1,2 @@ +@@ #{one_line_header} @@ -[] +[] EOD @@ -213,7 +264,7 @@ def inspect; ""; end diff = differ.diff(["a\r\nb"], ["a\r\nc"]) expected_diff = <<-EOD -@@ -1,2 +1,2 @@ +@@ #{one_line_header} @@ -a\\r\\nc +a\\r\\nb EOD @@ -262,7 +313,7 @@ def inspect; ""; end it 'outputs unified diff message of two hashes with differing encoding', :failing_on_appveyor do expected_diff = %Q{ -@@ -1,2 +1,2 @@ +@@ #{one_line_header} @@ -"a" => "a", #{ (RUBY_VERSION.to_f > 1.8) ? %Q{+"ö" => "ö"} : '+"\303\266" => "\303\266"' }, } @@ -273,7 +324,7 @@ def inspect; ""; end it 'outputs unified diff message of two hashes with encoding different to key encoding', :failing_on_appveyor do expected_diff = %Q{ -@@ -1,2 +1,2 @@ +@@ #{one_line_header} @@ -:a => "a", #{ (RUBY_VERSION.to_f > 1.8) ? %Q{+\"한글\" => \"한글2\"} : '+"\355\225\234\352\270\200" => "\355\225\234\352\270\2002"' }, } @@ -284,7 +335,7 @@ def inspect; ""; end it "outputs unified diff message of two hashes with object keys" do expected_diff = %Q{ -@@ -1,2 +1,2 @@ +@@ #{one_line_header} @@ -["a", "c"] => "b", +["d", "c"] => "b", } @@ -299,7 +350,7 @@ def inspect; ""; end it "outputs unified diff message of two hashes with Time object keys" do expected_diff = %Q{ -@@ -1,2 +1,2 @@ +@@ #{one_line_header} @@ -#{formatted_time} => "b", +#{formatted_time} => "c", } @@ -310,7 +361,7 @@ def inspect; ""; end it "outputs unified diff message of two hashes with hashes inside them" do expected_diff = %Q{ -@@ -1,2 +1,2 @@ +@@ #{one_line_header} @@ -"b" => {"key_1"=>#{formatted_time}}, +"c" => {"key_1"=>#{formatted_time}}, } @@ -328,7 +379,7 @@ def inspect; ""; end it "outputs unified diff message of two arrays with Time object keys" do expected_diff = %Q{ -@@ -1,2 +1,2 @@ +@@ #{one_line_header} @@ -[#{formatted_time}, "b"] +[#{formatted_time}, "c"] } @@ -339,7 +390,7 @@ def inspect; ""; end it "outputs unified diff message of two arrays with hashes inside them" do expected_diff = %Q{ -@@ -1,2 +1,2 @@ +@@ #{one_line_header} @@ -[{"b"=>#{formatted_time}}, "c"] +[{"a"=>#{formatted_time}}, "c"] } @@ -368,11 +419,11 @@ def inspect; ""; end end it "splits items with newlines" do - expected_diff = <<'EOD' + expected_diff = <<"EOD" -@@ -1,3 +1 @@ --a\nb --c\nd +@@ #{removing_two_line_header} @@ +-a\\nb +-c\\nd EOD diff = differ.diff [], ["a\nb", "c\nd"] @@ -380,11 +431,11 @@ def inspect; ""; end end it "shows inner arrays on a single line" do - expected_diff = <<'EOD' + expected_diff = <<"EOD" -@@ -1,3 +1 @@ --a\nb --["c\nd"] +@@ #{removing_two_line_header} @@ +-a\\nb +-["c\\nd"] EOD diff = differ.diff [], ["a\nb", ["c\nd"]] @@ -434,7 +485,7 @@ def inspect; ""; end expected_diff = dedent(<<-EOS) | - |@@ -1,2 +1,2 @@ + |@@ #{one_line_header} @@ |-[#] |+[#{object.inspect}] | @@ -456,7 +507,7 @@ def inspect; ""; end expected_diff = dedent(<<-EOS) | - |@@ -1,2 +1,2 @@ + |@@ #{one_line_header} @@ |-"oop" |+"oof" | @@ -473,7 +524,7 @@ def inspect; ""; end it "outputs colored diffs" do expected = "foo bar baz\n" actual = "foo bang baz\n" - expected_diff = "\e[0m\n\e[0m\e[34m@@ -1,2 +1,2 @@\n\e[0m\e[31m-foo bang baz\n\e[0m\e[32m+foo bar baz\n\e[0m" + expected_diff = "\e[0m\n\e[0m\e[34m@@ #{one_line_header} @@\n\e[0m\e[31m-foo bang baz\n\e[0m\e[32m+foo bar baz\n\e[0m" diff = differ.diff(expected,actual) expect(diff).to be_diffed_as(expected_diff) From 548624db45f93676f2d56f134d86d1dc9d6933a6 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 28 Jun 2020 09:48:20 +0100 Subject: [PATCH 82/91] Allow checking both versions of `diff-lcs` --- .travis.yml | 2 ++ Gemfile | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index b455d4c9f..1eaad615f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,8 @@ matrix: include: - rvm: jruby-1.7 env: JRUBY_OPTS='--dev --1.8' + - rvm: 2.7.1 + env: DIFF_LCS_VERSION="~> 1.3.0" allow_failures: - rvm: jruby-head - rvm: ruby-head diff --git a/Gemfile b/Gemfile index d8b30d910..198a555ce 100644 --- a/Gemfile +++ b/Gemfile @@ -21,6 +21,12 @@ else gem 'rake', '>= 12.3.3' end +if ENV['DIFF_LCS_VERSION'] + gem 'diff-lcs', ENV['DIFF_LCS_VERSION'] +else + gem 'diff-lcs', '~> 1.4', '>= 1.4.3' +end + if RUBY_VERSION < '2.2.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/) gem "childprocess", "< 1.0.0" elsif RUBY_VERSION < '2.3.0' From 73ab87a008418a3cdab445096c44490918cea9cf Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 28 Jun 2020 10:11:29 +0100 Subject: [PATCH 83/91] Improve diff formatting using dedent --- spec/rspec/support/differ_spec.rb | 337 ++++++++++++++++-------------- 1 file changed, 182 insertions(+), 155 deletions(-) diff --git a/spec/rspec/support/differ_spec.rb b/spec/rspec/support/differ_spec.rb index 524e815fa..91753c877 100644 --- a/spec/rspec/support/differ_spec.rb +++ b/spec/rspec/support/differ_spec.rb @@ -6,7 +6,7 @@ module RSpec module Support - describe Differ do + RSpec.describe Differ do # In the updated version of diff-lcs several diff headers change format slightly # compensate for this and change minimum version in RSpec 4 @@ -26,41 +26,43 @@ module Support actual = "foo\nbar\nzap\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nline\n" if Diff::LCS::VERSION.to_f < 1.4 - expected_diff = <<-'EOD' - - -@@ -1,6 +1,6 @@ - foo --zap - bar -+zap - this - is - soo -@@ -9,6 +9,5 @@ - equal - insert - a --another - line -EOD + expected_diff = dedent(<<-'EOD') + | + | + |@@ -1,6 +1,6 @@ + | foo + |-zap + | bar + |+zap + | this + | is + | soo + |@@ -9,6 +9,5 @@ + | equal + | insert + | a + |-another + | line + | + EOD else - expected_diff = <<-'EOD' - - -@@ -1,4 +1,6 @@ - foo --zap - bar -+zap - this -@@ -9,6 +11,7 @@ - equal - insert - a --another - line -EOD + expected_diff = dedent(<<-'EOD') + | + | + |@@ -1,4 +1,6 @@ + | foo + |-zap + | bar + |+zap + | this + |@@ -9,6 +11,7 @@ + | equal + | insert + | a + |-another + | line + | + EOD end @@ -130,7 +132,6 @@ def differ_ivars end if String.method_defined?(:encoding) - it "returns an empty string if strings are not multiline" do expected = "Tu avec carte {count} item has".encode('UTF-16LE') actual = "Tu avec carté {count} itém has".encode('UTF-16LE') @@ -143,12 +144,13 @@ def differ_ivars it 'copes with encoded strings', :skip => RSpec::Support::OS.windows? do expected = "Tu avec carte {count} item has\n".encode('UTF-16LE') actual = "Tu avec carté {count} itém has\n".encode('UTF-16LE') - expected_diff = <<-EOD.encode('UTF-16LE') - -@@ #{one_line_header} @@ --Tu avec carte {count} item has -+Tu avec carté {count} itém has -EOD + expected_diff = dedent(<<-EOD).encode('UTF-16LE') + | + |@@ #{one_line_header} @@ + |-Tu avec carte {count} item has + |+Tu avec carté {count} itém has + | + EOD diff = differ.diff(actual, expected) expect(diff).to be_diffed_as(expected_diff) @@ -186,16 +188,18 @@ def differ_ivars it "outputs unified diff message of two objects" do animal_class = Class.new do + include RSpec::Support::FormattingSupport + def initialize(name, species) @name, @species = name, species end def inspect - <<-EOA - + dedent(<<-EOA) + | EOA end end @@ -203,15 +207,16 @@ def inspect expected = animal_class.new "bob", "giraffe" actual = animal_class.new "bob", "tortoise" - expected_diff = <<'EOD' - -@@ -1,5 +1,5 @@ - -EOD + expected_diff = dedent(<<-'EOD') + | + |@@ -1,5 +1,5 @@ + | + | + EOD diff = differ.diff(expected,actual) expect(diff).to be_diffed_as(expected_diff) @@ -221,19 +226,20 @@ def inspect expected = [ :foo, 'bar', :baz, 'quux', :metasyntactic, 'variable', :delta, 'charlie', :width, 'quite wide' ] actual = [ :foo, 'bar', :baz, 'quux', :metasyntactic, 'variable', :delta, 'tango' , :width, 'very wide' ] - expected_diff = <<'EOD' - - -@@ -5,7 +5,7 @@ - :metasyntactic, - "variable", - :delta, -- "tango", -+ "charlie", - :width, -- "very wide"] -+ "quite wide"] -EOD + expected_diff = dedent(<<-'EOD') + | + | + |@@ -5,7 +5,7 @@ + | :metasyntactic, + | "variable", + | :delta, + |- "tango", + |+ "charlie", + | :width, + |- "very wide"] + |+ "quite wide"] + | + EOD diff = differ.diff(expected,actual) expect(diff).to be_diffed_as(expected_diff) @@ -251,23 +257,25 @@ def inspect; ""; end diff = differ.diff [obj], [] end - expected_diff = <<-EOD - -@@ #{one_line_header} @@ --[] -+[] -EOD + expected_diff = dedent(<<-EOD) + | + |@@ #{one_line_header} @@ + |-[] + |+[] + | + EOD expect(diff).to be_diffed_as(expected_diff) end it 'outputs unified diff message of strings in arrays' do diff = differ.diff(["a\r\nb"], ["a\r\nc"]) - expected_diff = <<-EOD - -@@ #{one_line_header} @@ --a\\r\\nc -+a\\r\\nb -EOD + expected_diff = dedent(<<-EOD) + | + |@@ #{one_line_header} @@ + |-a\\r\\nc + |+a\\r\\nb + | + EOD expect(diff).to be_diffed_as(expected_diff) end @@ -275,16 +283,17 @@ def inspect; ""; end expected = { :foo => 'bar', :baz => 'quux', :metasyntactic => 'variable', :delta => 'charlie', :width =>'quite wide' } actual = { :foo => 'bar', :metasyntactic => 'variable', :delta => 'charlotte', :width =>'quite wide' } - expected_diff = <<'EOD' - -@@ -1,4 +1,5 @@ --:delta => "charlotte", -+:baz => "quux", -+:delta => "charlie", - :foo => "bar", - :metasyntactic => "variable", - :width => "quite wide", -EOD + expected_diff = dedent(<<-'EOD') + | + |@@ -1,4 +1,5 @@ + |-:delta => "charlotte", + |+:baz => "quux", + |+:delta => "charlie", + | :foo => "bar", + | :metasyntactic => "variable", + | :width => "quite wide", + | + EOD diff = differ.diff(expected,actual) expect(diff).to be_diffed_as(expected_diff) @@ -295,16 +304,17 @@ def inspect; ""; end expected = [{ :foo => 'bar', :baz => 'quux', :metasyntactic => 'variable', :delta => 'charlie', :width =>'quite wide' }] actual = [{ :metasyntactic => 'variable', :delta => 'charlotte', :width =>'quite wide', :foo => 'bar' }] - expected_diff = <<'EOD' - -@@ -1,4 +1,5 @@ --[{:delta=>"charlotte", -+[{:baz=>"quux", -+ :delta=>"charlie", - :foo=>"bar", - :metasyntactic=>"variable", - :width=>"quite wide"}] -EOD + expected_diff = dedent(<<-'EOD') + | + |@@ -1,4 +1,5 @@ + |-[{:delta=>"charlotte", + |+[{:baz=>"quux", + |+ :delta=>"charlie", + | :foo=>"bar", + | :metasyntactic=>"variable", + | :width=>"quite wide"}] + | + EOD diff = differ.diff(expected,actual) expect(diff).to be_diffed_as(expected_diff) @@ -312,33 +322,39 @@ def inspect; ""; end end it 'outputs unified diff message of two hashes with differing encoding', :failing_on_appveyor do - expected_diff = %Q{ -@@ #{one_line_header} @@ --"a" => "a", -#{ (RUBY_VERSION.to_f > 1.8) ? %Q{+"ö" => "ö"} : '+"\303\266" => "\303\266"' }, -} + expected_diff = dedent(<<-"EOD") + | + |@@ #{one_line_header} @@ + |-"a" => "a", + |#{ (RUBY_VERSION.to_f > 1.8) ? %Q{+"ö" => "ö"} : '+"\303\266" => "\303\266"' }, + | + EOD diff = differ.diff({'ö' => 'ö'}, {'a' => 'a'}) expect(diff).to be_diffed_as(expected_diff) end it 'outputs unified diff message of two hashes with encoding different to key encoding', :failing_on_appveyor do - expected_diff = %Q{ -@@ #{one_line_header} @@ --:a => "a", -#{ (RUBY_VERSION.to_f > 1.8) ? %Q{+\"한글\" => \"한글2\"} : '+"\355\225\234\352\270\200" => "\355\225\234\352\270\2002"' }, -} + expected_diff = dedent(<<-"EOD") + | + |@@ #{one_line_header} @@ + |-:a => "a", + |#{ (RUBY_VERSION.to_f > 1.8) ? %Q{+\"한글\" => \"한글2\"} : '+"\355\225\234\352\270\200" => "\355\225\234\352\270\2002"' }, + | + EOD diff = differ.diff({ "한글" => "한글2"}, { :a => "a"}) expect(diff).to be_diffed_as(expected_diff) end it "outputs unified diff message of two hashes with object keys" do - expected_diff = %Q{ -@@ #{one_line_header} @@ --["a", "c"] => "b", -+["d", "c"] => "b", -} + expected_diff = dedent(<<-"EOD") + | + |@@ #{one_line_header} @@ + |-["a", "c"] => "b", + |+["d", "c"] => "b", + | + EOD diff = differ.diff({ ['d','c'] => 'b'}, { ['a','c'] => 'b' }) expect(diff).to be_diffed_as(expected_diff) @@ -349,22 +365,26 @@ def inspect; ""; end let(:formatted_time) { ObjectFormatter.format(time) } it "outputs unified diff message of two hashes with Time object keys" do - expected_diff = %Q{ -@@ #{one_line_header} @@ --#{formatted_time} => "b", -+#{formatted_time} => "c", -} + expected_diff = dedent(<<-"EOD") + | + |@@ #{one_line_header} @@ + |-#{formatted_time} => "b", + |+#{formatted_time} => "c", + | + EOD diff = differ.diff({ time => 'c'}, { time => 'b' }) expect(diff).to be_diffed_as(expected_diff) end it "outputs unified diff message of two hashes with hashes inside them" do - expected_diff = %Q{ -@@ #{one_line_header} @@ --"b" => {"key_1"=>#{formatted_time}}, -+"c" => {"key_1"=>#{formatted_time}}, -} + expected_diff = dedent(<<-"EOD") + | + |@@ #{one_line_header} @@ + |-"b" => {"key_1"=>#{formatted_time}}, + |+"c" => {"key_1"=>#{formatted_time}}, + | + EOD left_side_hash = {'c' => {'key_1' => time}} right_side_hash = {'b' => {'key_1' => time}} @@ -378,22 +398,26 @@ def inspect; ""; end let(:formatted_time) { ObjectFormatter.format(time) } it "outputs unified diff message of two arrays with Time object keys" do - expected_diff = %Q{ -@@ #{one_line_header} @@ --[#{formatted_time}, "b"] -+[#{formatted_time}, "c"] -} + expected_diff = dedent(<<-"EOD") + | + |@@ #{one_line_header} @@ + |-[#{formatted_time}, "b"] + |+[#{formatted_time}, "c"] + | + EOD diff = differ.diff([time, 'c'], [time, 'b']) expect(diff).to be_diffed_as(expected_diff) end it "outputs unified diff message of two arrays with hashes inside them" do - expected_diff = %Q{ -@@ #{one_line_header} @@ --[{"b"=>#{formatted_time}}, "c"] -+[{"a"=>#{formatted_time}}, "c"] -} + expected_diff = dedent(<<-"EOD") + | + |@@ #{one_line_header} @@ + |-[{"b"=>#{formatted_time}}, "c"] + |+[{"a"=>#{formatted_time}}, "c"] + | + EOD left_side_array = [{'a' => time}, 'c'] right_side_array = [{'b' => time}, 'c'] @@ -406,37 +430,40 @@ def inspect; ""; end expected = "this is:\n one string" actual = "this is:\n another string" - expected_diff = <<'EOD' - -@@ -1,3 +1,3 @@ - this is: -- another string -+ one string -EOD + expected_diff = dedent(<<-'EOD') + | + |@@ -1,3 +1,3 @@ + | this is: + |- another string + |+ one string + | + EOD diff = differ.diff(expected,actual) expect(diff).to be_diffed_as(expected_diff) end it "splits items with newlines" do - expected_diff = <<"EOD" - -@@ #{removing_two_line_header} @@ --a\\nb --c\\nd -EOD + expected_diff = dedent(<<-"EOD") + | + |@@ #{removing_two_line_header} @@ + |-a\\nb + |-c\\nd + | + EOD diff = differ.diff [], ["a\nb", "c\nd"] expect(diff).to be_diffed_as(expected_diff) end it "shows inner arrays on a single line" do - expected_diff = <<"EOD" - -@@ #{removing_two_line_header} @@ --a\\nb --["c\\nd"] -EOD + expected_diff = dedent(<<-"EOD") + | + |@@ #{removing_two_line_header} @@ + |-a\\nb + |-["c\\nd"] + | + EOD diff = differ.diff [], ["a\nb", ["c\nd"]] expect(diff).to be_diffed_as(expected_diff) From ca6729ad0c834d6d6204f6914771ed172b3aff70 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 28 Jun 2020 10:42:47 +0100 Subject: [PATCH 84/91] Add helper to support other libraries expecting diffs --- lib/rspec/support/spec.rb | 1 + lib/rspec/support/spec/diff_helpers.rb | 29 ++++++++++++++++++++++++++ spec/rspec/support/differ_spec.rb | 11 +--------- 3 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 lib/rspec/support/spec/diff_helpers.rb diff --git a/lib/rspec/support/spec.rb b/lib/rspec/support/spec.rb index 6db588b2a..bd998903e 100644 --- a/lib/rspec/support/spec.rb +++ b/lib/rspec/support/spec.rb @@ -2,6 +2,7 @@ require 'rspec/support/spec/in_sub_process' RSpec::Support.require_rspec_support "spec/deprecation_helpers" +RSpec::Support.require_rspec_support "spec/diff_helpers" RSpec::Support.require_rspec_support "spec/with_isolated_stderr" RSpec::Support.require_rspec_support "spec/stderr_splitter" RSpec::Support.require_rspec_support "spec/formatting_support" diff --git a/lib/rspec/support/spec/diff_helpers.rb b/lib/rspec/support/spec/diff_helpers.rb new file mode 100644 index 000000000..84e6fbf37 --- /dev/null +++ b/lib/rspec/support/spec/diff_helpers.rb @@ -0,0 +1,29 @@ +require 'diff/lcs' + +module RSpec + module Support + module Spec + module DiffHelpers + # In the updated version of diff-lcs several diff headers change format slightly + # compensate for this and change minimum version in RSpec 4 + if ::Diff::LCS::VERSION.to_f < 1.4 + def one_line_header(line_number=2) + "-1,#{line_number} +1,#{line_number}" + end + + def removing_two_line_header + "-1,3 +1" + end + else + def one_line_header(_=2) + "-1 +1" + end + + def removing_two_line_header + "-1,3 +1,5" + end + end + end + end + end +end diff --git a/spec/rspec/support/differ_spec.rb b/spec/rspec/support/differ_spec.rb index 91753c877..0700a74a8 100644 --- a/spec/rspec/support/differ_spec.rb +++ b/spec/rspec/support/differ_spec.rb @@ -7,16 +7,7 @@ module RSpec module Support RSpec.describe Differ do - - # In the updated version of diff-lcs several diff headers change format slightly - # compensate for this and change minimum version in RSpec 4 - if Diff::LCS::VERSION.to_f < 1.4 - one_line_header = "-1,2 +1,2" - removing_two_line_header = "-1,3 +1" - else - one_line_header = "-1 +1" - removing_two_line_header = "-1,3 +1,5" - end + include Spec::DiffHelpers describe '#diff' do let(:differ) { RSpec::Support::Differ.new } From fce6ef3f15a7ca0e368e44100fb6c921736efb1f Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Fri, 3 Jul 2020 16:58:22 +0100 Subject: [PATCH 85/91] Fix diff-lcs 1.4.4 --- lib/rspec/support/spec/diff_helpers.rb | 10 ++++++---- spec/rspec/support/differ_spec.rb | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/rspec/support/spec/diff_helpers.rb b/lib/rspec/support/spec/diff_helpers.rb index 84e6fbf37..76ef10a67 100644 --- a/lib/rspec/support/spec/diff_helpers.rb +++ b/lib/rspec/support/spec/diff_helpers.rb @@ -10,15 +10,17 @@ module DiffHelpers def one_line_header(line_number=2) "-1,#{line_number} +1,#{line_number}" end - - def removing_two_line_header - "-1,3 +1" - end else def one_line_header(_=2) "-1 +1" end + end + if Diff::LCS::VERSION.to_f < 1.4 || Diff::LCS::VERSION >= "1.4.4" + def removing_two_line_header + "-1,3 +1" + end + else def removing_two_line_header "-1,3 +1,5" end diff --git a/spec/rspec/support/differ_spec.rb b/spec/rspec/support/differ_spec.rb index 0700a74a8..4fc1ca2a4 100644 --- a/spec/rspec/support/differ_spec.rb +++ b/spec/rspec/support/differ_spec.rb @@ -16,7 +16,7 @@ module Support expected = "foo\nzap\nbar\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nanother\nline\n" actual = "foo\nbar\nzap\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nline\n" - if Diff::LCS::VERSION.to_f < 1.4 + if Diff::LCS::VERSION.to_f < 1.4 || Diff::LCS::VERSION >= "1.4.4" expected_diff = dedent(<<-'EOD') | | @@ -40,7 +40,7 @@ module Support expected_diff = dedent(<<-'EOD') | | - |@@ -1,4 +1,6 @@ + |@@ -1,6 +1,6 @@ | foo |-zap | bar @@ -65,7 +65,7 @@ module Support expected = "foo\nzap\nbar\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nanother\nline\n" actual = "foo\nbar\nzap\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nline\n" - if Diff::LCS::VERSION.to_f < 1.4 + if Diff::LCS::VERSION.to_f < 1.4 || Diff::LCS::VERSION >= "1.4.4" expected_diff = dedent(<<-'EOS') | | From 5443f309d49958227ba214406009e20fbbb967e2 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Fri, 3 Jul 2020 17:57:37 +0100 Subject: [PATCH 86/91] Restore diff for >= 1.4 < 1.4.4 --- .travis.yml | 2 ++ spec/rspec/support/differ_spec.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1eaad615f..3a33c6c15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,6 +40,8 @@ matrix: env: JRUBY_OPTS='--dev --1.8' - rvm: 2.7.1 env: DIFF_LCS_VERSION="~> 1.3.0" + - rvm: 2.7.1 + env: DIFF_LCS_VERSION="1.4.3" allow_failures: - rvm: jruby-head - rvm: ruby-head diff --git a/spec/rspec/support/differ_spec.rb b/spec/rspec/support/differ_spec.rb index 4fc1ca2a4..f27c169e9 100644 --- a/spec/rspec/support/differ_spec.rb +++ b/spec/rspec/support/differ_spec.rb @@ -40,7 +40,7 @@ module Support expected_diff = dedent(<<-'EOD') | | - |@@ -1,6 +1,6 @@ + |@@ -1,4 +1,6 @@ | foo |-zap | bar From bba249a0a5e13c64c12b6ed7a02de39aa568ebaa Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sat, 25 Jul 2020 16:55:47 +0100 Subject: [PATCH 87/91] Copy rspec/rspec#59 --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 71c762a86..b240b2fb3 100644 --- a/Rakefile +++ b/Rakefile @@ -17,7 +17,7 @@ task :default => [:spec] task :verify_private_key_present do private_key = File.expand_path('~/.gem/rspec-gem-private_key.pem') unless File.exist?(private_key) - raise "Your private key is not present. This gem should not be built without that." + raise "Your private key is not present. This gem should not be built without it." end end From efc7b46a6bb485de66f7a2a7d155437ef6b1d4b8 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 2 Aug 2020 02:53:33 +0100 Subject: [PATCH 88/91] Add deprecation message --- README.md | 39 +-------------------------------------- lib/rspec/support.rb | 2 ++ 2 files changed, 3 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 7bdde9c97..4a066618e 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,3 @@ # RSpec::Support -`RSpec::Support` provides common functionality to `RSpec::Core`, -`RSpec::Expectations` and `RSpec::Mocks`. It is considered -suitable for internal use only at this time. - -## Installation / Usage - -Install one or more of the `RSpec` gems. - -Want to run against the `master` branch? You'll need to include the dependent -RSpec repos as well. Add the following to your `Gemfile`: - -```ruby -%w[rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib| - gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'master' -end -``` - -## Contributing - -Once you've set up the environment, you'll need to cd into the working -directory of whichever repo you want to work in. From there you can run the -specs and cucumber features, and make patches. - -NOTE: You do not need to use rspec-dev to work on a specific RSpec repo. You -can treat each RSpec repo as an independent project. - -- [Build details](BUILD_DETAIL.md) -- [Code of Conduct](CODE_OF_CONDUCT.md) -- [Detailed contributing guide](CONTRIBUTING.md) -- [Development setup guide](DEVELOPMENT.md) - -## Patches - -Please submit a pull request or a github issue. If you submit an issue, please -include a link to either of: - -* a gist (or equivalent) of the patch -* a branch or commit in your github fork of the repo +This branch is deprecated, please use main`. diff --git a/lib/rspec/support.rb b/lib/rspec/support.rb index 4bbbc64cd..6a66eb180 100644 --- a/lib/rspec/support.rb +++ b/lib/rspec/support.rb @@ -1,3 +1,5 @@ +warn "This branch is deprecated. Please use `main`." + module RSpec module Support # @api private From c049086ab207ce2bd93a83f12c07344ef65044f0 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 2 Aug 2020 20:59:21 +0100 Subject: [PATCH 89/91] Ignore branch deprecation --- lib/rspec/support/spec/shell_out.rb | 1 + spec/rspec/support/warnings_spec.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rspec/support/spec/shell_out.rb b/lib/rspec/support/spec/shell_out.rb index d7409113a..16240b82f 100644 --- a/lib/rspec/support/spec/shell_out.rb +++ b/lib/rspec/support/spec/shell_out.rb @@ -72,6 +72,7 @@ def run_ruby_with_current_load_path(ruby_command, *flags) # These are related to the above, there is a warning about io from FFI %r{jruby-\d\.\d\.\d\.\d/lib/ruby/stdlib/io}, %r{io/console on JRuby shells out to stty for most operations}, + %r{This branch is deprecated\. Please use `main`\.}, ] def strip_known_warnings(input) diff --git a/spec/rspec/support/warnings_spec.rb b/spec/rspec/support/warnings_spec.rb index 5972819e5..db44ceb53 100644 --- a/spec/rspec/support/warnings_spec.rb +++ b/spec/rspec/support/warnings_spec.rb @@ -11,7 +11,7 @@ it 'works when required in isolation' do out, err, status = run_ruby_with_current_load_path("RSpec.deprecate('foo')", "-rrspec/support/warnings") expect(out).to eq("") - expect(err).to start_with("DEPRECATION: foo is deprecated") + expect(err).to include("DEPRECATION: foo is deprecated") expect(status.exitstatus).to eq(0) end From 46f001f43c48bf8b5241e6190ebb042c4b4823e0 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 2 Aug 2020 21:57:31 +0100 Subject: [PATCH 90/91] Refactor how warning filtering is applied --- lib/rspec/support/spec/library_wide_checks.rb | 2 +- lib/rspec/support/spec/shell_out.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/rspec/support/spec/library_wide_checks.rb b/lib/rspec/support/spec/library_wide_checks.rb index 56b059364..a70332ba8 100644 --- a/lib/rspec/support/spec/library_wide_checks.rb +++ b/lib/rspec/support/spec/library_wide_checks.rb @@ -68,7 +68,7 @@ def load_all_files(files, preamble, postamble=nil) run_ruby_with_current_load_path(command, *options) end - [stdout, strip_known_warnings(stderr), status.exitstatus] + [stdout, stderr, status.exitstatus] end define_method :load_all_lib_files do diff --git a/lib/rspec/support/spec/shell_out.rb b/lib/rspec/support/spec/shell_out.rb index 16240b82f..843188315 100644 --- a/lib/rspec/support/spec/shell_out.rb +++ b/lib/rspec/support/spec/shell_out.rb @@ -47,10 +47,12 @@ def run_ruby_with_current_load_path(ruby_command, *flags) # Unset these env vars because `ruby -w` will issue warnings whenever # they are set to non-default values. - with_env 'RUBY_GC_HEAP_FREE_SLOTS' => nil, 'RUBY_GC_MALLOC_LIMIT' => nil, - 'RUBY_FREE_MIN' => nil do - shell_out(*command) - end + stdout, stderr, status = + with_env 'RUBY_GC_HEAP_FREE_SLOTS' => nil, 'RUBY_GC_MALLOC_LIMIT' => nil, + 'RUBY_FREE_MIN' => nil do + shell_out(*command) + end + [stdout, strip_known_warnings(stderr), status] end LINES_TO_IGNORE = From 6447b0c2c9d1cd3e1504784fb85675ca9ae7b7c3 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 2 Aug 2020 22:11:28 +0100 Subject: [PATCH 91/91] Refactor warnings further to pass rubocop --- lib/rspec/support/spec/shell_out.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/rspec/support/spec/shell_out.rb b/lib/rspec/support/spec/shell_out.rb index 843188315..70ed6bcf6 100644 --- a/lib/rspec/support/spec/shell_out.rb +++ b/lib/rspec/support/spec/shell_out.rb @@ -47,11 +47,11 @@ def run_ruby_with_current_load_path(ruby_command, *flags) # Unset these env vars because `ruby -w` will issue warnings whenever # they are set to non-default values. - stdout, stderr, status = - with_env 'RUBY_GC_HEAP_FREE_SLOTS' => nil, 'RUBY_GC_MALLOC_LIMIT' => nil, - 'RUBY_FREE_MIN' => nil do - shell_out(*command) - end + stdout, stderr, status = with_env 'RUBY_GC_HEAP_FREE_SLOTS' => nil, + 'RUBY_GC_MALLOC_LIMIT' => nil, + 'RUBY_FREE_MIN' => nil do + shell_out(*command) + end [stdout, strip_known_warnings(stderr), status] end