Skip to content

Instantly share code, notes, and snippets.

@PotHix
Created October 22, 2010 13:19
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save PotHix/640517 to your computer and use it in GitHub Desktop.
Save PotHix/640517 to your computer and use it in GitHub Desktop.
remarkable -> shoulda sed helpers :P
grep "should_have_many" spec/* -Ril | xargs sed -i "s/should_have_many\(.*\)/it { should have_many\1 }/g"
grep "should_have_one" spec/* -Ril | xargs sed -i "s/should_have_one\(.*\)/it { should have_one\1 }/g"
grep "should_belong_to" spec/* -Ril | xargs sed -i "s/should_belong_to\(.*\)/it { should belong_to\1 }/g"
grep "should_validate_presence_of.*" spec/* -Ril | xargs sed -i "s/should_validate_presence_of\(.*\)/it { should validate_presence_of\1 }/g"
grep "should_validate_uniqueness_of.*" spec/* -Ril | xargs sed -i "s/should_validate_uniqueness_of\(.*\)/it { should validate_uniqueness_of\1 }/g"
grep "should_validate_numericality_of.*" spec/* -Ril | xargs sed -i "s/should_validate_numericality_of\(.*\)/it { should validate_numericality_of\1 }/g"
grep "should_validate_acceptance_of.*" spec/* -Ril | xargs sed -i "s/should_validate_acceptance_of\(.*\)/it { should validate_acceptance_of\1 }/g"
grep "should have_many :.*through.*" spec/* -Ril | xargs sed -i 's/should have_many :\([a-z_=>]*\),.*:through => :\(.*\) .*/should have_many(:\1).through(:\2) }/g'
grep "should have_many :.*dependent.*" spec/* -Ril | xargs sed -i 's/should have_many :\([a-z_=>]*\),.*:dependent => :\(.*\) .*/should have_many(:\1).dependent(:\2) }/g'
grep "should have_one :.*dependent.*" spec/* -Ril | xargs sed -i 's/should have_one :\([a-z_=>]*\),.*:dependent => :\(.*\) .*/should have_one(:\1).dependent(:\2) }/g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment