Introduce RSpec's Matchers

  • 2,840 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,840
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
23
Comments
0
Likes
5

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. by whatsound RSpec
  • 2. LiveCoding#7 ( ) ...
  • 3. (@Sixeight)
  • 4. [ ] You.should join(:us)
  • 5. Case -> Matchers
  • 6. test-unit 2.0.5
  • 7. Test::Unit + Shoulda Test::Unit + Coulda
  • 8. RSpec
  • 9. CASE:
  • 10. 1.should == 1
  • 11. 1.should == 1
  • 12. 1.should == 1
  • 13. 1.should == 1
  • 14. 1.should == 1
  • 15. Matchers
  • 16. he.should play(:piano)
  • 17. he.should play(:piano)
  • 18. CASE:
  • 19. [].empty? == true
  • 20. [].empty?.should == true
  • 21. × [].empty?.should == true
  • 22. Predicates
  • 23. be_xxx
  • 24. [].should be_empty
  • 25. [].should be_empty [].empty?
  • 26. be_true be_false be_nil be_activate
  • 27. be_a_xxx be_an_xxx
  • 28. be_a_kind_of(*args) be_an_instance_of(*args)
  • 29. CASE:
  • 30. 1.05 1.15
  • 31. be_close(expected, delta)
  • 32. value.should be_close(1.1, 0.5)
  • 33. CASE:
  • 34. change(receiver, message, &block)
  • 35. # lambda { Date(2009, 7, 6).next }.should change(hitagi, :age).by(1)
  • 36. # lambda { Date(2009, 7, 6).next }.should change(hitagi, :age).by(1)
  • 37. # lambda { Date(2009, 7, 6).next }.should change(hitagi, :age).by(1)
  • 38. CASE:
  • 39. 5 == 5
  • 40. 5.should eql(5)
  • 41. obj == other
  • 42. obj.should equal(other)
  • 43. /hane/ =~ ‘hanekawa’
  • 44. ‘hanekawa’.should match(/hane/)
  • 45. CASE:
  • 46. exist
  • 47. File.should exist(‘staple’)
  • 48. CASE:
  • 49. i.should respond_to(:say)
  • 50. i.should respond_to(:say). with(‘love you’)
  • 51. CASE:
  • 52. have(n)
  • 53. hitagi.should have(140).stationeries
  • 54. hitagi.should have(140).stationeries
  • 55. have == have_exactly
  • 56. n
  • 57. nadeko.should have_at_least(2).snakes
  • 58. n
  • 59. have_at_most
  • 60. CASE:
  • 61. [1, 2, 3].should include(2)
  • 62. [1, 2, 3].should include(1, 3)
  • 63. CASE:
  • 64. lambda { danger_method }.should raise_error
  • 65. Throw
  • 66. lambda { pitcher_method }.should throw_symbol
  • 67. CASE:
  • 68. true
  • 69. satisfy
  • 70. oshino.satisfy do |o| o.battles_against(:me) o.battles_against(:you) o.alive? end
  • 71. RSpec Matcher
  • 72. RDoc http://rspec.rubyforge.org/rspec/1.2.9/
  • 73. you.should have_at_least(1).question