SlideShare a Scribd company logo
1 of 14
Ruby on Rails
Training Week 2

Fast Books an
Example Project

Using Behavior
Driven
Development

by Mark Menard
Enable Labs
Fast Books
 A check book ledger program.
 You will learn about:
   Behavior Driven Development
   Story Carding
   Cucumber
   RSpec
   Active Record Models
     Validation
     Associations
  Action Controller
     REST
  Active View
     ERB Templates
                                  2
Requirements
 The system should allow the management of multiple
  accounts
 The system should maintain an account ledger for
  every account in the system.
 Each account ledger should consist of ledger entries.
 Each ledger entry can be either a positive or negative
  value.
 Ledger entries can be associated with a payee and a
  category.




                                                           3
Workflow Overview
 Story card use cases
 Create a new project
 Setup RSpec and Factory Girl
 Theme the project
 Define resource using: script/generate rspec_scaffold
 Create Cucumber scenarios specifying the stories in
  the application
 Write specification for model




                                                          4
Story Carding

 Story cards are bits of narrative describing
 features of the system under development.
 They are called "cards" because in
 traditional extreme programming practice,
 they were written on paper index cards.
 The constraints of an index card were
 considered a plus -- the writing on the card
 is intended to be a marker for
 communication, not a comprehensive
 requirements document that fully describes
 the feature represented by the story.          5
Story Carding
 Every interaction with the application should have a
  story card.
 Stories should be short and too the point.
 Stories are made up of four parts:
   In order to < do some business value >
   As a < actor > on < a context >
   I want to < do something >
   Acceptance criteria




                                                         6
An Example Story Card
In order to track written checks
As a user on the account view page
I want to be able to add a check


- view account page
- click the add check button
- fill in
-- check number
-- fill in payee                     Acceptance Criteria
-- fill in amount
-- fill in category
-- fill in memo
- click submit button
- see new entry on account ledger


                                                           7
Create Initial Story Cards
 Create account
 List accounts
 View account
 Edit account
 Write a check
 Make a deposit
 Add a payee
 Add a category
 View payee report
 View category report


                             8
Behavior Driven Development
 Focus on what something should do.
 Encourages a literate style.
 Supports extraction of the specification in a readable
  format.
 Specs should be readable by domain experts.
 Specs should be executable.
 Should support testing code in isolation, integrated
  and full stack.
   When the spec runs you’re done.



                                                           9
Cucumber
 A high level behavior driven testing framework using
 plain language executable specifications.
 Feature: Contact Us
   As an anonymous user I want to be able to send a message
   So that I can receive support or get an answer to a question

   Scenario: Load Form
     Given I am on "home page"
     When I follow "Contact Us"
     Then I should see "Please use the following form"

   Scenario: Submitting form
     Given I am on the "contact us page"
     When I fill in "contact_handler[email]" with "me@example.com"
     And I fill in "contact_handler[subject]" with "Help"
     And I fill in "contact_handler[body]" with "Content"
     And I press "send"
     Then I should see "Thanks for your message."

                                                                  10
Create Initial Cucumber Scenarios
 View List Accounts Page
 Create Account
 View Account
 Edit Account




                                    11
RSpec
 RSpec provides a domain specific language with which
  you can express executable examples of the expected
  behavior of your code.
 RSpec includes support for mocking and stubbing.
 I use it as a replacement for unit and integration
  testing.
   Models and controllers




                                                     12
An RSpec Example
   You:      Describe an account when it is first created.
   Customer: It should have a balance of $0.



describe Account, "when first created" do
  it "should have a balance of $0" do
    ...
  end
end

  When you run this example, RSpec can provide a report like this:



      Account when first created
      - should have a balance of $0
                                                                     13
The Check Register Data Model




                                14

More Related Content

Viewers also liked

Startup Lessons Learned
Startup Lessons LearnedStartup Lessons Learned
Startup Lessons LearnedMark Menard
 
Conference of Grand Masters Tech Talk 2013
Conference of Grand Masters Tech Talk 2013Conference of Grand Masters Tech Talk 2013
Conference of Grand Masters Tech Talk 2013Mark Menard
 
Let's Do Some Upfront Design - WindyCityRails 2014
Let's Do Some Upfront Design - WindyCityRails 2014Let's Do Some Upfront Design - WindyCityRails 2014
Let's Do Some Upfront Design - WindyCityRails 2014Mark Menard
 
Small Code - RailsConf 2014
Small Code - RailsConf 2014Small Code - RailsConf 2014
Small Code - RailsConf 2014Mark Menard
 
JRuby in a Java World
JRuby in a Java WorldJRuby in a Java World
JRuby in a Java WorldMark Menard
 
Iuav camp presentazione
Iuav camp presentazioneIuav camp presentazione
Iuav camp presentazione01021990
 
Intro to Ruby on Rails
Intro to Ruby on RailsIntro to Ruby on Rails
Intro to Ruby on RailsMark Menard
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Mark Menard
 
Intro to Rails ActiveRecord
Intro to Rails ActiveRecordIntro to Rails ActiveRecord
Intro to Rails ActiveRecordMark Menard
 

Viewers also liked (9)

Startup Lessons Learned
Startup Lessons LearnedStartup Lessons Learned
Startup Lessons Learned
 
Conference of Grand Masters Tech Talk 2013
Conference of Grand Masters Tech Talk 2013Conference of Grand Masters Tech Talk 2013
Conference of Grand Masters Tech Talk 2013
 
Let's Do Some Upfront Design - WindyCityRails 2014
Let's Do Some Upfront Design - WindyCityRails 2014Let's Do Some Upfront Design - WindyCityRails 2014
Let's Do Some Upfront Design - WindyCityRails 2014
 
Small Code - RailsConf 2014
Small Code - RailsConf 2014Small Code - RailsConf 2014
Small Code - RailsConf 2014
 
JRuby in a Java World
JRuby in a Java WorldJRuby in a Java World
JRuby in a Java World
 
Iuav camp presentazione
Iuav camp presentazioneIuav camp presentazione
Iuav camp presentazione
 
Intro to Ruby on Rails
Intro to Ruby on RailsIntro to Ruby on Rails
Intro to Ruby on Rails
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 
Intro to Rails ActiveRecord
Intro to Rails ActiveRecordIntro to Rails ActiveRecord
Intro to Rails ActiveRecord
 

Similar to Ruby on Rails Training - Module 2

Reynaldo Fadri’S Porfolio
Reynaldo Fadri’S PorfolioReynaldo Fadri’S Porfolio
Reynaldo Fadri’S Porfoliorfadri
 
Rinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat PortfolioRinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat PortfolioRinkeshkumar15
 
Rinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat PortfolioRinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat PortfolioRinkeshkumar15
 
Pay pal email guidelines 7 27-is
Pay pal email guidelines 7 27-isPay pal email guidelines 7 27-is
Pay pal email guidelines 7 27-isAudra Williams
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAraf Karsh Hamid
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With CucumberSean Cribbs
 
Robert Parkin Portfolio
Robert Parkin PortfolioRobert Parkin Portfolio
Robert Parkin Portfoliorsparkin
 
Transforming Feature Ideas into Machine Learning Inputs
Transforming Feature Ideas into Machine Learning InputsTransforming Feature Ideas into Machine Learning Inputs
Transforming Feature Ideas into Machine Learning InputsFeatureByte
 
Using Stories to Test Requirements and Systems
Using Stories to Test Requirements and SystemsUsing Stories to Test Requirements and Systems
Using Stories to Test Requirements and SystemsPaul Gerrard
 
SetFocus SQL Portfolio
SetFocus SQL PortfolioSetFocus SQL Portfolio
SetFocus SQL Portfoliogeometro17
 
SAP BO and BODS_4+ years of exp
SAP BO and BODS_4+ years of expSAP BO and BODS_4+ years of exp
SAP BO and BODS_4+ years of expsuresh konda
 
Jazmine Kane Portfolio
Jazmine Kane PortfolioJazmine Kane Portfolio
Jazmine Kane PortfolioJazmine Kane
 
SetFocus Reporting Services Project
SetFocus Reporting Services ProjectSetFocus Reporting Services Project
SetFocus Reporting Services ProjectDavidPerley
 
The Enable Labs Way
The Enable Labs WayThe Enable Labs Way
The Enable Labs Wayjwilson2244
 
conf2015_TLaGatta_CHarris_Splunk_BusinessAnalytics_DeliveringHighLevelAnalytics
conf2015_TLaGatta_CHarris_Splunk_BusinessAnalytics_DeliveringHighLevelAnalyticsconf2015_TLaGatta_CHarris_Splunk_BusinessAnalytics_DeliveringHighLevelAnalytics
conf2015_TLaGatta_CHarris_Splunk_BusinessAnalytics_DeliveringHighLevelAnalyticsTom LaGatta
 

Similar to Ruby on Rails Training - Module 2 (20)

Reynaldo Fadri’S Porfolio
Reynaldo Fadri’S PorfolioReynaldo Fadri’S Porfolio
Reynaldo Fadri’S Porfolio
 
Rinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat PortfolioRinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat Portfolio
 
Rinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat PortfolioRinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat Portfolio
 
Pay pal email guidelines 7 27-is
Pay pal email guidelines 7 27-isPay pal email guidelines 7 27-is
Pay pal email guidelines 7 27-is
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With Cucumber
 
Robert Parkin Portfolio
Robert Parkin PortfolioRobert Parkin Portfolio
Robert Parkin Portfolio
 
User Stories
User StoriesUser Stories
User Stories
 
Test script
Test scriptTest script
Test script
 
LEYTON_AgileBusinessAnalystSample
LEYTON_AgileBusinessAnalystSampleLEYTON_AgileBusinessAnalystSample
LEYTON_AgileBusinessAnalystSample
 
Transforming Feature Ideas into Machine Learning Inputs
Transforming Feature Ideas into Machine Learning InputsTransforming Feature Ideas into Machine Learning Inputs
Transforming Feature Ideas into Machine Learning Inputs
 
Using Stories to Test Requirements and Systems
Using Stories to Test Requirements and SystemsUsing Stories to Test Requirements and Systems
Using Stories to Test Requirements and Systems
 
SetFocus SQL Portfolio
SetFocus SQL PortfolioSetFocus SQL Portfolio
SetFocus SQL Portfolio
 
SAP BO and BODS_4+ years of exp
SAP BO and BODS_4+ years of expSAP BO and BODS_4+ years of exp
SAP BO and BODS_4+ years of exp
 
Jazmine Kane Portfolio
Jazmine Kane PortfolioJazmine Kane Portfolio
Jazmine Kane Portfolio
 
Marcus Matthews
Marcus MatthewsMarcus Matthews
Marcus Matthews
 
SetFocus Reporting Services Project
SetFocus Reporting Services ProjectSetFocus Reporting Services Project
SetFocus Reporting Services Project
 
The Enable Labs Way
The Enable Labs WayThe Enable Labs Way
The Enable Labs Way
 
conf2015_TLaGatta_CHarris_Splunk_BusinessAnalytics_DeliveringHighLevelAnalytics
conf2015_TLaGatta_CHarris_Splunk_BusinessAnalytics_DeliveringHighLevelAnalyticsconf2015_TLaGatta_CHarris_Splunk_BusinessAnalytics_DeliveringHighLevelAnalytics
conf2015_TLaGatta_CHarris_Splunk_BusinessAnalytics_DeliveringHighLevelAnalytics
 
OLT open script
OLT open script OLT open script
OLT open script
 

Recently uploaded

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 Nanonetsnaman860154
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 

Recently uploaded (20)

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
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 

Ruby on Rails Training - Module 2

  • 1. Ruby on Rails Training Week 2 Fast Books an Example Project Using Behavior Driven Development by Mark Menard Enable Labs
  • 2. Fast Books  A check book ledger program.  You will learn about:  Behavior Driven Development  Story Carding  Cucumber  RSpec  Active Record Models  Validation  Associations  Action Controller  REST  Active View  ERB Templates 2
  • 3. Requirements  The system should allow the management of multiple accounts  The system should maintain an account ledger for every account in the system.  Each account ledger should consist of ledger entries.  Each ledger entry can be either a positive or negative value.  Ledger entries can be associated with a payee and a category. 3
  • 4. Workflow Overview  Story card use cases  Create a new project  Setup RSpec and Factory Girl  Theme the project  Define resource using: script/generate rspec_scaffold  Create Cucumber scenarios specifying the stories in the application  Write specification for model 4
  • 5. Story Carding Story cards are bits of narrative describing features of the system under development. They are called "cards" because in traditional extreme programming practice, they were written on paper index cards. The constraints of an index card were considered a plus -- the writing on the card is intended to be a marker for communication, not a comprehensive requirements document that fully describes the feature represented by the story. 5
  • 6. Story Carding  Every interaction with the application should have a story card.  Stories should be short and too the point.  Stories are made up of four parts:  In order to < do some business value >  As a < actor > on < a context >  I want to < do something >  Acceptance criteria 6
  • 7. An Example Story Card In order to track written checks As a user on the account view page I want to be able to add a check - view account page - click the add check button - fill in -- check number -- fill in payee Acceptance Criteria -- fill in amount -- fill in category -- fill in memo - click submit button - see new entry on account ledger 7
  • 8. Create Initial Story Cards  Create account  List accounts  View account  Edit account  Write a check  Make a deposit  Add a payee  Add a category  View payee report  View category report 8
  • 9. Behavior Driven Development  Focus on what something should do.  Encourages a literate style.  Supports extraction of the specification in a readable format.  Specs should be readable by domain experts.  Specs should be executable.  Should support testing code in isolation, integrated and full stack.  When the spec runs you’re done. 9
  • 10. Cucumber  A high level behavior driven testing framework using plain language executable specifications. Feature: Contact Us As an anonymous user I want to be able to send a message So that I can receive support or get an answer to a question Scenario: Load Form Given I am on "home page" When I follow "Contact Us" Then I should see "Please use the following form" Scenario: Submitting form Given I am on the "contact us page" When I fill in "contact_handler[email]" with "me@example.com" And I fill in "contact_handler[subject]" with "Help" And I fill in "contact_handler[body]" with "Content" And I press "send" Then I should see "Thanks for your message." 10
  • 11. Create Initial Cucumber Scenarios  View List Accounts Page  Create Account  View Account  Edit Account 11
  • 12. RSpec  RSpec provides a domain specific language with which you can express executable examples of the expected behavior of your code.  RSpec includes support for mocking and stubbing.  I use it as a replacement for unit and integration testing.  Models and controllers 12
  • 13. An RSpec Example You: Describe an account when it is first created. Customer: It should have a balance of $0. describe Account, "when first created" do it "should have a balance of $0" do ... end end When you run this example, RSpec can provide a report like this: Account when first created - should have a balance of $0 13
  • 14. The Check Register Data Model 14

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n