o2oyrg
Last Updated: February 25, 2016
·
1.371K
· oivoodoo

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

5626

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 ·
5634

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

over 1 year ago ·
21873

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

over 1 year ago ·