SlideShare a Scribd company logo
1 of 20
Download to read offline
Telling Stories with
       RSpec
        Rahoul Baruah
Functional Specifications
• Functionality and Features
• Sketches
• Pages and pages of text
Big Design Up Front
•   Estimates for cost and delivery dates
•   Agreement and sign-off
•   Misunderstandings
•   Software is Intangible
•   Change is inevitable
“Agile” Development
•   Short descriptions of each feature
•   Testable and Verifiable
•   Easy to understand
•   Easy to manage
•   Easy to prioritise
•   Easy to change
RSpec and Behaviour Driven
            Development
•   Getting the words right
•   It should do this
•   blue.should be_darker_than(turquoise)
•   Code as Specification
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
Integration Tests
• Test the full stack
• Interactions between objects
• Written as code
RSpec User Stories
• User Stories
• Full Stack Testing
• Plain Text plus Executables
Story Structure
• As a ...
• I want ...
• So that ...
Scenarios
• Different paths
• Success and Errors
• “Blank Slate”
Given
•   Set up pre-requisites
•   Set up state
•   Given a user called Dave
•   And Dave is logged in
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
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
Steps
• Given, When and Then
• Text matchers, with parameters
• Executable
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
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
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
Cucumber
• Structure for organising stories and steps
• rake features
• Is now part of RSpec
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
References
•   RSpec
•   Cucumber
•   Webrat
•   JBehave
•   Celerity
•   HTMLUnit

More Related Content

What's hot

Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with BehatBehavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behat
imoneytech
 
Intro to-rails-webperf
Intro to-rails-webperfIntro to-rails-webperf
Intro to-rails-webperf
New Relic
 

What's hot (20)

Catalog display
Catalog displayCatalog display
Catalog display
 
Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with BehatBehavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behat
 
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
 
Intro to-rails-webperf
Intro to-rails-webperfIntro to-rails-webperf
Intro to-rails-webperf
 
I Love codeigniter, You?
I Love codeigniter, You?I Love codeigniter, You?
I Love codeigniter, You?
 
Optimizing AngularJS Application
Optimizing AngularJS ApplicationOptimizing AngularJS Application
Optimizing AngularJS Application
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp Atlanta
 
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST API
 
Built in filters
Built in filtersBuilt in filters
Built in filters
 
Using of TDD practices for Magento
Using of TDD practices for MagentoUsing of TDD practices for Magento
Using of TDD practices for Magento
 
Building an App with jQuery and JAXER
Building an App with jQuery and JAXERBuilding an App with jQuery and JAXER
Building an App with jQuery and JAXER
 
Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)
 
Ruby on Rails testing with Rspec
Ruby on Rails testing with RspecRuby on Rails testing with Rspec
Ruby on Rails testing with Rspec
 
RSpec
RSpecRSpec
RSpec
 
Ractive js
Ractive jsRactive js
Ractive js
 
Shaping up with angular JS
Shaping up with angular JSShaping up with angular JS
Shaping up with angular JS
 
Rails is not just Ruby
Rails is not just RubyRails is not just Ruby
Rails is not just Ruby
 
Boosting Your Productivity, with Backbone & RactiveJS
Boosting Your Productivity, with Backbone & RactiveJS Boosting Your Productivity, with Backbone & RactiveJS
Boosting Your Productivity, with Backbone & RactiveJS
 
Excellent
ExcellentExcellent
Excellent
 

Similar to Telling Stories With RSpec

Wide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendWide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
MySQLConference
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And Maven
PerconaPerformance
 
ruote stockholm 2008
ruote stockholm 2008ruote stockholm 2008
ruote stockholm 2008
John Mettraux
 
Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2
Byrne Reese
 
Towards a Framework for the Composition & Performance of Real-Time Notation
Towards a Framework for the Composition & Performance of Real-Time NotationTowards a Framework for the Composition & Performance of Real-Time Notation
Towards a Framework for the Composition & Performance of Real-Time Notation
chrismcclelland
 
iPhone Development For Experienced Web Developers
iPhone Development For Experienced Web DevelopersiPhone Development For Experienced Web Developers
iPhone Development For Experienced Web Developers
lisab517
 
Android Bootcamp
Android   BootcampAndroid   Bootcamp
Android Bootcamp
ahkjsdcsadc
 

Similar to Telling Stories With RSpec (20)

When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Rails
 
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendWide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
 
Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client Development
 
Basics of Rich Internet Applications
Basics of Rich Internet ApplicationsBasics of Rich Internet Applications
Basics of Rich Internet Applications
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
 
Mapreduce Pact06 Keynote
Mapreduce Pact06 KeynoteMapreduce Pact06 Keynote
Mapreduce Pact06 Keynote
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And Maven
 
Magee Dday2 Fixing App Performance Italiano
Magee Dday2 Fixing App Performance ItalianoMagee Dday2 Fixing App Performance Italiano
Magee Dday2 Fixing App Performance Italiano
 
ruote stockholm 2008
ruote stockholm 2008ruote stockholm 2008
ruote stockholm 2008
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
 
Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2
 
Towards a Framework for the Composition & Performance of Real-Time Notation
Towards a Framework for the Composition & Performance of Real-Time NotationTowards a Framework for the Composition & Performance of Real-Time Notation
Towards a Framework for the Composition & Performance of Real-Time Notation
 
Asp.Net Mvc Dev Days09
Asp.Net Mvc Dev Days09Asp.Net Mvc Dev Days09
Asp.Net Mvc Dev Days09
 
Story Driven Development
Story Driven DevelopmentStory Driven Development
Story Driven Development
 
Workin On The Rails Road
Workin On The Rails RoadWorkin On The Rails Road
Workin On The Rails Road
 
iPhone Development For Experienced Web Developers
iPhone Development For Experienced Web DevelopersiPhone Development For Experienced Web Developers
iPhone Development For Experienced Web Developers
 
Jumping Into Java Then!
Jumping Into Java Then!Jumping Into Java Then!
Jumping Into Java Then!
 
Framework Presentation
Framework PresentationFramework Presentation
Framework Presentation
 
Android Bootcamp
Android   BootcampAndroid   Bootcamp
Android Bootcamp
 
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Telling Stories With RSpec

  • 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