Is there a way to break long RSpec line to two separate lines:
expect(....).to
eq(.....)
?
Update:
Now I have an error:
Failure/Error: expect(@query_builder.questions_from_time(@time_to_test)).to ArgumentError: The expect syntax does not support operator matchers, so you must pass a matcher to
#to
.
The error is disappeared if I remove line break
to
is technically just a method, but the common style is to leave off the parenthesis on the to
method in rspec. However, it seems the Ruby parser just doesn't realize you're attempting to send an argument to that to
method if you separate it to a new line without parenthesis.
Any of the following should work…
expect(....).
to eq(.....)
or
expect(....)
.to eq(.....)
or
expect(....).to eq(
.....
)
or
expect(
....
).to eq(.....)
or
expect(
....
).to eq(
.....
)
I guess the long and short of it is just "don't break before an argument that isn't surrounded by parenthesis". As to which one of these to use — it depends on the particular code. I would do whatever is easiest to read and keeps the line length fairly short.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With