require 'spec_helper' describe String do describe '#rdiff' do it 'should return the common parts between self and another string' do str = <<-END This is the first test. Not really sure what else to put here... END str2 = <<-END This is the second test. Not really sure what else to put here... Boo-Yah! END str.rdiff( str2 ).should == " This is the test.\n" + " Not really sure what else to put here" end end describe '#diff_ratio' do context 'when the strings are identical' do it 'returns 0.0' do 'test'.diff_ratio( 'test' ).should == 0 'test this'.diff_ratio( 'test this' ).should == 0 end end context 'when the strings completely different' do it 'returns 1.0' do 'test'.diff_ratio( 'toast' ).should == 1 'test this'.diff_ratio( 'toast that' ).should == 1 end end context 'when the strings share less than half of their words' do it 'returns < 0.5' do 'test this here now'.diff_ratio( 'test that here now' ).should > 0.0 'test this here now'.diff_ratio( 'test that here now' ).should < 0.5 end end context 'when the strings share more than half of their words' do it 'returns > 0.5' do 'test this here now'.diff_ratio( 'test that here later' ).should > 0.0 'test this here now'.diff_ratio( 'test that here later' ).should > 0.5 end end end describe '#words' do context 'when strict is set to true' do it 'does not include boundaries' do 'blah.bloo