Your SlideShare is downloading. ×
Telling Stories With RSpec
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Telling Stories With RSpec

2,323
views

Published on

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

Published in: Technology, Economy & Finance

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,323
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
83
Comments
0
Likes
4
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. 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