2011-12-13 03:38:47 +00:00
|
|
|
require 'rubygems' if RUBY_VERSION =~ /^1.8/
|
2011-12-12 03:39:55 +00:00
|
|
|
gem 'minitest'
|
|
|
|
require 'minitest/spec'
|
|
|
|
require 'minitest/autorun'
|
|
|
|
require 'minitest/matchers'
|
|
|
|
|
2011-12-13 02:51:06 +00:00
|
|
|
require 'process_shared'
|
|
|
|
|
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)
|
|
|
|
subject.send(@operator, @limit)
|
|
|
|
end
|
|
|
|
|
|
|
|
def failure_message_for_should
|
|
|
|
"expected #{operator} #{@limit}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def failure_message_for_should_not
|
|
|
|
"expected not #{operator} #{@limit}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def be_lt(value)
|
|
|
|
RangeMatcher.new('<', value)
|
|
|
|
end
|
|
|
|
|
|
|
|
def be_lte(value)
|
|
|
|
RangeMatcher.new('<=', value)
|
|
|
|
end
|