BDD for Rails Legacy
      Code
About Me

   Lu Wei Jen
       Rails Developer
   http://blog.weijen.net
   http://www.facebook.com/
    weijenlu
   ...
10
10
Legacy Code
Agenda
•
•      BDD

• BDD
• Legacy Code
• Legacy Code
•
•
•
•
Changes Changes Changes

Changes

          Changes

                          Changes
BDD

• Behavior Driven Development
•
•
BDD Tools for Rails

• Cucumber
• Webrat
• RSpec
Cucumber

•
•
•
Cucumber
Cucumber
Cucumber

    Mock Object
Webrat
•
•
    •
    •   form

    •
Webrat:


• visit "http://rubyconf.tw"
• click_link "        "
Webrat:                Form

• file_in " ", :with => "weijen"
• check "      "

• select "     ", :from => "   "

• click_...
Webrat:

•   response.should contain("            ")



•   response.should have_selector("img.photo")
RSpec
•
•
•
•
•
•
    •


•
• Waybill model         #set_customer

• Waybills_controller     #create
Model
Model
Mock Object

•
•
•
•
Mock Object

• my_mock = mock(name)
• my_mock = mock(name, stubs)
• my_mock = mock_model(name, stubs)
•   my_mock.stub!(:msg).with(args).and_return(value)
Message Expectation


•   my_mock.should_receive(:msg).with(args).and_r
    eturn(value)
Mock
Controller
Controller
Cucumber
•
•   +
• No Silver Bullet
•
•
Q &A
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
BDD for Rails Legacy Code
Upcoming SlideShare
Loading in...5
×

BDD for Rails Legacy Code

1,589

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,589
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
73
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide























































  • BDD for Rails Legacy Code

    1. 1. BDD for Rails Legacy Code
    2. 2. About Me  Lu Wei Jen  Rails Developer  http://blog.weijen.net  http://www.facebook.com/ weijenlu  Twitter: weijenlu 
    3. 3. 10
    4. 4. 10
    5. 5. Legacy Code
    6. 6. Agenda • • BDD • BDD • Legacy Code • Legacy Code
    7. 7. • • • •
    8. 8. Changes Changes Changes Changes Changes Changes
    9. 9. BDD • Behavior Driven Development • •
    10. 10. BDD Tools for Rails • Cucumber • Webrat • RSpec
    11. 11. Cucumber • • •
    12. 12. Cucumber
    13. 13. Cucumber
    14. 14. Cucumber Mock Object
    15. 15. Webrat • • • • form •
    16. 16. Webrat: • visit "http://rubyconf.tw" • click_link " "
    17. 17. Webrat: Form • file_in " ", :with => "weijen" • check " " • select " ", :from => " " • click_button
    18. 18. Webrat: • response.should contain(" ") • response.should have_selector("img.photo")
    19. 19. RSpec
    20. 20. • • • • •
    21. 21. • • •
    22. 22. • Waybill model #set_customer • Waybills_controller #create
    23. 23. Model
    24. 24. Model
    25. 25. Mock Object • • • •
    26. 26. Mock Object • my_mock = mock(name) • my_mock = mock(name, stubs) • my_mock = mock_model(name, stubs)
    27. 27. • my_mock.stub!(:msg).with(args).and_return(value)
    28. 28. Message Expectation • my_mock.should_receive(:msg).with(args).and_r eturn(value)
    29. 29. Mock
    30. 30. Controller
    31. 31. Controller
    32. 32. Cucumber
    33. 33.
    34. 34. • +
    35. 35. • No Silver Bullet • •
    36. 36. Q &A
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×