• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Introduce RSpec's Matchers
 

Introduce RSpec's Matchers

on

  • 4,096 views

 

Statistics

Views

Total Views
4,096
Views on SlideShare
3,897
Embed Views
199

Actions

Likes
5
Downloads
23
Comments
0

5 Embeds 199

http://d.hatena.ne.jp 169
http://sixeight.hatenablog.com 18
http://www.slideshare.net 10
http://s.deeeki.com 1
https://twitter.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Introduce RSpec's Matchers Introduce RSpec's Matchers Presentation Transcript

  • 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