Module Spec::Mocks::ArgumentConstraints
In: lib/spec/mocks/argument_constraints.rb

ArgumentConstraints are messages that you can include in message expectations to match arguments against a broader check than simple equality.

With the exception of any_args() and no_args(), the constraints are all positional - they match against the arg in the given position.


Classes and Modules

Class Spec::Mocks::ArgumentConstraints::AnyArgConstraint
Class Spec::Mocks::ArgumentConstraints::AnyArgsConstraint
Class Spec::Mocks::ArgumentConstraints::BooleanConstraint
Class Spec::Mocks::ArgumentConstraints::DuckTypeConstraint
Class Spec::Mocks::ArgumentConstraints::EqualityProxy
Class Spec::Mocks::ArgumentConstraints::HashIncludingConstraint
Class Spec::Mocks::ArgumentConstraints::HashNotIncludingConstraint
Class Spec::Mocks::ArgumentConstraints::InstanceOf
Class Spec::Mocks::ArgumentConstraints::KindOf
Class Spec::Mocks::ArgumentConstraints::MatcherConstraint
Class Spec::Mocks::ArgumentConstraints::NoArgsConstraint
Class Spec::Mocks::ArgumentConstraints::RegexpConstraint

Public Instance methods


Alias for kind_of


Alias for instance_of

Passes if object receives :message with any args at all. This is really a more explicit variation of object.should_receive(:message)

Passes as long as there is an argument.

Passes if the argument is boolean.

Passes if the argument responds to the specified messages.


  array = []
  display = mock('display')
  display.should_receive(:present_names).with(duck_type(:length, :each))
  => passes


  object.should_receive(:message).with(hash_including(:key => val))
  object.should_receive(:message).with(hash_including(:key, :key2 => val2))

Passes if the argument is a hash that includes the specified key(s) or key/value pairs. If the hash includes other keys, it will still pass.

Passes if arg.instance_of?(klass)

Passes if arg.kind_of?(klass)

Passes if no arguments are passed along with the message