[ENHANCEMENT] Set trim mode to honor dash #840

hron84 opened this Issue Mar 22, 2013 · 6 comments


None yet
4 participants

hron84 commented Mar 22, 2013

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

<% if test -%>
<% end -%>

samphippen commented Mar 26, 2013

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


soulcutter commented Mar 26, 2013

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


hron84 commented Mar 26, 2013

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 commented Mar 26, 2013

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 commented Mar 26, 2013

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


hron84 commented Mar 26, 2013

I added a PR to this topic, see #846

@myronmarston myronmarston added a commit that referenced this issue Mar 31, 2013

@myronmarston myronmarston Merge pull request #846 from hron84/feature-erb-trim
Adding trim option to ERB, closes #840

@soulcutter soulcutter added a commit to soulcutter/rspec-core that referenced this issue Apr 7, 2013

@hron84 @soulcutter hron84 + soulcutter 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