Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Ruby 2.7 support #392

Merged
merged 4 commits into from
Dec 27, 2019
Merged

Conversation

JonRowe
Copy link
Member

@JonRowe JonRowe commented Dec 26, 2019

These are some updates, generated from rspec-dev's rake tasks.

@JonRowe JonRowe force-pushed the update-travis-build-scripts-2019-12-26-for-master branch 4 times, most recently from 02255e1 to f9a3fae Compare December 26, 2019 21:17
@JonRowe JonRowe force-pushed the update-travis-build-scripts-2019-12-26-for-master branch from f9a3fae to b2f4a68 Compare December 26, 2019 21:25
@JonRowe JonRowe changed the title Updates from rspec-dev (2019-12-26) Ruby 2.7 support Dec 26, 2019
@JonRowe JonRowe force-pushed the update-travis-build-scripts-2019-12-26-for-master branch from c907307 to 56ce2e4 Compare December 27, 2019 10:42
@JonRowe JonRowe requested review from benoittgt and pirj December 27, 2019 17:24
@JonRowe
Copy link
Member Author

JonRowe commented Dec 27, 2019

The major change here is removing the warning by using **kwargs which is not universally compatible, hence the eval (ick) defined methods, I'm open to better solutions here but we are calling keyword arguments and there is no every Ruby parseable way to define this I know of.

Copy link
Member

@pirj pirj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I can't think of a better way around having code that is not supported by older parser.

@@ -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:}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvz you might be interested

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pirj. This is fixed in Aruba 0.14.14.

@JonRowe JonRowe force-pushed the update-travis-build-scripts-2019-12-26-for-master branch from 56ce2e4 to 0930546 Compare December 27, 2019 20:47
@JonRowe JonRowe merged commit 9d0482b into master Dec 27, 2019
@JonRowe JonRowe deleted the update-travis-build-scripts-2019-12-26-for-master branch December 27, 2019 21:42
JonRowe added a commit that referenced this pull request Dec 27, 2019
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__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Jon for the patch.
That's sad we have to do that to deal with Ruby 2.7.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I can't think of another away around it except having an extra file thats not required by the older build... I'm unsure if I like that less...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes me too. The comments help for this part.

Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While fixing 2.7 compatibility for aruba, I found you can still pass the keyword arguments as a 1.8-style hash literal. This would allow getting rid of the eval. You would also lose the constants though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvz I think that depends on the API in use, I tried the hash directly with String#encode and it still produces the warning.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JonRowe I'm not sure how that happened, but I just had to try as well and it seems to work here too: #394.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂

2.7.0 > "abc".encode("UTF-8", {:invalid => :replace})
(irb):2: warning: Using the last argument as keyword parameters is deprecated
 => "abc"
2.7.0 > "abc".encode("UTF-8", :invalid => :replace)
 => "abc"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂

yujinakayama pushed a commit to yujinakayama/rspec-monorepo that referenced this pull request Oct 6, 2021
…e-travis-build-scripts-2019-12-26-for-master

Ruby 2.7 support

---
This commit was imported from rspec/rspec-support@97ea7a0.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants