Telling Stories With RSpec
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Telling Stories With RSpec

on

  • 3,998 views

An introduction to Behaviour Driven Development and User Stories using RSpec and Ruby

An introduction to Behaviour Driven Development and User Stories using RSpec and Ruby

Statistics

Views

Total Views
3,998
Views on SlideShare
3,959
Embed Views
39

Actions

Likes
4
Downloads
83
Comments
0

2 Embeds 39

http://www.3hv.co.uk 36
http://www.slideshare.net 3

Accessibility

Upload Details

Uploaded via as Adobe PDF

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

Telling Stories With RSpec Presentation Transcript

  • 1. Telling Stories with RSpec Rahoul Baruah
  • 2. Functional Specifications • Functionality and Features • Sketches • Pages and pages of text
  • 3. Big Design Up Front • Estimates for cost and delivery dates • Agreement and sign-off • Misunderstandings • Software is Intangible • Change is inevitable
  • 4. “Agile” Development • Short descriptions of each feature • Testable and Verifiable • Easy to understand • Easy to manage • Easy to prioritise • Easy to change
  • 5. RSpec and Behaviour Driven Development • Getting the words right • It should do this • blue.should be_darker_than(turquoise) • Code as Specification
  • 6. Mock Objects • vat_calculator = mock ‘VAT Calculator’ • invoice.vat_calculator = vat_calculator • invoice.sub_total = 100 • vat_calculator.should_receive(:calculate).with(100).and_re turn(17.5) • invoice.total.should == 117.5
  • 7. Integration Tests • Test the full stack • Interactions between objects • Written as code
  • 8. RSpec User Stories • User Stories • Full Stack Testing • Plain Text plus Executables
  • 9. Story Structure • As a ... • I want ... • So that ...
  • 10. Scenarios • Different paths • Success and Errors • “Blank Slate”
  • 11. Given • Set up pre-requisites • Set up state • Given a user called Dave • And Dave is logged in
  • 12. When • Actions performed by the actor • When I click the ‘profile’ link • When I enter my new password and confirmation • And click the ‘Change my password’ button • Defined in terms of the user interface
  • 13. Then • Defines the results of your actions • Then I should see my profile page • And it should list how many items I have bought • Defined in terms of the user interface
  • 14. Steps • Given, When and Then • Text matchers, with parameters • Executable
  • 15. Test the Full-Stack • Specify in terms of User-Interface elements • Parse the DOM to check for results • Defines the user interface for the customer
  • 16. Webrat When “Dave logs in” do visit login_path fill_in ‘User Name’, :with => ‘Dave’ fill_in ‘Password’, :with => ‘secret’ click_button ‘Log In’ end
  • 17. RSpec Matchers Then “Dave’s profile page is shown” do response.should be_success response.should render_template(‘profiles/show’) response.should include_text(“Dave’s profile page”) end
  • 18. Cucumber • Structure for organising stories and steps • rake features • Is now part of RSpec
  • 19. Process • Write a Story • Write the first step • Write the specifications for the controllers • Write the controllers • Write the specifications for the models • Write the models • Run the Story • Write the next step
  • 20. References • RSpec • Cucumber • Webrat • JBehave • Celerity • HTMLUnit