spec/view_matchers_spec.rb in suhyo-0.0.2 vs spec/view_matchers_spec.rb in suhyo-0.0.3
- old
+ new
@@ -35,9 +35,47 @@
it 'does not match when the ancestors are wrong' do
'<a href="http://example.com">Foo</a>'.should_not have_link(:ancestors => 'div#main')
end
end
+ describe '#contain_in_order' do
+ context 'matching before' do
+ it 'matches when the content is in the right order' do
+ '<p>Foo</p><p>Bar</p>'.should contain_in_order('Foo', :before => 'Bar')
+ end
+
+ it 'does not match when the content is in the reverse order' do
+ '<p>Bar</p><p>Foo</p>'.should_not contain_in_order('Foo', :before => 'Bar')
+ end
+
+ it 'does not match when the first content is missing' do
+ '<p>...</p><p>Bar</p>'.should_not contain_in_order('Foo', :before => 'Bar')
+ end
+
+ it 'does not match when the second content is missing' do
+ '<p>Foo</p><p>...</p>'.should_not contain_in_order('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')
+ end
+
+ it 'does not match when the content is in the reverse order' do
+ '<p>Bar</p><p>Foo</p>'.should_not contain_in_order('Bar', :after => 'Foo')
+ end
+
+ it 'does not match when the first content is missing' do
+ '<p>Foo</p><p>...</p>'.should_not contain_in_order('Bar', :after => 'Foo')
+ end
+
+ it 'does not match when the second content is missing' do
+ '<p>...</p><p>Bar</p>'.should_not contain_in_order('Bar', :after => 'Foo')
+ end
+ end
+ end
+
describe '#have_restful_form' do
def restful_form(method)
case method
when 'get'
browser_method = 'get'