class ListCountComparison
Store a value and a comparison operator to determine if a provided number validates against it
Attributes
type[R]
Public Class Methods
new(type, amount)
click to toggle source
# File lib/cucumber-rest-bdd/list.rb, line 93 def initialize(type, amount) @type = type.nil? ? CMP_EQUALS : to_compare(type) @amount = amount.nil? ? 1 : to_num(amount) end
Public Instance Methods
amount()
click to toggle source
# File lib/cucumber-rest-bdd/list.rb, line 111 def amount amount end
compare(actual)
click to toggle source
# File lib/cucumber-rest-bdd/list.rb, line 98 def compare(actual) case @type when CMP_LESS_THAN then actual < @amount when CMP_MORE_THAN then actual > @amount when CMP_AT_MOST then actual <= @amount when CMP_AT_LEAST then actual >= @amount when CMP_EQUALS then actual == @amount else actual == @amount end end
compare_to_string()
click to toggle source
turn a comparison into a string
# File lib/cucumber-rest-bdd/list.rb, line 116 def compare_to_string case @type when CMP_LESS_THAN then 'fewer than ' when CMP_MORE_THAN then 'more than ' when CMP_AT_LEAST then 'at least ' when CMP_AT_MOST then 'at most ' when CMP_EQUALS then 'exactly ' else '' end end
to_string()
click to toggle source
# File lib/cucumber-rest-bdd/list.rb, line 127 def to_string compare_to_string + ' ' + @amount.to_s end