class DataValidation::Comparison::RankingTableMwPollComparison
Public Instance Methods
api_path()
click to toggle source
# File lib/data_validation/comparison/ranking_table_mw_poll_comparison.rb, line 7 def api_path '/rest/LaxPower/rankingTableMWpoll' end
compare()
click to toggle source
# File lib/data_validation/comparison/conference_ranking_table_comparison.rb, line 7 def compare if api_path.nil? raise 'Please define api_path' end data_access = DataValidation::DataAccess.new(web_url, DataValidation.api_request_host + api_path, determine_request_body_and_logger_name) puts 'requesting web page...' web_data = data_access.get_main_table_data puts 'requesting mobile api data: ' + DataValidation.api_request_host + api_path api_data = data_access.get_response_from_mobile_api if web_data.length != api_data['results']['results']['total'] logger.error "The record size between web page and api data is not the same: #{web_data.length} -- #{api_data['results']['results']['total']}" return end web_data.each_with_index do |item, index| team = api_data['results']['results']['teams'][index] field_array.each_with_index do |filed_name, index| if filed_name.is_a? String team_value = team[filed_name] elsif filed_name.is_a? Array team_value = team[filed_name[0]][filed_name[1]] else next end unless (team_value.is_a?(String) && team_value.include?(item[index])) || (team_value.is_a?(Float) && team_value == item[index].to_f) || (team_value.is_a?(Integer) && team_value == item[index].to_i) logger.error "team #{item[0]}'s #{filed_name} is not correct: #{item[index]} -- #{team_value}" end end end end
empty_field()
click to toggle source
# File lib/data_validation/comparison/ranking_table_mw_poll_comparison.rb, line 15 def empty_field 'pollFirst' end
field_array()
click to toggle source
# File lib/data_validation/comparison/ranking_table_mw_poll_comparison.rb, line 11 def field_array ['rank', 'teamName', %w|record wins|, %w|record losses|, %w|record ties|, 'pollPoint', 'pollFirst'] end
rank_field()
click to toggle source
# File lib/data_validation/comparison/ranking_table_mw_poll_comparison.rb, line 19 def rank_field 'pollPoint' end