X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/ddd5b4cf19a92582fd114914be5bd5a04d3522a7..3f607d565bc0e2c7b1b738301c11c16d069913d5:/vendor/gems/rspec-1.1.2/lib/spec/expectations/extensions/object.rb diff --git a/vendor/gems/rspec-1.1.2/lib/spec/expectations/extensions/object.rb b/vendor/gems/rspec-1.1.2/lib/spec/expectations/extensions/object.rb new file mode 100644 index 000000000..a3925bbee --- /dev/null +++ b/vendor/gems/rspec-1.1.2/lib/spec/expectations/extensions/object.rb @@ -0,0 +1,71 @@ +module Spec + module Expectations + # rspec adds #should and #should_not to every Object (and, + # implicitly, every Class). + module ObjectExpectations + # :call-seq: + # should(matcher) + # should == expected + # should === expected + # should =~ expected + # + # receiver.should(matcher) + # => Passes if matcher.matches?(receiver) + # + # receiver.should == expected #any value + # => Passes if (receiver == expected) + # + # receiver.should === expected #any value + # => Passes if (receiver === expected) + # + # receiver.should =~ regexp + # => Passes if (receiver =~ regexp) + # + # See Spec::Matchers for more information about matchers + # + # == Warning + # + # NOTE that this does NOT support receiver.should != expected. + # Instead, use receiver.should_not == expected + def should(matcher = :default_parameter, &block) + if :default_parameter == matcher + Spec::Matchers::PositiveOperatorMatcher.new(self) + else + ExpectationMatcherHandler.handle_matcher(self, matcher, &block) + end + end + + # :call-seq: + # should_not(matcher) + # should_not == expected + # should_not === expected + # should_not =~ expected + # + # receiver.should_not(matcher) + # => Passes unless matcher.matches?(receiver) + # + # receiver.should_not == expected + # => Passes unless (receiver == expected) + # + # receiver.should_not === expected + # => Passes unless (receiver === expected) + # + # receiver.should_not =~ regexp + # => Passes unless (receiver =~ regexp) + # + # See Spec::Matchers for more information about matchers + def should_not(matcher = :default_parameter, &block) + if :default_parameter == matcher + Spec::Matchers::NegativeOperatorMatcher.new(self) + else + NegativeExpectationMatcherHandler.handle_matcher(self, matcher, &block) + end + end + + end + end +end + +class Object + include Spec::Expectations::ObjectExpectations +end