Module Spec::Expectations::ProcExpectations
In: lib/spec/expectations/extensions/proc.rb

Methods

Public Instance methods

Given a receiver and a message (Symbol), specifies that the result of sending that message that receiver should change after executing the proc.

  lambda { @team.add player }.should_change(@team.players, :size)
  lambda { @team.add player }.should_change(@team.players, :size).by(1)
  lambda { @team.add player }.should_change(@team.players, :size).to(23)
  lambda { @team.add player }.should_change(@team.players, :size).from(22).to(23)

You can use a block instead of a message and receiver.

  lambda { @team.add player }.should_change{@team.players.size}
  lambda { @team.add player }.should_change{@team.players.size}.by(1)
  lambda { @team.add player }.should_change{@team.players.size}.to(23)
  lambda { @team.add player }.should_change{@team.players.size}.from(22).to(23)

[Source]

    # File lib/spec/expectations/extensions/proc.rb, line 19
19:       def should_change(receiver=nil, message=nil, &block)
20:         should.change(receiver, message, &block)
21:       end

Given a receiver and a message (Symbol), specifies that the result of sending that message that receiver should NOT change after executing the proc.

  lambda { @team.add player }.should_not_change(@team.players, :size)

You can use a block instead of a message and receiver.

  lambda { @team.add player }.should_not_change{@team.players.size}

[Source]

    # File lib/spec/expectations/extensions/proc.rb, line 32
32:       def should_not_change(receiver, message)
33:         should.not.change(receiver, message)
34:       end

[Source]

    # File lib/spec/expectations/extensions/proc.rb, line 40
40:       def should_not_raise(exception=Exception, message=nil)
41:         should.not.raise(exception, message)
42:       end

[Source]

    # File lib/spec/expectations/extensions/proc.rb, line 48
48:       def should_not_throw(symbol=:___this_is_a_symbol_that_will_likely_never_occur___)
49:         should.not.throw(symbol)
50:       end

[Source]

    # File lib/spec/expectations/extensions/proc.rb, line 36
36:       def should_raise(exception=Exception, message=nil)
37:         should.raise(exception, message)
38:       end

[Source]

    # File lib/spec/expectations/extensions/proc.rb, line 44
44:       def should_throw(symbol)
45:         should.throw(symbol)
46:       end

[Validate]