Testing Merb

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    2 Favorites

    Testing Merb - Presentation Transcript

    1. Testing Merb The Right Way
    2. Why Test?
    3. TDD
    4. TDD and Regressions
    5. TDD and Regressions I am not saying TDD is bad, but this talk doesn’t focus on mock- driven TDD.
    6. Resiliant Against Refactoring
    7. class Awesome def hello puts \"~ Hello ~\" end end describe Awesome do it \"prints hello\" do awesome = Awesome.new awesome.should_receive(:puts) awesome.hello end end
    8. class Awesome def hello awesome_print \"~ Hello ~\" end def awesome_print(str) print \"#{str}\\n\" end end describe Awesome do it \"prints hello\" do awesome = Awesome.new awesome.should_receive(:puts) awesome.hello end end
    9. class Awesome def hello awesome_print \"~ Hello ~\" end def awesome_print(str) print \"#{str}\\n\" end end describe Awesome do it \"prints hello\" do AIL awesome = Awesome.new F awesome.should_receive(:puts) awesome.hello end end
    10. class Awesome def hello awesome_print \"~ Hello ~\" end def awesome_print(str) print \"#{str}\\n\" end end describe Awesome do it \"prints hello\" do capture { Awesome.new.hello }. should =~ /Hello/ end end
    11. How to Test Three Rules
    12. Broken Interface means failing tests
    13. Working Interface means passing tests
    14. Write tests about what you care about
    15. http://example.com/foo Filters Controller Views Helpers What Happens in Your App
    16. http://example.com/foo Your App What You Care About
    17. http://example.com/foo 4 Filters Controller H Views Partials Helpers Refactoring
    18. Iteration 1
    19. class Foo < Application def awesome awesome_string end def awesome_string \"Awesome\" end end Merb::Router.prepare do match(\"/foo/awesome\"). to(:controller => Foo, :action => :awesome). name(:awesome) end
    20. dispatch_to(Foo, :awesome) do |cont| cont.should_receive(:awesome_string) end
    21. dispatch_to(Foo, :awesome) do |cont| cont.should_receive(:awesome_string) end
    22. Iteration 2
    23. class Bar < Application def coolness render end end Merb::Router.prepare do match(\"/foo/awesome\"). to(:controller => Bar, :action => :coolness). name(:awesome) end
    24. dispatch_to(Foo, :awesome) do |cont| cont.should_receive(:awesome_string) end
    25. dispatch_to(Foo, :awesome) do |cont| AIL cont.should_receive(:awesome_string) end F
    26. request(\"/foo/awesome\").body. should =~ /Awesome/
    27. request(url(:awesome)).body. should =~ /Awesome/
    28. Broken Interface means failing tests
    29. Working Interface means passing tests
    30. Write tests about what you care about
    31. “It’s Too Hard”
    32. Let’s Make it Easy
    33. request(url(:speakers)) request(resource(@speaker)) request(\"/foo/speakers\")
    34. request(url(:speakers)) one method request(resource(@speaker)) request(\"/foo/speakers\")
    35. Sessions are automatically sticky in a spec
    36. it \"should let you in\" do request(\"/login\", :method => :post, :params => {:username => \"user\", :password => \"pass\"}) request(\"/home\").should be_successful end
    37. it \"should let you in\" do request(\"/login\", :method => :post, :params => {:username => \"user\", :password => \"pass\"}) request(\"/home\").should be_successful login end
    38. it \"should let you in\" do request(\"/login\", :method => :post, :params => {:username => \"user\", :password => \"pass\"}) request(\"/home\").should be_successful end you’re logged in
    39. describe \"/login\", :given => \"successful login\" do it \"should let you in\" do request(\"/home\").should be_successful end end simpler
    40. describe \"/login\", :given => \"successful login\" do it \"should let you in\" do request(\"/home\").should be_successful end end simpler
    41. Request Rack status body headers
    42. request() helper Rack status body headers
    43. request(\"/foo\").body.should == \"hello\" request(\"/foo\").should have_xpath(\"//h1\") request(\"/foo\").should( have_selector(\"h1:contains(text)\"))
    44. request(\"/foo\").body.should == \"hello\" request(\"/foo\").should have_xpath(\"//h1\") request(\"/foo\").should( have_selector(\"h1:contains(text)\")) 1.0 final
    45. request(\"/foo\").should be_client_error request(\"/foo\").should( have_content_type(:json))
    46. Thank you.

    + Yehuda KatzYehuda Katz, 2 years ago

    custom

    2362 views, 2 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 2362
      • 2362 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 62
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories