Sha256: 34b50bde8535c0eec5c586418846541f9c392ba962e341deadd7c2ae2536f1da

Contents?: true

Size: 1.99 KB

Versions: 17

Compression:

Stored size: 1.99 KB

Contents

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=nil, &block)
        return ExpectationMatcherHandler.handle_matcher(self, matcher, &block) if matcher
        Spec::Matchers::PositiveOperatorMatcher.new(self)
      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=nil, &block)
        return NegativeExpectationMatcherHandler.handle_matcher(self, matcher, &block) if matcher
        Spec::Matchers::NegativeOperatorMatcher.new(self)
      end

    end
  end
end

class Object
  include Spec::Expectations::ObjectExpectations
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
has_finder-0.1.1 spec/rails/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb
has_finder-0.1.2 spec/rails/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb
has_finder-0.1.3 spec/rails/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb
rspec-0.9.0 lib/spec/expectations/extensions/object.rb
rspec-1.0.5 lib/spec/expectations/extensions/object.rb
rspec-1.0.2 lib/spec/expectations/extensions/object.rb
rspec-1.0.3 lib/spec/expectations/extensions/object.rb
rspec-1.0.4 lib/spec/expectations/extensions/object.rb
rspec-0.9.1 lib/spec/expectations/extensions/object.rb
rspec-0.9.2 lib/spec/expectations/extensions/object.rb
rspec-0.9.3 lib/spec/expectations/extensions/object.rb
rspec-0.9.4 lib/spec/expectations/extensions/object.rb
rspec-1.0.0 lib/spec/expectations/extensions/object.rb
rspec-1.0.1 lib/spec/expectations/extensions/object.rb
rspec-1.0.8 lib/spec/expectations/extensions/object.rb
rspec-1.0.7 lib/spec/expectations/extensions/object.rb
rspec-1.0.6 lib/spec/expectations/extensions/object.rb