Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[ENHANCEMENT] Set trim mode to honor dash #840

Closed
hron84 opened this Issue · 6 comments

4 participants

@hron84

It would be nice if .rspec could accept the following snippet:

<% if test -%>
--color
<% end -%>
--another-option
@samphippen
Collaborator

I'm not quite sure I understand this. Can you expand your request a little?

@soulcutter
Collaborator

If I understand correctly, erb parsing would produce a single line in this example?

@hron84

The dash in ERB means no line break. If dash is at the ERB tag opening then no line break before the code if at end, not line break after.

So in the previous example: if test fails, it produces one line instead of two empty line + one line (--another-option), if test succeeds it produces two line instead of four with two empty (1st and 3rd).

@myronmarston

We're rendering the .rspec file as ERB using the main ERB rendering API documented on the rdoc page. Not sure what else we can do here.

I think the ERB rendering is nice but this seems like a bit of an abuse of it, honestly. If you want conditional options I recommend you put them in an RSpec.configure block because then you're 100% in ruby land and there's no weird ruby/ERB/options-parsing semantics.

Alternately, you can put personal options in ~/.rspec or your personal options for one project in .rspec-local.

Do these meet your needs, @hron84?

@hron84

I mean to this. My problem is not with options, but with parsing .rspec file itself.

@hron84

I added a PR to this topic, see #846

@soulcutter soulcutter referenced this issue from a commit in soulcutter/rspec-core
@hron84 hron84 Adding trim option to ERB, closes #840 9adfb51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.