Flowdock
method

predicate_matchers

Importance_1
RSpec latest stable (1.3.1) - 0 notes - Class: Spec::Example::ExampleGroupMethods

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (1.1.12) is shown here.

These similar methods exist in 1.3.1:

predicate_matchers() public

Dynamically generates a custom matcher that will match a predicate on your class. RSpec provides a couple of these out of the box:

  exist (for state expectations)
    File.should exist("path/to/file")

  an_instance_of (for mock argument constraints)
    mock.should_receive(:message).with(an_instance_of(String))

Examples

  class Fish
    def can_swim?
      true
    end
  end

  describe Fish do
    predicate_matchers[:swim] = :can_swim?
    it "should swim" do
      Fish.new.should swim
    end
  end
Show source
Register or log in to add new notes.