2011-12-12 03:39:55 +00:00
|
|
|
require 'minitest/autorun'
|
2014-01-01 02:17:15 +00:00
|
|
|
require 'minitest/spec'
|
2011-12-12 03:39:55 +00:00
|
|
|
require 'minitest/matchers'
|
2011-12-13 02:51:06 +00:00
|
|
|
|
2011-12-21 04:20:30 +00:00
|
|
|
require 'process_shared'
|
2012-02-24 03:37:19 +00:00
|
|
|
require 'process_shared/lock_behavior'
|
2011-12-21 04:20:30 +00:00
|
|
|
|
2011-12-12 03:39:55 +00:00
|
|
|
class RangeMatcher
|
|
|
|
def initialize(operator, limit)
|
|
|
|
@operator = operator.to_sym
|
|
|
|
@limit = limit
|
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
|
|
|
"be #{operator} #{@limit}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def matches?(subject)
|
2011-12-17 15:58:10 +00:00
|
|
|
@subject = subject
|
2011-12-12 03:39:55 +00:00
|
|
|
subject.send(@operator, @limit)
|
|
|
|
end
|
|
|
|
|
|
|
|
def failure_message_for_should
|
2011-12-17 15:58:10 +00:00
|
|
|
"expected #{@operator} #{@limit}, not #{@subject}"
|
2011-12-12 03:39:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def failure_message_for_should_not
|
2011-12-17 15:58:10 +00:00
|
|
|
"expected not #{@operator} #{@limit}, not #{@subject}"
|
2011-12-12 03:39:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def be_lt(value)
|
|
|
|
RangeMatcher.new('<', value)
|
|
|
|
end
|
|
|
|
|
2011-12-17 15:58:10 +00:00
|
|
|
def be_gt(value)
|
|
|
|
RangeMatcher.new('>', value)
|
|
|
|
end
|
|
|
|
|
2011-12-12 03:39:55 +00:00
|
|
|
def be_lte(value)
|
|
|
|
RangeMatcher.new('<=', value)
|
|
|
|
end
|
2011-12-17 15:58:10 +00:00
|
|
|
|
|
|
|
def be_gte(value)
|
|
|
|
RangeMatcher.new('>=', value)
|
|
|
|
end
|