Skip to content

Instantly share code, notes, and snippets.

@dzaporozhets
Forked from PotHix/gist:640517
Created May 22, 2012 17:25
Show Gist options
  • Save dzaporozhets/2770405 to your computer and use it in GitHub Desktop.
Save dzaporozhets/2770405 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'
grep "should belong_to :.*class_name.*" spec/* -Ril | xargs sed -i "s/should belong_to :\([a-z_=>]*\),.*:class_name => '\(.*\)'\ .*/should belong_to(:\1).class_name('\\2'\) }/g"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment