sed skills

sed skills coming along…

filenum=1
find . -type f -name '*_spec.rb' | while read file; do
  mkdir -p ../_spec_seded/"${file%/*}"
  echo "next file...$filenum...$file"
  let filenum+=1
  cp "$file" ../_spec_seded/"$file"

  sed -i '/[[:space:]]*it.*do/! {
            /.should/ {
              s/.should/).to/
              /[^}.to|end.to].to[[:space:]]/ s/(S)/expect(1/
              /[^}.to|end.to].to_not[[:space:]]/ s/(S)/expect(1/
            }
            /.to ==[^=]/s/==/eq/
            /=~/ {
              s/=~/match(/
              s/$/ )/
            }
            s/[^}.to|end.to].to[[:space:]]/).to /
            s/to_receive/to receive/
            s/to_not_receive/to_not receive/
            /.to eq {/ {
              s/eq {/eq ({ /
              s/$/ )/
            }
            /.to match( [.*] )/s/to match/to match_array/
          }' ../_spec_seded/"$file"
done

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s