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

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
Mark Menard
 
Iuav camp presentazione
Iuav camp presentazioneIuav camp presentazione
Iuav camp presentazione
01021990
 

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

Rinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat PortfolioRinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat Portfolio
Rinkeshkumar15
 
Rinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat PortfolioRinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat Portfolio
Rinkeshkumar15
 
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
Audra Williams
 
SetFocus SQL Portfolio
SetFocus SQL PortfolioSetFocus SQL Portfolio
SetFocus SQL Portfolio
geometro17
 
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
suresh konda
 
Jazmine Kane Portfolio
Jazmine Kane PortfolioJazmine Kane Portfolio
Jazmine Kane Portfolio
Jazmine Kane
 
conf2015_TLaGatta_CHarris_Splunk_BusinessAnalytics_DeliveringHighLevelAnalytics
conf2015_TLaGatta_CHarris_Splunk_BusinessAnalytics_DeliveringHighLevelAnalyticsconf2015_TLaGatta_CHarris_Splunk_BusinessAnalytics_DeliveringHighLevelAnalytics
conf2015_TLaGatta_CHarris_Splunk_BusinessAnalytics_DeliveringHighLevelAnalytics
Tom 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

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

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