spec/view_matchers_spec.rb in suhyo-0.0.5 vs spec/view_matchers_spec.rb in suhyo-0.0.6

- old
+ new

@@ -74,18 +74,25 @@ end it 'tells the expected order in the error message' do lambda do '<p>Bar</p><p>Foo</p>'.should contain_in_order('Foo', :before => 'Bar') - end.should raise_error(Spec::Expectations::ExpectationNotMetError, /expected the following element's content to include "Foo" before "Bar":/) + end.should raise_error(Spec::Expectations::ExpectationNotMetError, /^expected the following element's content to include "Foo" before "Bar":/) end it 'tells you if the reference content is missing' do lambda do '<p>Foo</p><p>...</p>'.should contain_in_order('Foo', :before => 'Bar') - end.should raise_error(Spec::Expectations::ExpectationNotMetError, /expected the following element's content to include "Foo" before "Bar" but "Bar" was not found:/) + end.should raise_error(Spec::Expectations::ExpectationNotMetError, /^expected the following element's content to include "Foo" before "Bar" but "Bar" was not found:/) end + + # Bug fix + it 'does not falsely tell you the reference content is missing when the main content is missing' do + lambda do + '<p>...</p><p>Bar</p>'.should contain_in_order('Foo', :before => 'Bar') + end.should raise_error(Spec::Expectations::ExpectationNotMetError, /^expected the following element\'s content to include "Foo" before "Bar":/) + end end context 'matching after' do it 'matches when the content is in the right order' do '<p>Foo</p><p>Bar</p>'.should contain_in_order('Bar', :after => 'Foo') @@ -104,16 +111,23 @@ end it 'tells the expected order in the error message' do lambda do '<p>Foo</p><p>Bar</p>'.should contain_in_order('Foo', :after => 'Bar') - end.should raise_error(Spec::Expectations::ExpectationNotMetError, /expected the following element's content to include "Foo" after "Bar":/) + end.should raise_error(Spec::Expectations::ExpectationNotMetError, /^expected the following element's content to include "Foo" after "Bar":/) end it 'tells you if the reference content is missing' do lambda do '<p>...</p><p>Foo</p>'.should contain_in_order('Foo', :after => 'Bar') - end.should raise_error(Spec::Expectations::ExpectationNotMetError, /expected the following element's content to include "Foo" after "Bar" but "Bar" was not found:/) + end.should raise_error(Spec::Expectations::ExpectationNotMetError, /^expected the following element's content to include "Foo" after "Bar" but "Bar" was not found:/) + end + + # Bug fix + it 'does not falsely tell you the reference content is missing when the main content is missing' do + lambda do + '<p>Bar</p><p>...</p>'.should contain_in_order('Foo', :after => 'Bar') + end.should raise_error(Spec::Expectations::ExpectationNotMetError, /^expected the following element's content to include "Foo" after "Bar":/) end end end describe '#have_restful_form' do