SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Downloaden Sie, um offline zu lesen
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/

Weitere ähnliche Inhalte

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
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
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
🐬 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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
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 educationjfdjdjcjdnsjd
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - 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
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
[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
 
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
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 

Kürzlich hochgeladen (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
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
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - 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
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.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
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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...
 
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...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 

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/