Last Updated: February 25, 2016
·
1.503K
· Alexandr K

vim regexp for replacing rspec 'should' style with 'expect().to' for eq example.

Replace Pattern:

%s/\(\S\+\).should\(\s\+\)==\s*\(.\+\)/expect(\1).to\2eq(\3)/

Before:

row.day.should == 'value'

After:

expect(row.day).to eq('value')

3 Responses
Add your response

I'm not quite sure why the expect syntax is that much better.

row.day.should eq 'value' seems much more readable. I would love to hear from you why you use 'expect'.

over 1 year ago ·

As for me it's more readable like a sentence. I think it depends on a developer anyway.

over 1 year ago ·

I think the point is to eliminate 'should'. One less syntax sugar

over 1 year ago ·