Module: Spec::Expectations::ProcExpectations
- Included in:
- Proc
- Defined in:
- lib/spec/expectations/extensions/proc.rb
Instance Method Summary collapse
-
#should_change(receiver = nil, message = nil, &block) ⇒ Object
Given a receiver and a message (Symbol), specifies that the result of sending that message that receiver should change after executing the proc.
-
#should_not_change(receiver, message) ⇒ Object
Given a receiver and a message (Symbol), specifies that the result of sending that message that receiver should NOT change after executing the proc.
- #should_not_raise(exception = Exception, message = nil) ⇒ Object
- #should_not_throw(symbol = :___this_is_a_symbol_that_will_likely_never_occur___) ⇒ Object
- #should_raise(exception = Exception, message = nil) ⇒ Object
- #should_throw(symbol) ⇒ Object
Instance Method Details
#should_change(receiver = nil, message = nil, &block) ⇒ Object
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)
19 20 21 |
# File 'lib/spec/expectations/extensions/proc.rb', line 19 def should_change(receiver=nil, =nil, &block) should.change(receiver, , &block) end |
#should_not_change(receiver, message) ⇒ Object
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}
32 33 34 |
# File 'lib/spec/expectations/extensions/proc.rb', line 32 def should_not_change(receiver, ) should.not.change(receiver, ) end |
#should_not_raise(exception = Exception, message = nil) ⇒ Object
40 41 42 |
# File 'lib/spec/expectations/extensions/proc.rb', line 40 def should_not_raise(exception=Exception, =nil) should.not.raise(exception, ) end |
#should_not_throw(symbol = :___this_is_a_symbol_that_will_likely_never_occur___) ⇒ Object
48 49 50 |
# File 'lib/spec/expectations/extensions/proc.rb', line 48 def should_not_throw(symbol=:___this_is_a_symbol_that_will_likely_never_occur___) should.not.throw(symbol) end |
#should_raise(exception = Exception, message = nil) ⇒ Object
36 37 38 |
# File 'lib/spec/expectations/extensions/proc.rb', line 36 def should_raise(exception=Exception, =nil) should.raise(exception, ) end |
#should_throw(symbol) ⇒ Object
44 45 46 |
# File 'lib/spec/expectations/extensions/proc.rb', line 44 def should_throw(symbol) should.throw(symbol) end |