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 @@ -131,6 +131,11 @@ def extract_equality_tests(refute)
else
comparisons[:minimum] ||= 1
end

if comparisons[:minimum] && comparisons[:maximum] && comparisons[:minimum] > comparisons[:maximum]
raise ArgumentError, "Range begin or :minimum cannot be greater than Range end or :maximum"
end

comparisons
end
end
Expand Down
14 changes: 14 additions & 0 deletions test/selector_assertions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,20 @@ def test_assert_select_text_match
end
end

def test_assert_select_with_invalid_range
render_html "<div>foo</div>"
error = assert_raises(ArgumentError) { assert_select("div", 2..1) { nil } }
assert_equal "Range begin or :minimum cannot be greater than Range end or :maximum", error.message
end

def test_assert_select_with_invalid_minimum_and_maximum
render_html "<div>foo</div>"
error = assert_raises(ArgumentError) { assert_select("div", maximum: 0) { nil } }
assert_equal "Range begin or :minimum cannot be greater than Range end or :maximum", error.message
error = assert_raises(ArgumentError) { assert_select("div", minimum: 2, maximum: 1) { nil } }
assert_equal "Range begin or :minimum cannot be greater than Range end or :maximum", error.message
end

#
# Test assert_not_select.
#
Expand Down