-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add rubocop and drop support for Rubies < 2.0 #124
Conversation
1d785e0
to
ccc9b89
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for this! I didn't expect help on 4.0 so quickly! Most of this looks great; I just had a few questions. Also, could you please rebase this against the very little pending work I've done in the v4
branch? Thank you!
@@ -25,7 +25,8 @@ def build_organizer(options = {}, &block) | |||
# └─ interactor5 | |||
|
|||
let(:organizer) { | |||
build_organizer(organize: [organizer2, interactor3, organizer4, interactor5]) do | |||
interactors = [organizer2, interactor3, organizer4, interactor5] | |||
build_organizer(organize: interactors) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are this and the similar changes below just a line length concern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm all for the 80 character limit but I typically relax that rule a bit for specs. But maybe I shouldn't!
spec/integration_spec.rb
Outdated
raise "foo" | ||
context.steps << :around_before | ||
interactor.call | ||
context.steps << :around_after |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it may seem obvious to Rubocop, there's some value in the assertion that these lines are not called, even after a raise
. This applies to several of the changes below as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to discussion on this point!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I see your point. I thought about smth like this:
def unexpected_error!
raise "foo"
end
It may be more intention-revealing (the "unexpected" nature), but plain raise
is far simpler and understable. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like your use of unexpected_error!
although we might have to define that method within the interactor's definition in the spec rather than as a helper method in the spec, which muddies the waters a little bit.
spec/support/lint.rb
Outdated
expect(Interactor::Context).to receive(:build).once.with(foo: "bar") { context } | ||
expect( | ||
Interactor::Context | ||
).to receive(:build).once.with(foo: "bar") { context } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a line length concern, would Rubocop accept this style:
expect(Interactor::Context).to receive(:build)
.once.with(foo: "bar") { context }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
@@ -1,19 +1,24 @@ | |||
# encoding: utf-8 | |||
require "English" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I didn't know about this!
interactor.gemspec
Outdated
spec.test_files = spec.files.grep(/^spec/) | ||
|
||
spec.required_ruby_version = ">= 2.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 🏆 💐 🥇
interactor.gemspec
Outdated
spec.add_development_dependency "bundler", "~> 1.7" | ||
spec.add_development_dependency "rake", "~> 10.3" | ||
spec.add_development_dependency "rubocop", "~> 0.47.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather put this dependency in the Gemfile
and keep the gemspec dependencies to only bundler
and rake
.
lib/interactor.rb
Outdated
@@ -153,14 +153,12 @@ def run! | |||
# each interactor class. | |||
# | |||
# Returns nothing. | |||
def call | |||
end | |||
def call; end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of this, but I suppose if the community has spoken! 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rubocop default settings are easily adjustable to project's needs. I'll remove this change.
Actually, this may need to be reopened as a PR against the |
I've added replies to your comments; some of them require further discussion. I'll close this PR and reopen a new one on Thank you for a quick response 😄 |
Actually, it's possible to just change base branch via github UI. Closed this too rashly 😄 |
I used the GitHub web UI to resolve conflicts with the |
Changes in last commit:
About Ruby versions: support for required keyword arguments appeared only in 2.1. I think we'll definitely need them if we're going to implement #123. |
@hedgesky Your changes look really good. You said in your comment that keyword arguments appeared in Ruby 2.1, but I'm seeing otherwise. You're absolutely right though that keyword arguments will most likely be required so that would be the right reason to scope the Ruby version in the gemspec. It seems like we'll need to scope it to |
Yeah, keyword arguments appeared in 2.0, but I told about def foo(bar:)
puts bar
end They appeared in 2.1. Both your link and official changelog on Ruby github mentions that. |
It could be that even though required keyword arguments would be a big win for Interactor 4, they might not be strictly necessary because the structure of the keyword arguments is up to the developer when they define the |
I suggest delaying the decision about 2.0/2.1 until we have more information about Interactor 4 implementation details. For now we can just stick with 2.0. |
@hedgesky Yes, that sounds fine, but let's make one change then. If we'll target Ruby 2.0 for now, let's add 2.0 back to |
@hedgesky Looks good. Is there anything else you want to add before I merge? |
Nope, that's all. Go right ahead 😄 |
@hedgesky Absolutely, I hope you don't feel like you're off the hook now! 😄 You've been a big help already and I know I'll need help to get 4.0 out the door. 🚀 |
Looks like I'm going to work on |
This PR consists of two commits. First one introduces following changes:
rubocop
as a dev dependency (use conservative version locking as official manual advises;.rubocop.yml
config;rake
task;travis.yml
to runrake
instead ofrspec
When first commit failed Travis checks I realized that fresh Rubocop requires only Ruby >= 2.0. Keeping in mind that there is a plan to drop support for Rubies < 2.1 in Interactor 4.0, I've decided to update this PR accordingly.
So the second commit does following:
required_ruby_version = ">= 2.1"
in gemspec.