Permalink
Browse files

Changing the test in order to drive a switch to selectors, instead of…

… only table ids.
  • Loading branch information...
1 parent f9503ab commit 5c84e9db50c85e78ccb825a9b93f0c3caa51b2e9 bendycode committed Jul 12, 2009
Showing with 8 additions and 8 deletions.
  1. +8 −8 spec/table_matcher_spec.rb
View
16 spec/table_matcher_spec.rb
@@ -4,20 +4,20 @@
describe 'with <thead> and <tbody> elements' do
it 'should find header and body rows' do
response = mock_model(Object, :body => '<table id="my_id"><thead><tr><th>h1</th><th>h2</th></tr></thead><tbody><tr><td>c1</td><td>c2</td></tr></tbody></table>')
- response.should have_table('my_id', [['h1', 'h2'], ['c1', 'c2']])
+ response.should have_table('#my_id', [['h1', 'h2'], ['c1', 'c2']])
end
end
describe 'without <thead> and <tbody> elements' do
it 'should work' do
response = mock_model(Object, :body => '<table id="my_id"><tr><th>h1</th><th>h2</th></tr><tr><td>c1</td><td>c2</td></tr></table>')
- response.should have_table('my_id', [['h1', 'h2'], ['c1', 'c2']])
+ response.should have_table('#my_id', [['h1', 'h2'], ['c1', 'c2']])
end
describe 'with extraneous multiline whitespace' do
it 'should remove extraneous whitespace' do
response = mock_model(Object, :body => "<table id=\"my_id\"><tr><th>h1</th><th>h2</th></tr><tr><td>\n c1a\n \t<br/> \tc1b</td><td>c2</td></tr></table>")
- response.should have_table('my_id', [['h1', 'h2'], ["c1a\nc1b", 'c2']])
+ response.should have_table('#my_id', [['h1', 'h2'], ["c1a\nc1b", 'c2']])
end
end
end
@@ -35,38 +35,38 @@
describe 'passed wrong id' do
it 'should not match' do
response = mock_model(Object, :body => '<table id="my_id"><tr><td>c1</td><td>c2</td></tr></table>')
- response.should_not have_table('wrong_id', [['c1', 'c2']])
+ response.should_not have_table('#wrong_id', [['c1', 'c2']])
end
end
describe 'passed non-matching expected' do
it 'should not match' do
response = mock_model(Object, :body => '<table id="my_id"><tr><td>c1</td><td>c2</td></tr></table>')
- response.should_not have_table('my_id', [['c3', 'c2']])
+ response.should_not have_table('#my_id', [['c3', 'c2']])
end
end
describe 'with normal failure' do
it 'should raise ExpectationNotMetError with correct message' do
response = mock_model Object, :body => 'Some non-matching HTML'
lambda do
- response.should have_table('my_id', [['c1', 'c2']])
+ response.should have_table('#my_id', [['c1', 'c2']])
end.should raise_error(Spec::Expectations::ExpectationNotMetError, "\nWrong table contents.\nexpected: [[\"c1\", \"c2\"]]\n found: []\n\n")
end
end
describe 'with negative failure' do
it 'should raise ExpectationNotMetError' do
response = mock_model Object, :body => '<table id="my_id"><tr><td>c1</td><td>c2</td></tr></table>'
- lambda{response.should_not have_table('my_id', [['c1', 'c2']])}.should raise_error(Spec::Expectations::ExpectationNotMetError,
+ lambda{response.should_not have_table('#my_id', [['c1', 'c2']])}.should raise_error(Spec::Expectations::ExpectationNotMetError,
"\nTable should not have matched: [[\"c1\", \"c2\"]]\n")
end
end
describe 'passed nil expected' do
it 'should raise error' do
response = mock_model(Object, :body => '<table id="my_id"><tr><td>c1</td><td>c2</td></tr></table>')
- lambda{ response.should have_table('my_id', nil)}.should raise_error(RuntimeError, 'Invalid "expected" argument')
+ lambda{ response.should have_table('#my_id', nil)}.should raise_error(RuntimeError, 'Invalid "expected" argument')
end
end
end

0 comments on commit 5c84e9d

Please sign in to comment.