SlideShare una empresa de Scribd logo
1 de 20
Descargar para leer sin conexión
Yura Tolstik
Ruby/Rails developer at Altoros Development

            t witter: @yltsrc
         email: yltsrc@gmail.com
Do your test


              Why?

test before          save time
     or                 or
 test after          waste time
Save time writing code???
     We spend time writing tests, but
      we save time with tests, so...




        Spent time == Saved time
Rspec best practices

$ rake spec
...........................................................
...........................................................
...........................................................
...........................................................
...........................................................
....................................................

Finished in 0.00116 seconds
Describe what you are doing
 describe User do
   describe '.authenticate' do
   end

   describe '.admins' do
   end

   describe '#admin?' do
   end

   describe '#name' do
   end
 end
Establish the context

describe '#create' do
  context 'given valid credentials' do
  end
 
  context 'given invalid credentials' do
  end
end
it only expects one thing
describe '#create' do
  it 'creates a new user' do
   User.count.should == @count + 1
  end
 
  it 'sets a flash message' do
    flash[:notice].should be
  end
 
  it "redirects to the new user's profile" do
    response.should redirect_to(user_path(assigns(:user)))
  end
end
Prefer explicitness
describe '#new' do
  context 'when not logged in' do
    subject do
      response
    end

    it 'redirects to the sign in page' do
      should redirect_to(sign_in_path)
    end

    it 'displays a message to sign in' do
      subject.body.should match(/sign in/i)
    end
  end
end
Confirm readability
UsersController
  #create
    creates a new user
    sets a flash message
    redirects to the new user's profile
  #show
    finds the given user
    displays its profile
  #show.json
    returns the given user as JSON
  #destroy
    deletes the given user
    sets a flash message
    redirects to the home page
Use the right matcher

object.should be

7.should respond_to(:zero?).with(0).arguments
7.should_not be_zero

expect { model.save! }.to
  raise_error(ActiveRecord::RecordNotFound)

collection.should have(4).items
Rspec options
describe "group with tagged specs" do
  it "example I'm working now", :focus => true do; end
  it "slow example", :speed => 'slow' do; end
  it "ordinary example", :skip => true do; end
end

rspec   spec/*_spec.rb   --tag @focus
rspec   spec/*_spec.rb   --tag ~@focus
rspec   spec/*_spec.rb   --tag @speed:slow
rspec   spec/*_spec.rb   --format=progress --color

# spec_helper.rb
RSpec.configure do |config|
  config.color_enabled = true
  config.formatter = :documentation
         # :progress, :html, :textmate
end
Cucumber best practices
Organize your garden

bank_account_add.feature
bank_account_delete.feature
user_signup.feature
user_signup_when_invited.feature
user_login.feature
Thinking declaratively
Scenario: Create a slide
  Given I am signed in as an admin
  When I go to the admin dashboard
    And I create a new slide

Scenario: Create a slide
  Given I am signed as an admin
  When I go to the admin dashboard
    And I create a new slide
  Then I should be able to edit it
Cucumber helps you
Feature: Search engine optimization
  In order to find company
  As a future customer
  I want to find company in google

  Scenario: Find company in google
    Given I ask google for "company"
    Then I should see "http://company.url"


$ cucumber
...
Given /^I ask google for "([^"]*)"$/ do |arg1|
  pending
end

#Gemfile
gem "cucumber-rails-training-wheels", :group => :test
Make your scenario DRY
Feature: A user can cancel a transaction unless it's
         claimed by the recipient
 
  Background:
    Given I am logged in
    And I send "$10" to "mukmuk@example.com" from my "Bank account"
 
  Scenario: I can cancel as long as the payment is not claimed
    When I cancel my latest transaction
    Then I should see a cancellation confirmation
 
  Scenario: I can't cancel once the payment is claimed
    Given "Mukmuk" claimed the latest transaction
    Then I can't cancel my latest transaction
Scenario with variables
Scenario Outline: Add invalid bank account displays inline
  errors

  Given I follow "Add Bank Account"
  When I fill in "<field>" with "<value>"
  And I press "Add Bank Account"
  And I should see the inline error "<error>" for "<field>"
 
  Examples:
    | field   | value         | error                    |
    | Account |               | Can't be blank           |
    | Account | Sixty five    | Should be 1 to 12 digits |
    | Account | 1234567890123 | Should be 1 to 12 digits | 
Cucumber options
@smoke
Feature: Find site in search engines
  @javascript @wip
  Scenario: Find site in google



cucumber --name "Find site in search engines"

cucumber features --tags @wip:3

cucumber --tags @wip,@smoke # logical OR (@wip || @smoke)

# logical AND (@wip && !@slow)
cucumber --tags @wip --tags ~@slow

cucumber features/account_*.feature --format=progress --quiet
Cucumber profiles
#cucumber.yml
<%
std_opts = "--format pretty --quiet --strict --tags ~@wip"
%>

default: <%= std_opts << " --tags ~@javascript" %> features
selenium: <%= std_opts %> features
wip: --tags @wip:3 --wip features




cucumber --profile=wip
rake cucumber:wip
Questions




       http://blog.carbonfive.com/2010/10/21/rspec-best-practices/
  https://www.relishapp.com/rspec/rspec-core/v/2-6/docs/command-line/
                https://github.com/rspec/rspec-expectations
http://eggsonbread.com/2010/09/06/my-cucumber-best-practices-and-tips/

Más contenido relacionado

Destacado

Failsafe 1 hour 2013
Failsafe 1 hour   2013Failsafe 1 hour   2013
Failsafe 1 hour 2013Marc Mercuri
 
Constitutionof india acts
Constitutionof india actsConstitutionof india acts
Constitutionof india actsAshique Mp
 
Science the bold words
Science the bold wordsScience the bold words
Science the bold wordsroyalebabyphat
 
The GCRO BAROMETER 2014
The GCRO BAROMETER 2014�The GCRO BAROMETER 2014�
The GCRO BAROMETER 2014Gaia Manco
 
Nå begynner moroa software2011
Nå begynner moroa software2011Nå begynner moroa software2011
Nå begynner moroa software2011FINN.no
 
Slutt å snakk, begynn å jobb - om FINNovasjonsdagen
Slutt å snakk, begynn å jobb - om FINNovasjonsdagenSlutt å snakk, begynn å jobb - om FINNovasjonsdagen
Slutt å snakk, begynn å jobb - om FINNovasjonsdagenFINN.no
 
Ngo 와 social network
Ngo 와 social networkNgo 와 social network
Ngo 와 social networkJinJooYeon
 
DTC Lab Kickoff Intro
DTC Lab Kickoff IntroDTC Lab Kickoff Intro
DTC Lab Kickoff IntroDTC Lab
 
Forum Innovation & the Science of Publishing
Forum Innovation & the Science of PublishingForum Innovation & the Science of Publishing
Forum Innovation & the Science of PublishingImpelsys Inc.
 
LaunchPad Resources Module
LaunchPad Resources ModuleLaunchPad Resources Module
LaunchPad Resources Moduleacastle08
 
Nebuloasa personal branding in social media
Nebuloasa   personal branding in social mediaNebuloasa   personal branding in social media
Nebuloasa personal branding in social mediaOlteaZambori
 
Mpeg Advisor Presentation Power Point[1]
Mpeg Advisor Presentation Power Point[1]Mpeg Advisor Presentation Power Point[1]
Mpeg Advisor Presentation Power Point[1]maryannstaff
 
Introduction & Session 1 - Innovation
Introduction & Session 1 - InnovationIntroduction & Session 1 - Innovation
Introduction & Session 1 - InnovationThe Digital Insurer
 
Edu 290 ppt 1
Edu 290 ppt 1Edu 290 ppt 1
Edu 290 ppt 1marti13a
 
A4 examen et corrige his geo 2012 1-am t2
A4 examen et corrige his geo 2012 1-am t2A4 examen et corrige his geo 2012 1-am t2
A4 examen et corrige his geo 2012 1-am t2Ahmed Mesellem
 
Pptppom 111011111708-phpapp01
Pptppom 111011111708-phpapp01Pptppom 111011111708-phpapp01
Pptppom 111011111708-phpapp01Sky Blue
 
Foss introduction-license-system
Foss introduction-license-systemFoss introduction-license-system
Foss introduction-license-systemnghia le trung
 

Destacado (20)

Весна в японском стиле
Весна в японском стилеВесна в японском стиле
Весна в японском стиле
 
Failsafe 1 hour 2013
Failsafe 1 hour   2013Failsafe 1 hour   2013
Failsafe 1 hour 2013
 
Constitutionof india acts
Constitutionof india actsConstitutionof india acts
Constitutionof india acts
 
Science the bold words
Science the bold wordsScience the bold words
Science the bold words
 
The GCRO BAROMETER 2014
The GCRO BAROMETER 2014�The GCRO BAROMETER 2014�
The GCRO BAROMETER 2014
 
FailSafe IaaS
FailSafe IaaSFailSafe IaaS
FailSafe IaaS
 
Nå begynner moroa software2011
Nå begynner moroa software2011Nå begynner moroa software2011
Nå begynner moroa software2011
 
Las
LasLas
Las
 
Slutt å snakk, begynn å jobb - om FINNovasjonsdagen
Slutt å snakk, begynn å jobb - om FINNovasjonsdagenSlutt å snakk, begynn å jobb - om FINNovasjonsdagen
Slutt å snakk, begynn å jobb - om FINNovasjonsdagen
 
Ngo 와 social network
Ngo 와 social networkNgo 와 social network
Ngo 와 social network
 
DTC Lab Kickoff Intro
DTC Lab Kickoff IntroDTC Lab Kickoff Intro
DTC Lab Kickoff Intro
 
Forum Innovation & the Science of Publishing
Forum Innovation & the Science of PublishingForum Innovation & the Science of Publishing
Forum Innovation & the Science of Publishing
 
LaunchPad Resources Module
LaunchPad Resources ModuleLaunchPad Resources Module
LaunchPad Resources Module
 
Nebuloasa personal branding in social media
Nebuloasa   personal branding in social mediaNebuloasa   personal branding in social media
Nebuloasa personal branding in social media
 
Mpeg Advisor Presentation Power Point[1]
Mpeg Advisor Presentation Power Point[1]Mpeg Advisor Presentation Power Point[1]
Mpeg Advisor Presentation Power Point[1]
 
Introduction & Session 1 - Innovation
Introduction & Session 1 - InnovationIntroduction & Session 1 - Innovation
Introduction & Session 1 - Innovation
 
Edu 290 ppt 1
Edu 290 ppt 1Edu 290 ppt 1
Edu 290 ppt 1
 
A4 examen et corrige his geo 2012 1-am t2
A4 examen et corrige his geo 2012 1-am t2A4 examen et corrige his geo 2012 1-am t2
A4 examen et corrige his geo 2012 1-am t2
 
Pptppom 111011111708-phpapp01
Pptppom 111011111708-phpapp01Pptppom 111011111708-phpapp01
Pptppom 111011111708-phpapp01
 
Foss introduction-license-system
Foss introduction-license-systemFoss introduction-license-system
Foss introduction-license-system
 

Similar a Do your test

From java to rails
From java to railsFrom java to rails
From java to railsjokry
 
Webinar: Top 5 Mistakes Your Don't Want to Make When Moving to the Cloud
Webinar: Top 5 Mistakes Your Don't Want to Make When Moving to the CloudWebinar: Top 5 Mistakes Your Don't Want to Make When Moving to the Cloud
Webinar: Top 5 Mistakes Your Don't Want to Make When Moving to the CloudInternap
 
Vineet Choudhry Portfolio
Vineet Choudhry PortfolioVineet Choudhry Portfolio
Vineet Choudhry PortfolioRakesh Ranjan
 
Groupware functionsinm daemon
Groupware functionsinm daemonGroupware functionsinm daemon
Groupware functionsinm daemonjupiter89
 
Make them Fall in Love All Over Again: Nurturing the Inbound Way
Make them Fall in Love All Over Again: Nurturing the Inbound WayMake them Fall in Love All Over Again: Nurturing the Inbound Way
Make them Fall in Love All Over Again: Nurturing the Inbound WayKirsten Knipp
 
Using Database Constraints Wisely
Using Database Constraints WiselyUsing Database Constraints Wisely
Using Database Constraints Wiselybarunio
 
Azri solutions leaner techniques for faster portals get drupalled
Azri solutions leaner techniques for faster portals   get drupalledAzri solutions leaner techniques for faster portals   get drupalled
Azri solutions leaner techniques for faster portals get drupalledOpenSourceIndia
 
Azri solutions leaner techniques for faster portals get drupalled
Azri solutions leaner techniques for faster portals   get drupalledAzri solutions leaner techniques for faster portals   get drupalled
Azri solutions leaner techniques for faster portals get drupalledsuniltomar04
 
Scalable JavaScript Application Architecture
Scalable JavaScript Application ArchitectureScalable JavaScript Application Architecture
Scalable JavaScript Application ArchitectureNicholas Zakas
 
Intro to Table-Grouping™ technology
Intro to Table-Grouping™ technologyIntro to Table-Grouping™ technology
Intro to Table-Grouping™ technologyDavid McFarlane
 
Jeremiah Caron, Context, Google+ for businesses and brands
Jeremiah Caron, Context, Google+ for businesses and brandsJeremiah Caron, Context, Google+ for businesses and brands
Jeremiah Caron, Context, Google+ for businesses and brandsCommunicate Magazine
 
Getting started with Cloud Foundry
Getting started with Cloud FoundryGetting started with Cloud Foundry
Getting started with Cloud FoundryLode Vermeiren
 
Getting started with Cloud Foundry
Getting started with Cloud FoundryGetting started with Cloud Foundry
Getting started with Cloud FoundryLode Vermeiren
 
Rajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websitesRajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websitesOpenSourceIndia
 
Rajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websitesRajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websitessuniltomar04
 
『Ficia』インフラとPerlにまつわるエトセトラ
『Ficia』インフラとPerlにまつわるエトセトラ『Ficia』インフラとPerlにまつわるエトセトラ
『Ficia』インフラとPerlにまつわるエトセトラMasaaki HIROSE
 
RSpec User Stories
RSpec User StoriesRSpec User Stories
RSpec User Storiesrahoulb
 

Similar a Do your test (20)

From java to rails
From java to railsFrom java to rails
From java to rails
 
Webinar: Top 5 Mistakes Your Don't Want to Make When Moving to the Cloud
Webinar: Top 5 Mistakes Your Don't Want to Make When Moving to the CloudWebinar: Top 5 Mistakes Your Don't Want to Make When Moving to the Cloud
Webinar: Top 5 Mistakes Your Don't Want to Make When Moving to the Cloud
 
Vineet Choudhry Portfolio
Vineet Choudhry PortfolioVineet Choudhry Portfolio
Vineet Choudhry Portfolio
 
Hacking Rapidshare
Hacking RapidshareHacking Rapidshare
Hacking Rapidshare
 
Groupware functionsinm daemon
Groupware functionsinm daemonGroupware functionsinm daemon
Groupware functionsinm daemon
 
Make them Fall in Love All Over Again: Nurturing the Inbound Way
Make them Fall in Love All Over Again: Nurturing the Inbound WayMake them Fall in Love All Over Again: Nurturing the Inbound Way
Make them Fall in Love All Over Again: Nurturing the Inbound Way
 
Using Database Constraints Wisely
Using Database Constraints WiselyUsing Database Constraints Wisely
Using Database Constraints Wisely
 
Azri solutions leaner techniques for faster portals get drupalled
Azri solutions leaner techniques for faster portals   get drupalledAzri solutions leaner techniques for faster portals   get drupalled
Azri solutions leaner techniques for faster portals get drupalled
 
Azri solutions leaner techniques for faster portals get drupalled
Azri solutions leaner techniques for faster portals   get drupalledAzri solutions leaner techniques for faster portals   get drupalled
Azri solutions leaner techniques for faster portals get drupalled
 
Scalable JavaScript Application Architecture
Scalable JavaScript Application ArchitectureScalable JavaScript Application Architecture
Scalable JavaScript Application Architecture
 
Intro to Table-Grouping™ technology
Intro to Table-Grouping™ technologyIntro to Table-Grouping™ technology
Intro to Table-Grouping™ technology
 
Jeremiah Caron, Context, Google+ for businesses and brands
Jeremiah Caron, Context, Google+ for businesses and brandsJeremiah Caron, Context, Google+ for businesses and brands
Jeremiah Caron, Context, Google+ for businesses and brands
 
11 tips for HTML5
11 tips for HTML511 tips for HTML5
11 tips for HTML5
 
Getting started with Cloud Foundry
Getting started with Cloud FoundryGetting started with Cloud Foundry
Getting started with Cloud Foundry
 
Getting started with Cloud Foundry
Getting started with Cloud FoundryGetting started with Cloud Foundry
Getting started with Cloud Foundry
 
Rajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websitesRajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websites
 
Rajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websitesRajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websites
 
Metodologia de-las-5-s
Metodologia de-las-5-sMetodologia de-las-5-s
Metodologia de-las-5-s
 
『Ficia』インフラとPerlにまつわるエトセトラ
『Ficia』インフラとPerlにまつわるエトセトラ『Ficia』インフラとPerlにまつわるエトセトラ
『Ficia』インフラとPerlにまつわるエトセトラ
 
RSpec User Stories
RSpec User StoriesRSpec User Stories
RSpec User Stories
 

Último

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 

Último (20)

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 

Do your test

  • 1. Yura Tolstik Ruby/Rails developer at Altoros Development t witter: @yltsrc email: yltsrc@gmail.com
  • 2. Do your test Why? test before save time or or test after waste time
  • 3. Save time writing code??? We spend time writing tests, but we save time with tests, so... Spent time == Saved time
  • 4. Rspec best practices $ rake spec ........................................................... ........................................................... ........................................................... ........................................................... ........................................................... .................................................... Finished in 0.00116 seconds
  • 5. Describe what you are doing describe User do   describe '.authenticate' do   end   describe '.admins' do   end   describe '#admin?' do   end   describe '#name' do   end end
  • 6. Establish the context describe '#create' do   context 'given valid credentials' do   end     context 'given invalid credentials' do   end end
  • 7. it only expects one thing describe '#create' do it 'creates a new user' do    User.count.should == @count + 1   end     it 'sets a flash message' do     flash[:notice].should be   end     it "redirects to the new user's profile" do     response.should redirect_to(user_path(assigns(:user)))   end end
  • 8. Prefer explicitness describe '#new' do context 'when not logged in' do     subject do       response     end     it 'redirects to the sign in page' do       should redirect_to(sign_in_path)     end     it 'displays a message to sign in' do       subject.body.should match(/sign in/i)     end   end end
  • 9. Confirm readability UsersController   #create     creates a new user     sets a flash message     redirects to the new user's profile   #show     finds the given user     displays its profile   #show.json     returns the given user as JSON   #destroy     deletes the given user     sets a flash message     redirects to the home page
  • 10. Use the right matcher object.should be 7.should respond_to(:zero?).with(0).arguments 7.should_not be_zero expect { model.save! }.to raise_error(ActiveRecord::RecordNotFound) collection.should have(4).items
  • 11. Rspec options describe "group with tagged specs" do it "example I'm working now", :focus => true do; end it "slow example", :speed => 'slow' do; end it "ordinary example", :skip => true do; end end rspec spec/*_spec.rb --tag @focus rspec spec/*_spec.rb --tag ~@focus rspec spec/*_spec.rb --tag @speed:slow rspec spec/*_spec.rb --format=progress --color # spec_helper.rb RSpec.configure do |config| config.color_enabled = true config.formatter = :documentation # :progress, :html, :textmate end
  • 14. Thinking declaratively Scenario: Create a slide Given I am signed in as an admin When I go to the admin dashboard And I create a new slide Scenario: Create a slide Given I am signed as an admin When I go to the admin dashboard And I create a new slide Then I should be able to edit it
  • 15. Cucumber helps you Feature: Search engine optimization In order to find company As a future customer I want to find company in google Scenario: Find company in google Given I ask google for "company" Then I should see "http://company.url" $ cucumber ... Given /^I ask google for "([^"]*)"$/ do |arg1| pending end #Gemfile gem "cucumber-rails-training-wheels", :group => :test
  • 16. Make your scenario DRY Feature: A user can cancel a transaction unless it's claimed by the recipient     Background:     Given I am logged in     And I send "$10" to "mukmuk@example.com" from my "Bank account"     Scenario: I can cancel as long as the payment is not claimed     When I cancel my latest transaction     Then I should see a cancellation confirmation     Scenario: I can't cancel once the payment is claimed     Given "Mukmuk" claimed the latest transaction     Then I can't cancel my latest transaction
  • 17. Scenario with variables Scenario Outline: Add invalid bank account displays inline errors   Given I follow "Add Bank Account"   When I fill in "<field>" with "<value>"   And I press "Add Bank Account"   And I should see the inline error "<error>" for "<field>"     Examples:     | field   | value         | error                    |     | Account |               | Can't be blank           |     | Account | Sixty five    | Should be 1 to 12 digits |     | Account | 1234567890123 | Should be 1 to 12 digits | 
  • 18. Cucumber options @smoke Feature: Find site in search engines @javascript @wip Scenario: Find site in google cucumber --name "Find site in search engines" cucumber features --tags @wip:3 cucumber --tags @wip,@smoke # logical OR (@wip || @smoke) # logical AND (@wip && !@slow) cucumber --tags @wip --tags ~@slow cucumber features/account_*.feature --format=progress --quiet
  • 19. Cucumber profiles #cucumber.yml <% std_opts = "--format pretty --quiet --strict --tags ~@wip" %> default: <%= std_opts << " --tags ~@javascript" %> features selenium: <%= std_opts %> features wip: --tags @wip:3 --wip features cucumber --profile=wip rake cucumber:wip
  • 20. Questions http://blog.carbonfive.com/2010/10/21/rspec-best-practices/ https://www.relishapp.com/rspec/rspec-core/v/2-6/docs/command-line/ https://github.com/rspec/rspec-expectations http://eggsonbread.com/2010/09/06/my-cucumber-best-practices-and-tips/