lib/spec/expectations/should/base.rb in rspec-0.7.3 vs lib/spec/expectations/should/base.rb in rspec-0.7.4
- old
+ new
@@ -1,16 +1,38 @@
module Spec
module Expectations
module Should
class Base
+
+ def <(expected)
+ __delegate_method_missing_to_target "<", "<", expected
+ end
+
+ def <=(expected)
+ __delegate_method_missing_to_target "<=", "<=", expected
+ end
+
+ def ==(expected)
+ __delegate_method_missing_to_target "==", "==", expected
+ end
+
+ def =~(expected)
+ __delegate_method_missing_to_target "=~", "=~", expected
+ end
+
+ def >=(expected)
+ __delegate_method_missing_to_target ">=", ">=", expected
+ end
+
+ def >(expected)
+ __delegate_method_missing_to_target ">", ">", expected
+ end
- instance_methods.each { |m| undef_method m unless m =~ /^(__|\w)/ }
-
def default_message(expectation, expected=:no_expectation_specified)
- message = "#{@target.inspect_for_expectation_not_met_error} #{expectation}"
+ message = "#{@target.inspect} #{expectation}"
if (expected != :no_expectation_specified)
- message << " " << expected.inspect_for_expectation_not_met_error
+ message << " " << expected.inspect
end
message
end
def fail_with_message(message)
@@ -19,10 +41,10 @@
def find_supported_sym(original_sym)
["#{original_sym}?", "#{original_sym}s?"].each do |alternate_sym|
return alternate_sym.to_s if @target.respond_to?(alternate_sym.to_s)
end
- return original_sym.supported_by_rspec? ? original_sym : "#{original_sym}?"
+ return ["<","<=",">=",">","==","=~"].include?(original_sym) ? original_sym : "#{original_sym}?"
end
def method_missing(original_sym, *args, &block)
if original_sym.to_s =~ /^not_/
return Not.new(@target).__send__(original_sym.to_s[4..-1].to_sym, *args, &block)