Sha256: 4e8735cc330a1b8acd6c845cf740dc68bdef9c975953c08cbd566954ebfd80a7

Contents?: true

Size: 1.84 KB

Versions: 54

Compression:

Stored size: 1.84 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)
        ExpectationMatcherHandler.handle_matcher(self, matcher, &block)
      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)
        NegativeExpectationMatcherHandler.handle_matcher(self, matcher, &block)
      end

    end
  end
end

class Object
  include Spec::Expectations::ObjectExpectations
end

Version data entries

54 entries across 54 versions & 10 rubygems

Version Path
dchelimsky-rspec-1.1.10 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.11.1 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.11.2 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.11.3 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.11.4 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.11.5 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.11.6 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.11.7 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.11 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.12 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.99.1 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.99.13 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.99.2 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.99.3 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.99.4 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.99.5 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.99.6 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.99.7 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.99.8 lib/spec/expectations/extensions/object.rb
dchelimsky-rspec-1.1.99.9 lib/spec/expectations/extensions/object.rb