by whatsound



RSpec
LiveCoding#7
            ( )
      ...
(@Sixeight)
[       ]
    You.should join(:us)
Case -> Matchers
test-unit 2.0.5
Test::Unit + Shoulda
Test::Unit + Coulda
RSpec
CASE:
1.should == 1
1.should == 1
1.should == 1
1.should == 1
1.should == 1
Matchers
he.should play(:piano)
he.should play(:piano)
CASE:
[].empty? == true
[].empty?.should == true
×
[].empty?.should == true
Predicates
be_xxx
[].should be_empty
[].should be_empty

    [].empty?
be_true
 be_false
   be_nil
be_activate
be_a_xxx
be_an_xxx
be_a_kind_of(*args)
be_an_instance_of(*args)
CASE:
1.05   1.15
be_close(expected, delta)
value.should be_close(1.1, 0.5)
CASE:
change(receiver, message, &block)
#
lambda {
 Date(2009, 7, 6).next
}.should change(hitagi, :age).by(1)
#
lambda {
 Date(2009, 7, 6).next
}.should change(hitagi, :age).by(1)
#
lambda {
 Date(2009, 7, 6).next
}.should change(hitagi, :age).by(1)
CASE:
5 == 5
5.should eql(5)
obj == other
obj.should equal(other)
/hane/ =~ ‘hanekawa’
‘hanekawa’.should match(/hane/)
CASE:
exist
File.should exist(‘staple’)
CASE:
i.should respond_to(:say)
i.should respond_to(:say).
  with(‘love you’)
CASE:
have(n)
hitagi.should have(140).stationeries
hitagi.should have(140).stationeries
have == have_exactly
n
nadeko.should have_at_least(2).snakes
n
have_at_most
CASE:
[1, 2, 3].should include(2)
[1, 2, 3].should include(1, 3)
CASE:
lambda {
 danger_method
}.should raise_error
Throw
lambda {
 pitcher_method
}.should throw_symbol
CASE:
true
satisfy
oshino.satisfy do |o|
 o.battles_against(:me)
 o.battles_against(:you)
 o.alive?
end
RSpec
Matcher
RDoc
http://rspec.rubyforge.org/rspec/1.2.9/
you.should have_at_least(1).question

Introduce RSpec's Matchers