SlideShare une entreprise Scribd logo
1  sur  34
UPenn on Rails
Lesson 2: User Stories and Testing
User Stories

  Testing
How’s it going?

Got some Players?

 Is it on GitHub?

    Heroku?
User Stories
(pivotal tracker)
In order to [value]

As a [actor]

I want [feature]
Players feature?
In order to know who is on a team

As a league manager

I want to see a list of players on
the team page
Feature: Player listings
  In order to know who is on a team
  As a league manager
  I want to see a list of players on the team page

  Scenario: listing on a team page
    Given I am on the teams page
    When I follow "Ballshevicks"
    Then I should see "Trotter"
Cucumber
Feature: Player listings
  In order to know who is on a team
  As a league manager
  I want to see a list of players on the team page

  Scenario: listing on a team page
    Given I am on the teams page
    When I follow "Ballshevicks"
    Then I should see "Trotter"
User Stories
as Integration Tests
Setting up Cucumber
1. Add `group :development, :test` to Gemfile
2. Add ‘cucumber-rails’, ‘capybara’ and
   ‘database_cleaner’ in that group
3. Run `bundle`
4. Run `rails generate cucumber:install`
5. `$EDITOR features/players.feature`
undefined local variable or method `node' for
  #<Capybara::Driver::RackTest::Node:...>
               (NameError)

    • Comment out line 18 in features/
      support/env.rb


    • cucumber-rails 0.4.0 fixes this, but it’s still in
      beta
CODE
(setting it up)
Running a scenario


1. Put `@wip` above the scenario
2. Run `rake cucumber:wip`
CODE
(running it)
Debugging

`Then show me the page`
requires ‘launchy’ gem

`Then debug` (debugger;1)
requires ‘ruby-debug’ or ‘ruby-debug19’
CODE
(debugging it)
Building data
`$EDITOR features/support/fixtures.rb`

Before do
  Team.create(:name => "Ballshevicks")
end
• Any features/support/*.rb gets loaded

• `Before` gets run before each Scenario
Other Data Options


• Load test/fixtures/*.yml
• Use the ‘fabrication’ object factory gem
CODE
(giving it data)
Defining Steps
          When I follow "Show" in the row with "Ballshevicks"




When /^I follow "([^"]*)" in the row with "([^"]*)"$/ do |link, text|

  When %Q|I follow "#{link}" within "tr:contains('#{text}')"|

end
               features/step_definitions/table_steps.rb
Defining Steps
          When I follow "Show" in the row with "Ballshevicks"



 Regular Expression


When /^I follow "([^"]*)" in the row with "([^"]*)"$/ do |link, text|

  When %Q|I follow "#{link}" within "tr:contains('#{text}')"|

end
               features/step_definitions/table_steps.rb
Defining Steps
          When I follow "Show" in the row with "Ballshevicks"



 Regular Expression
                             Capturing groups

When /^I follow "([^"]*)" in the row with "([^"]*)"$/ do |link, text|

  When %Q|I follow "#{link}" within "tr:contains('#{text}')"|

end
               features/step_definitions/table_steps.rb
Defining Steps
          When I follow "Show" in the row with "Ballshevicks"



 Regular Expression
                             Capturing groups

When /^I follow "([^"]*)" in the row with "([^"]*)"$/ do |link, text|

  When %Q|I follow "#{link}" within "tr:contains('#{text}')"|

end
               features/step_definitions/table_steps.rb

               Definition in ruby code
web_steps.rb
Given I am on the (rake routes) page
When I press “button” / follow “link”
When I fill in “field” with “value”
When I select “option” from “field”
When I check “field”
Then I should see “text” (within “section”)
CODE
(assigning teams?)
Unit testing
Use for direct testing of

• Models (test/unit/*.rb)
• Helpers (test/unit/helpers/*.rb)
• Controllers (test/functional/*.rb)
Example:
          Player#last_name
class PlayerTest < ActiveSupport::TestCase
  test "parses out last name" do
    trotter = Player.new(:name => "Trotter Cashion")
    assert_equal "Cashion", trotter.last_name
  end
end


               (Test First! At least try.)
CODE
(run and fix it)
Homework
• Write user stories for adding and editing
  teams, players and games


• Add a username and password system
  (railscasts.com episodes 82 and 250)


• Next week: Plugins!

Contenu connexe

Tendances

優しいWAFの作り方
優しいWAFの作り方優しいWAFの作り方
優しいWAFの作り方techmemo
 
10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming languageYaroslav Tkachenko
 
My Adventures In Objective-C (A Rubyists Perspective)
My Adventures In Objective-C (A Rubyists Perspective)My Adventures In Objective-C (A Rubyists Perspective)
My Adventures In Objective-C (A Rubyists Perspective)abdels
 
The Grand Puppet Sub-Systems Tour - Nicholas Fagerlund, Puppet Labs
The Grand Puppet Sub-Systems Tour - Nicholas Fagerlund, Puppet LabsThe Grand Puppet Sub-Systems Tour - Nicholas Fagerlund, Puppet Labs
The Grand Puppet Sub-Systems Tour - Nicholas Fagerlund, Puppet LabsPuppet
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers StealBen Scofield
 
jQuery Plugin Creation
jQuery Plugin CreationjQuery Plugin Creation
jQuery Plugin Creationbenalman
 
PerlでWeb API入門
PerlでWeb API入門PerlでWeb API入門
PerlでWeb API入門Yusuke Wada
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansiblebcoca
 
How to simplify OSGi development using OBR - Peter Kriens
How to simplify OSGi development using OBR - Peter KriensHow to simplify OSGi development using OBR - Peter Kriens
How to simplify OSGi development using OBR - Peter Kriensmfrancis
 
Django REST Framework
Django REST FrameworkDjango REST Framework
Django REST FrameworkLoad Impact
 
Building Cloud Castles - LRUG
Building Cloud Castles - LRUGBuilding Cloud Castles - LRUG
Building Cloud Castles - LRUGBen Scofield
 
Codeigniter : Using Third Party Components - Zend Framework Components
Codeigniter : Using Third Party Components - Zend Framework ComponentsCodeigniter : Using Third Party Components - Zend Framework Components
Codeigniter : Using Third Party Components - Zend Framework ComponentsAbdul Malik Ikhsan
 
YAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービスYAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービスYusuke Wada
 

Tendances (20)

優しいWAFの作り方
優しいWAFの作り方優しいWAFの作り方
優しいWAFの作り方
 
Play á la Rails
Play á la RailsPlay á la Rails
Play á la Rails
 
10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language
 
Cakephpstudy5 hacks
Cakephpstudy5 hacksCakephpstudy5 hacks
Cakephpstudy5 hacks
 
My Adventures In Objective-C (A Rubyists Perspective)
My Adventures In Objective-C (A Rubyists Perspective)My Adventures In Objective-C (A Rubyists Perspective)
My Adventures In Objective-C (A Rubyists Perspective)
 
The Grand Puppet Sub-Systems Tour - Nicholas Fagerlund, Puppet Labs
The Grand Puppet Sub-Systems Tour - Nicholas Fagerlund, Puppet LabsThe Grand Puppet Sub-Systems Tour - Nicholas Fagerlund, Puppet Labs
The Grand Puppet Sub-Systems Tour - Nicholas Fagerlund, Puppet Labs
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers Steal
 
jQuery Plugin Creation
jQuery Plugin CreationjQuery Plugin Creation
jQuery Plugin Creation
 
PerlでWeb API入門
PerlでWeb API入門PerlでWeb API入門
PerlでWeb API入門
 
Findbin libs
Findbin libsFindbin libs
Findbin libs
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
How to simplify OSGi development using OBR - Peter Kriens
How to simplify OSGi development using OBR - Peter KriensHow to simplify OSGi development using OBR - Peter Kriens
How to simplify OSGi development using OBR - Peter Kriens
 
Django REST Framework
Django REST FrameworkDjango REST Framework
Django REST Framework
 
Building Cloud Castles - LRUG
Building Cloud Castles - LRUGBuilding Cloud Castles - LRUG
Building Cloud Castles - LRUG
 
RESTful web services
RESTful web servicesRESTful web services
RESTful web services
 
Codeigniter : Using Third Party Components - Zend Framework Components
Codeigniter : Using Third Party Components - Zend Framework ComponentsCodeigniter : Using Third Party Components - Zend Framework Components
Codeigniter : Using Third Party Components - Zend Framework Components
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
 
YAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービスYAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービス
 
Sprockets
SprocketsSprockets
Sprockets
 

En vedette

chef loves windows
chef loves windowschef loves windows
chef loves windowsMat Schaffer
 
2011 02-08 cucumber
2011 02-08 cucumber2011 02-08 cucumber
2011 02-08 cucumberMat Schaffer
 
Hadoop a Natural Choice for Data Intensive Log Processing
Hadoop a Natural Choice for Data Intensive Log ProcessingHadoop a Natural Choice for Data Intensive Log Processing
Hadoop a Natural Choice for Data Intensive Log ProcessingHitendra Kumar
 
wwc start-launched
wwc start-launchedwwc start-launched
wwc start-launchedMat Schaffer
 

En vedette (6)

chef loves windows
chef loves windowschef loves windows
chef loves windows
 
2011 02-08 cucumber
2011 02-08 cucumber2011 02-08 cucumber
2011 02-08 cucumber
 
Hadoop a Natural Choice for Data Intensive Log Processing
Hadoop a Natural Choice for Data Intensive Log ProcessingHadoop a Natural Choice for Data Intensive Log Processing
Hadoop a Natural Choice for Data Intensive Log Processing
 
Node.js
Node.jsNode.js
Node.js
 
Ruby on the Phone
Ruby on the PhoneRuby on the Phone
Ruby on the Phone
 
wwc start-launched
wwc start-launchedwwc start-launched
wwc start-launched
 

Similaire à UPenn on Rails pt 2

Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
Riak with node.js
Riak with node.jsRiak with node.js
Riak with node.jsSean Cribbs
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
Crafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyNikhil Mungel
 
Rugged Driven Development with Gauntlt
Rugged Driven Development with GauntltRugged Driven Development with Gauntlt
Rugged Driven Development with GauntltJames Wickett
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends旻琦 潘
 
The Best (and Worst) of Django
The Best (and Worst) of DjangoThe Best (and Worst) of Django
The Best (and Worst) of DjangoJacob Kaplan-Moss
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - IntroductionVagmi Mudumbai
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasminePaulo Ragonha
 
Doing the Refactor Dance - Making Your Puppet Modules More Modular - PuppetCo...
Doing the Refactor Dance - Making Your Puppet Modules More Modular - PuppetCo...Doing the Refactor Dance - Making Your Puppet Modules More Modular - PuppetCo...
Doing the Refactor Dance - Making Your Puppet Modules More Modular - PuppetCo...Puppet
 
Test legacy apps with Behat
Test legacy apps with BehatTest legacy apps with Behat
Test legacy apps with Behatagpavlakis
 
Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Clinton Dreisbach
 
Refactor Dance - Puppet Labs 'Best Practices'
Refactor Dance - Puppet Labs 'Best Practices'Refactor Dance - Puppet Labs 'Best Practices'
Refactor Dance - Puppet Labs 'Best Practices'Gary Larizza
 
Desarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosDesarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosEdgar Suarez
 
Isolated development in python
Isolated development in pythonIsolated development in python
Isolated development in pythonAndrés J. Díaz
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium AppsNate Abele
 
Integration Testing With Cucumber How To Test Anything J A O O 2009
Integration Testing With  Cucumber    How To Test Anything    J A O O 2009Integration Testing With  Cucumber    How To Test Anything    J A O O 2009
Integration Testing With Cucumber How To Test Anything J A O O 2009Dr Nic Williams
 

Similaire à UPenn on Rails pt 2 (20)

Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Riak with node.js
Riak with node.jsRiak with node.js
Riak with node.js
 
Rails 4.0
Rails 4.0Rails 4.0
Rails 4.0
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
Crafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in Ruby
 
Rugged Driven Development with Gauntlt
Rugged Driven Development with GauntltRugged Driven Development with Gauntlt
Rugged Driven Development with Gauntlt
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends
 
The Best (and Worst) of Django
The Best (and Worst) of DjangoThe Best (and Worst) of Django
The Best (and Worst) of Django
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
Doing the Refactor Dance - Making Your Puppet Modules More Modular - PuppetCo...
Doing the Refactor Dance - Making Your Puppet Modules More Modular - PuppetCo...Doing the Refactor Dance - Making Your Puppet Modules More Modular - PuppetCo...
Doing the Refactor Dance - Making Your Puppet Modules More Modular - PuppetCo...
 
Test legacy apps with Behat
Test legacy apps with BehatTest legacy apps with Behat
Test legacy apps with Behat
 
Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3
 
Refactor Dance - Puppet Labs 'Best Practices'
Refactor Dance - Puppet Labs 'Best Practices'Refactor Dance - Puppet Labs 'Best Practices'
Refactor Dance - Puppet Labs 'Best Practices'
 
Cucumber
CucumberCucumber
Cucumber
 
Desarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosDesarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutos
 
Isolated development in python
Isolated development in pythonIsolated development in python
Isolated development in python
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium Apps
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Integration Testing With Cucumber How To Test Anything J A O O 2009
Integration Testing With  Cucumber    How To Test Anything    J A O O 2009Integration Testing With  Cucumber    How To Test Anything    J A O O 2009
Integration Testing With Cucumber How To Test Anything J A O O 2009
 

Dernier

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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...Enterprise Knowledge
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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 Scriptwesley chun
 
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 Processorsdebabhi2
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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.pptxEarley Information Science
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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 productivityPrincipled Technologies
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Dernier (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

UPenn on Rails pt 2

  • 1. UPenn on Rails Lesson 2: User Stories and Testing
  • 2. User Stories Testing
  • 3. How’s it going? Got some Players? Is it on GitHub? Heroku?
  • 6. In order to [value] As a [actor] I want [feature]
  • 8. In order to know who is on a team As a league manager I want to see a list of players on the team page
  • 9. Feature: Player listings In order to know who is on a team As a league manager I want to see a list of players on the team page Scenario: listing on a team page Given I am on the teams page When I follow "Ballshevicks" Then I should see "Trotter"
  • 10. Cucumber Feature: Player listings In order to know who is on a team As a league manager I want to see a list of players on the team page Scenario: listing on a team page Given I am on the teams page When I follow "Ballshevicks" Then I should see "Trotter"
  • 12. Setting up Cucumber 1. Add `group :development, :test` to Gemfile 2. Add ‘cucumber-rails’, ‘capybara’ and ‘database_cleaner’ in that group 3. Run `bundle` 4. Run `rails generate cucumber:install` 5. `$EDITOR features/players.feature`
  • 13. undefined local variable or method `node' for #<Capybara::Driver::RackTest::Node:...> (NameError) • Comment out line 18 in features/ support/env.rb • cucumber-rails 0.4.0 fixes this, but it’s still in beta
  • 15. Running a scenario 1. Put `@wip` above the scenario 2. Run `rake cucumber:wip`
  • 17. Debugging `Then show me the page` requires ‘launchy’ gem `Then debug` (debugger;1) requires ‘ruby-debug’ or ‘ruby-debug19’
  • 21. • Any features/support/*.rb gets loaded • `Before` gets run before each Scenario
  • 22. Other Data Options • Load test/fixtures/*.yml • Use the ‘fabrication’ object factory gem
  • 24. Defining Steps When I follow "Show" in the row with "Ballshevicks" When /^I follow "([^"]*)" in the row with "([^"]*)"$/ do |link, text|   When %Q|I follow "#{link}" within "tr:contains('#{text}')"| end features/step_definitions/table_steps.rb
  • 25. Defining Steps When I follow "Show" in the row with "Ballshevicks" Regular Expression When /^I follow "([^"]*)" in the row with "([^"]*)"$/ do |link, text|   When %Q|I follow "#{link}" within "tr:contains('#{text}')"| end features/step_definitions/table_steps.rb
  • 26. Defining Steps When I follow "Show" in the row with "Ballshevicks" Regular Expression Capturing groups When /^I follow "([^"]*)" in the row with "([^"]*)"$/ do |link, text|   When %Q|I follow "#{link}" within "tr:contains('#{text}')"| end features/step_definitions/table_steps.rb
  • 27. Defining Steps When I follow "Show" in the row with "Ballshevicks" Regular Expression Capturing groups When /^I follow "([^"]*)" in the row with "([^"]*)"$/ do |link, text|   When %Q|I follow "#{link}" within "tr:contains('#{text}')"| end features/step_definitions/table_steps.rb Definition in ruby code
  • 28. web_steps.rb Given I am on the (rake routes) page When I press “button” / follow “link” When I fill in “field” with “value” When I select “option” from “field” When I check “field” Then I should see “text” (within “section”)
  • 31. Use for direct testing of • Models (test/unit/*.rb) • Helpers (test/unit/helpers/*.rb) • Controllers (test/functional/*.rb)
  • 32. Example: Player#last_name class PlayerTest < ActiveSupport::TestCase   test "parses out last name" do     trotter = Player.new(:name => "Trotter Cashion")     assert_equal "Cashion", trotter.last_name   end end (Test First! At least try.)
  • 34. Homework • Write user stories for adding and editing teams, players and games • Add a username and password system (railscasts.com episodes 82 and 250) • Next week: Plugins!

Notes de l'éditeur

  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
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n