Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def initialize(values, previous_selection = nil, &root_fallback)
@tests = extract_equality_tests
@message = @values.shift

if @message.is_a?(Hash)
raise ArgumentError, "Last argument was a Hash, which would be used for the assertion message. You probably want this to be a String, or you have the wrong type of arguments."
end

if @values.shift
raise ArgumentError, "Not expecting that last argument, you either have too many arguments, or they're the wrong type"
end
Expand Down
10 changes: 10 additions & 0 deletions test/selector_assertions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,16 @@ def test_body_class_can_be_tested_with_html
assert_select '.foo'
end

def test_assert_select_with_extra_argument
render_html '<html><head><title>Welcome</title></head><body><div></div></body></html>'

assert_raises ArgumentError do
assert_select "title", "Welcome", count: 1
end

assert_select "title", text: "Welcome", count: 1
end

protected
def render_html(html)
fake_render(:html, html)
Expand Down