module Turnip::ExtraSteps::Support::TableStepsHelper::ArrayMethods
Public Instance Methods
find_row(expected_row)
click to toggle source
# File lib/turnip/extra_steps/table_steps.rb, line 8 def find_row(expected_row) find_index do |row| expected_row.all? do |expected_column| first_column = row.find_index do |column| content = normalize_content(column.content) expected_content = normalize_content(expected_column) matching_parts = expected_content.split(/\s*\*\s*/, -1).collect { |part| Regexp.escape(part) } matching_expression = /\A#{matching_parts.join(".*")}\z/ content =~ matching_expression end if first_column.nil? false else row = row[(first_column + 1)..-1] true end end end end
normalize_content(content)
click to toggle source
# File lib/turnip/extra_steps/table_steps.rb, line 28 def normalize_content(content) nbsp = " " content.gsub(/[\r\n\t]+/, ' ').gsub(nbsp, ' ').gsub(/ {2,}/, ' ').strip end