Sha256: fd61d747700f2169a383a5452e75739d241dcc5b1eef8410ca750ad473de915f
Contents?: true
Size: 1.71 KB
Versions: 6
Compression:
Stored size: 1.71 KB
Contents
require 'rubygems' require 'spec' require File.dirname(__FILE__) + '/../lib/gecoder' module CustomVarMatchers class HaveDomain def initialize(expected) @expected = expected.to_a end def matches?(target) @target = target return false unless @target.size == @expected.size @expected.each do |element| return false unless @target.include? element end return true end def failure_message "expected #{@target.inspect} to have domain #{@expected.inspect}" end def negative_failure_message "expected #{@target.inspect} not to have domain #{@expected.inspect}" end end # Tests whether a variable has the expected domain. def have_domain(expected) HaveDomain.new(expected) end class HaveBounds def initialize(expected_glb, expected_lub) @expected_glb = expected_glb.to_a @expected_lub = expected_lub.to_a end def matches?(target) @target = target return @target.lower_bound.to_a == @expected_glb && @target.upper_bound.to_a == @expected_lub end def failure_message "expected #{@target.inspect} to have greatest lower bound " + "#{@expected_glb.inspect} and least upper bound #{@expected_lub.inspect}" end def negative_failure_message "expected #{@target.inspect} to not have greatest lower bound " + "#{@expected_glb.inspect} and least upper bound #{@expected_lub.inspect}" end end # Tests whether a set variable has the expected bounds. def have_bounds(expected_glb, expected_lub) HaveBounds.new(expected_glb, expected_lub) end end Spec::Runner.configure do |config| config.include(CustomVarMatchers) end
Version data entries
6 entries across 6 versions & 2 rubygems