rename :collapse_ws to :normalize_ws
This commit is contained in:
parent
a55bef1546
commit
8f07330783
|
@ -3,7 +3,7 @@ Release date: unreleased
|
|||
|
||||
### Added
|
||||
|
||||
* text predicates and matchers (`has_text?`, `has_content?`, `assert_text`, etc) now support a `collapse_ws` option
|
||||
* text predicates and matchers (`has_text?`, `has_content?`, `assert_text`, etc) now support a `normalize_ws` option
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
@ -632,7 +632,7 @@ module Capybara
|
|||
# @option options [Range] :between (nil) Range of times that is expected to contain number of times text occurs
|
||||
# @option options [Numeric] :wait (Capybara.default_max_wait_time) Maximum time that Capybara will wait for text to eq/match given string/regexp argument
|
||||
# @option options [Boolean] :exact (Capybara.exact_text) Whether text must be an exact match or just substring
|
||||
# @option options [Boolean] :collapse_ws (false) When true replace all whitespace with standard spaces and collapse consecutive whitespace to a single space
|
||||
# @option options [Boolean] :nomalize_ws (false) When true replace all whitespace with standard spaces and collapse consecutive whitespace to a single space
|
||||
# @overload $0(text, **options)
|
||||
# @param [String, Regexp] text The string/regexp to check for. If it's a string, text is expected to include it. If it's a regexp, text is expected to match it.
|
||||
# @option options [Integer] :count (nil) Number of times the text is expected to occur
|
||||
|
@ -641,7 +641,7 @@ module Capybara
|
|||
# @option options [Range] :between (nil) Range of times that is expected to contain number of times text occurs
|
||||
# @option options [Numeric] :wait (Capybara.default_max_wait_time) Maximum time that Capybara will wait for text to eq/match given string/regexp argument
|
||||
# @option options [Boolean] :exact (Capybara.exact_text) Whether text must be an exact match or just substring
|
||||
# @option options [Boolean] :collapse_ws (false) When true replace all whitespace with standard spaces and collapse consecutive whitespace to a single space
|
||||
# @option options [Boolean] :normalize_ws (false) When true replace all whitespace with standard spaces and collapse consecutive whitespace to a single space
|
||||
# @raise [Capybara::ExpectationNotMet] if the assertion hasn't succeeded during wait time
|
||||
# @return [true]
|
||||
#
|
||||
|
|
|
@ -24,7 +24,7 @@ module Capybara
|
|||
def resolve_for(node)
|
||||
@node = node
|
||||
@actual_text = text(node, @type)
|
||||
@actual_text.gsub!(/[[:space:]]+/, ' ').strip! if options[:collapse_ws]
|
||||
@actual_text.gsub!(/[[:space:]]+/, ' ').strip! if options[:normalize_ws]
|
||||
@count = @actual_text.scan(@search_regexp).size
|
||||
end
|
||||
|
||||
|
@ -84,7 +84,7 @@ module Capybara
|
|||
end
|
||||
|
||||
def valid_keys
|
||||
COUNT_KEYS + %i[wait exact collapse_ws]
|
||||
COUNT_KEYS + %i[wait exact normalize_ws]
|
||||
end
|
||||
|
||||
def check_visible_text?
|
||||
|
|
|
@ -12,7 +12,7 @@ Capybara::SpecHelper.spec '#assert_text' do
|
|||
|
||||
it 'should support collapsing whitespace' do
|
||||
@session.visit('/with_html')
|
||||
expect(@session.assert_text('text with whitespace', collapse_ws: true)).to eq(true)
|
||||
expect(@session.assert_text('text with whitespace', normalize_ws: true)).to eq(true)
|
||||
end
|
||||
|
||||
it 'should take scopes into account' do
|
||||
|
|
|
@ -36,7 +36,7 @@ Capybara::SpecHelper.spec '#has_text?' do
|
|||
|
||||
it 'should search whitespace collapsed text' do
|
||||
@session.visit('/with_html')
|
||||
expect(@session).to have_text('text with whitespace', collapse_ws: true)
|
||||
expect(@session).to have_text('text with whitespace', normalize_ws: true)
|
||||
end
|
||||
|
||||
it 'should be false if the given text is not on the page' do
|
||||
|
|
Loading…
Reference in New Issue