-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix Style/BlockDelimiters #1224
Conversation
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.
Couple of syntatical observations
lib/cucumber/formatter/junit.rb
Outdated
@@ -25,15 +25,16 @@ def initialize(config) | |||
config.on_event :test_run_finished, &method(:on_test_run_finished) | |||
@reportdir = ensure_dir(config.out_stream, 'junit') | |||
@config = config | |||
@features_data = Hash.new { |h,k| h[k] = { | |||
@features_data = Hash.new do |h,k| h[k] = { |
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.
whilst not in this cop, probably worth doing |h, k|
just whilst you're here. Also line 35 can go to new syntax if you're inclined
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.
All set on this. :)
@@ -49,9 +49,9 @@ | |||
end | |||
|
|||
it 'does not raise an error' do | |||
expect { | |||
expect 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.
possible 1 liner?
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.
Got it!
spec/cucumber/formatter/json_spec.rb
Outdated
@@ -550,8 +550,8 @@ module Formatter | |||
FEATURE | |||
|
|||
define_steps do | |||
Given(/^there are bananas$/) { data = 'YWJj' | |||
embed data, 'mime-type;base64' } | |||
Given(/^there are bananas$/) do data = 'YWJj' |
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.
Like below, Given end typically are your wrappers, so I'd have them distinct. Move end:554
to 555
?
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.
That's a weird one- don't know how that happened! Nice catch!
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.
For some weird reason the json_spec file seems very fragile and without that extra line under my change, some of the tests following that one fail.
spec/cucumber/rake/forked_spec.rb
Outdated
@@ -36,8 +36,8 @@ module Rake | |||
context 'when running without bundler' do | |||
let(:bundler) { false } | |||
|
|||
subject { Task::ForkedCucumberRunner.new( | |||
libs, binary, cucumber_opts, bundler, feature_files) } | |||
subject do Task::ForkedCucumberRunner.new( |
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.
do
and end
are the starting arguments and distinct like above. I'll leave the rest out.
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.
All set on this one
Will work to fix conflicts today if I can! Also, @luke-hill Thanks for the feedback, I'll also work on your changes when I get to this PR. :) |
Given(/^there are bananas$/) { data = 'YWJj' | ||
embed data, 'mime-type;base64' } | ||
Given(/^there are bananas$/) { embed('YWJj', 'mime-type;base64') } | ||
|
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.
Rogue line
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.
@luke-hill This line has to be here otherwise random tests after this one fail. Seems to be a really fragile file. :( We can work on fixing that in another issue.
spec/cucumber/rake/forked_spec.rb
Outdated
subject { Task::ForkedCucumberRunner.new( | ||
libs, binary, cucumber_opts, bundler, feature_files) } | ||
subject do Task::ForkedCucumberRunner.new( | ||
libs, binary, cucumber_opts, bundler, feature_files) 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.
think the end here should be newlined?
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 can try new lining it, but given my comment on json_spec, it may break things. Technically, it should just be a one-line request, but I think it's on two due to line-length. :grumble:
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.
Nevermind, things are fine after changing.
spec/cucumber/formatter/html_spec.rb
Outdated
@formatter.feature_name('Feature', '') | ||
}).not_to raise_error | ||
end).not_to raise_error |
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.
One way to get this to read a little easier is to try keeping the "stabby lambda" and having it on 1 line:
expect(->{ @formatter.feature_name('Feature', '') }).not_to raise_error
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.
All set here!
Interceptor::Pipe.wrap(:nonsense) | ||
}.to raise_error(ArgumentError) | ||
end.to raise_error(ArgumentError) |
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.
Perhaps this also reads easy on 1 line?
expect { Interceptor::Pipe.wrap(:nonsense) }.to raise_error(ArgumentError)
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.
All set here!
Interceptor::Pipe.unwrap!(:nonsense) | ||
}.to raise_error(ArgumentError) | ||
end.to raise_error(ArgumentError) |
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.
And, this too. You see what I'm trying to achieve, I hope.
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 totally do. The project looks like it may need a larger rspec update to bring it up to speed stylistically. Thanks!
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.
All set here!
run_defined_feature | ||
}).to raise_error(Junit::UnNamedFeatureError) | ||
end).to raise_error(Junit::UnNamedFeatureError) |
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.
Oh, this would also read easier to me as a single-line
expect(->{ run_defined_feature }).to raise_error(Junit::UnNamedFeatureError)
Oh, blast. So many instances of the same thing. Where I'm trying to go is: The two forms of anonymous methods in Ruby can stylistically be used in two distinct forms: as inline, or as multiline block.
|
Yeh thats a good point ☝️ Wasn't sure how you've been tackling these whether manually or through some |
Thanks, you two! I'll get these handled. :) |
@@ -88,17 +88,17 @@ module MultilineArgument | |||
end | |||
|
|||
it 'should pass silently if a mapped column does not exist in non-strict mode' do | |||
expect { | |||
expect 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.
Leaving these as they're multi-line
@olleolleolle Are we good to go here? :D |
I'm going to merge this, now! 👍 |
Woot! Thanks! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Details
{...}
for single line blocks anddo..end
for multi-line blocks.Motivation and Context
Working to help solve issue 1021!
How Has This Been Tested?
bundle exec rake
👍Types of changes