Skip to content

Commit

Permalink
Removed unused test directory and changed table_body_matcher to make …
Browse files Browse the repository at this point in the history
…the table_id optional. [#9 state:resolved responsible:Stephen]
  • Loading branch information
Stephen Anderson committed Sep 27, 2008
1 parent 69aac9b commit be2bcfa
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/html_matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def have_table_header table_id, expected
TableHeaderMatcher.new table_id, expected
end

def have_table_body table_id, expected
TableBodyMatcher.new table_id, expected
def have_table_body table_id_or_expected, expected = nil
TableBodyMatcher.new table_id_or_expected, expected
end

def have_td_link target_id, expected_link, expected_text
Expand Down
11 changes: 8 additions & 3 deletions lib/matchers/table_body_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ module Spec # :nodoc:
module Rails
module Matchers
class TableBodyMatcher
def initialize table_id, expected
@table_id = table_id
@expected = expected
def initialize table_id_or_expected, expected
case table_id_or_expected
when String
@table_id = table_id_or_expected
@expected = expected
when Array
@expected = table_id_or_expected
end
end
def matches? response
@actual = extract_html_content response.body
Expand Down
5 changes: 5 additions & 0 deletions spec/table_body_matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@
response.should have_table_body('my_id', [['c1', 'c2']])
end
end

it 'can be called without a table_id' do
response = mock_model(Object, :body => '<table id="my_id"><tr><td>c1</td><td>c2</td></tr></table>')
response.should have_table_body([['c1', 'c2']])
end
end
1 change: 0 additions & 1 deletion test/.gitignore

This file was deleted.

8 changes: 0 additions & 8 deletions test/html_matchers_test.rb

This file was deleted.

0 comments on commit be2bcfa

Please sign in to comment.