SlideShare uma empresa Scribd logo
1 de 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!

Mais conteúdo relacionado

Mais procurados

優しい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
 

Mais procurados (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
 

Destaque

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
 

Destaque (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
 

Semelhante a 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
 

Semelhante a 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
 

Último

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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
[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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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
 
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
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
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
 
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 WorkerThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
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
 
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 Takeoffsammart93
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Último (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
[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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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...
 
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
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
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...
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

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!

Notas do Editor

  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