SlideShare une entreprise Scribd logo
1  sur  75
Télécharger pour lire hors ligne
Cucumber
       (             )

       ○×    sonic
     sonic       id:nsgc
http://cukes.info/
Behaviour
      Driven
   Development
with elegance and joy
!
Cucumber

Cucumber

Cucumber
Cucumber

Cucumber

Cucumber
Cucumber

Cucumber

Cucumber
Cucumber               ?
35   Rails   id:moro
Cucumber                      ?
         http://cukes.info/

Cucumber lets software development
teams describe how software should
behave in plain text. The text is written
in a business-readable domain-
specific language and serves as
documentation, automated tests and
development-aid - all rolled into one
format.
Cucumber                     ?
  http://cukes.info/

all rolled into one format


             DSL
(   )BDD   ?
(   )BDD   ?
✓ Cucumber


✓ BDD
✓ BDD

 ✓           =
Cucumber

Cucumber

Cucumber
Cucumber
Cucumber
gem

✓ cucumber
✓ webrat
✓ nokogiri ※
✓ rspec
✓ rspec-rails
Webrat
Ruby Acceptance Testing for Web applications



class SignupTest < ActionController::IntegrationTest

  def test_trial_account_sign_up
    visit home_path
    click_link "Sign up"
    fill_in "Email", :with => "good@example.com"
    select "Free account"
    click_button "Register"
  end

end
Nokogiri
HTML, XML, SAX, XSLT, Read
  require 'nokogiri'
  require 'open-uri'

  # Get a Nokogiri::HTML:Document for the page we’re interested in...
  doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))

  # Do funky things with it using Nokogiri::XML::Node methods...
  ####
  # Search for nodes by css
  doc.css('h3.r a.l').each do |link|
    puts link.content
  end

  ####
  # Search for nodes by xpath
  doc.xpath('//h3/a[@class="l"]').each do |link|
    puts link.content
  end

  ####
  # Or mix and match.
  doc.search('h3.r a.l', '//h3/a[@class="l"]').each do |link|
    puts link.content
  end
Nokogiri
HTML, XML, SAX, XSLT, Read
  require 'nokogiri'
  require 'open-uri'

  # Get a Nokogiri::HTML:Document for the page we’re interested in...
  doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))

  # Do funky things with it using Nokogiri::XML::Node methods...
  ####
  # Search for nodes by css
  doc.css('h3.r a.l').each do |link|
    puts link.content
  end

  ####
  # Search for nodes by xpath
  doc.xpath('//h3/a[@class="l"]').each do |link|
    puts link.content
  end

  ####
  # Or mix and match.
  doc.search('h3.r a.l', '//h3/a[@class="l"]').each do |link|
    puts link.content
  end
Cucumber
$ruby script/generate cucumber
$ruby script/generate cucumber
features/step_definitions/webrat_steps.rb
features/step_definitions/webrat_steps.rb

   step

   features/step_definitions        step

            step   webrat_step.rb

   Given, When, Then



   Webrat                Rspec
Webrat
  webrat_step.rb                             Rdoc


                                 visit(url = nil, http_method
visit path_to(page_name)                                          URL
                                 = :get, data = {})


   click_button(button)          click_button(value = nil)


                                 fill_in(field_locator, options
fill_in(field, :with => value)
                                 = {})



            )
       RDocul.us http://docs.rdocul.us/webrat/master/
       ramaze-users Webrat               http://route477.net/ramaze/?Webrat
✓ features/support/env.rb
  cucumber

✓ features/support/paths.rb
 path_to
Cucumber
$ruby script/generate feature Memo
$ruby script/generate feature Memo
features/manage_memos.feature
features/manage_memos.feature

feature

Feature:

Scenario:


                  Step

Given When Then

           And
features/manage_memos.feature
features/manage_memos.feature
Cucumber
✓
    $rake features
    $cucumber featutes

✓
    $cucumber features/manage_memos.feature
✓ gem     cucumber, webrat

✓ ruby script/generate cucumber
  cucumber

✓ ruby script/generate feature XXX
  XXX

✓ rake features   cucumber
Cucumber

Cucumber

Cucumber
features/manage_memos.feature
features/manage_memos.feature




‘       ’, ‘   ’, ‘       ’, ‘   ’, ‘   ’, ‘   ’
                      (          !        )
✓ step_definition
                    step


✓
?
moro-miso
                  step_definition
       “                                               ”


$gem sources --add http://gems.github.com
$gem install moro-miso


 Cuke          step_definition             miso   (id:moro   )
 http://d.hatena.ne.jp/moro/20090603/1244042258
$ruby script/generate miso
features/step_definitions/webrat_ja_steps.rb
★ -l ja
  $cucumber features/manage_memos.feature -l ja
  $cucumber features -l ja
•



•
NO MONEY
?
?
✓ step_definition              feature


✓            step_definition             moro-
    miso

✓                      step




✓          Rspec    BDD
Cucumber
       (             )

       ○×    sonic
     sonic       id:nsgc
Cucumber
       (             )

       ○×    sonic
     sonic       id:nsgc
•        Cucumber


•
    • Rainbow
    •(              )
                        !
•
• autospec
•
• cucumber.el
• Nokogiri      xpath
!

Contenu connexe

Tendances

Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricksambiescent
 
PHP Web Development
PHP Web DevelopmentPHP Web Development
PHP Web Developmentgaplabs
 
Localforage - fast and simple storage library for JavaScript.
Localforage - fast and simple storage library for JavaScript.Localforage - fast and simple storage library for JavaScript.
Localforage - fast and simple storage library for JavaScript.Sergey Romaneko
 
Perl调用微博API实现自动查询应答
Perl调用微博API实现自动查询应答Perl调用微博API实现自动查询应答
Perl调用微博API实现自动查询应答琛琳 饶
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPJeremy Kendall
 
コードの動的生成のお話
コードの動的生成のお話コードの動的生成のお話
コードの動的生成のお話鉄次 尾形
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPJeremy Kendall
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodJeremy Kendall
 
Country State City Dropdown in PHP
Country State City Dropdown in PHPCountry State City Dropdown in PHP
Country State City Dropdown in PHPVineet Kumar Saini
 
JQuery: JavaScript Library of the Future
JQuery: JavaScript Library of the FutureJQuery: JavaScript Library of the Future
JQuery: JavaScript Library of the FutureMatthew Taylor
 
Extracting ruby gem
Extracting ruby gemExtracting ruby gem
Extracting ruby gemYura Tolstik
 
Add edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPAdd edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPVineet Kumar Saini
 
Designers Guide To jQuery
Designers Guide To jQueryDesigners Guide To jQuery
Designers Guide To jQuerySteve Krueger
 

Tendances (20)

Assetic (Zendcon)
Assetic (Zendcon)Assetic (Zendcon)
Assetic (Zendcon)
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricks
 
Perl5i
Perl5iPerl5i
Perl5i
 
PHP Web Development
PHP Web DevelopmentPHP Web Development
PHP Web Development
 
Rails by example
Rails by exampleRails by example
Rails by example
 
Localforage - fast and simple storage library for JavaScript.
Localforage - fast and simple storage library for JavaScript.Localforage - fast and simple storage library for JavaScript.
Localforage - fast and simple storage library for JavaScript.
 
Perl调用微博API实现自动查询应答
Perl调用微博API实现自动查询应答Perl调用微博API实现自动查询应答
Perl调用微博API实现自动查询应答
 
Assetic (OSCON)
Assetic (OSCON)Assetic (OSCON)
Assetic (OSCON)
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 
コードの動的生成のお話
コードの動的生成のお話コードの動的生成のお話
コードの動的生成のお話
 
Drupal.Behaviors
Drupal.BehaviorsDrupal.Behaviors
Drupal.Behaviors
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the Good
 
Pagination in PHP
Pagination in PHPPagination in PHP
Pagination in PHP
 
Country State City Dropdown in PHP
Country State City Dropdown in PHPCountry State City Dropdown in PHP
Country State City Dropdown in PHP
 
JQuery: JavaScript Library of the Future
JQuery: JavaScript Library of the FutureJQuery: JavaScript Library of the Future
JQuery: JavaScript Library of the Future
 
Variations on a Theme
Variations on a ThemeVariations on a Theme
Variations on a Theme
 
Extracting ruby gem
Extracting ruby gemExtracting ruby gem
Extracting ruby gem
 
Add edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPAdd edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHP
 
Designers Guide To jQuery
Designers Guide To jQueryDesigners Guide To jQuery
Designers Guide To jQuery
 

En vedette

Background Audio Playback
Background Audio PlaybackBackground Audio Playback
Background Audio PlaybackKorhan Bircan
 
ぼくにもできたよ! Rubyを使ったデブラブハック
ぼくにもできたよ! Rubyを使ったデブラブハックぼくにもできたよ! Rubyを使ったデブラブハック
ぼくにもできたよ! Rubyを使ったデブラブハックNaoki Nishiguchi
 
Desigining for evolvability
Desigining for evolvabilityDesigining for evolvability
Desigining for evolvabilityAslak Hellesøy
 
Test Driven Development - Workshop
Test Driven Development - WorkshopTest Driven Development - Workshop
Test Driven Development - WorkshopAnjana Somathilake
 

En vedette (6)

Background Audio Playback
Background Audio PlaybackBackground Audio Playback
Background Audio Playback
 
TDD talk
TDD talkTDD talk
TDD talk
 
ぼくにもできたよ! Rubyを使ったデブラブハック
ぼくにもできたよ! Rubyを使ったデブラブハックぼくにもできたよ! Rubyを使ったデブラブハック
ぼくにもできたよ! Rubyを使ったデブラブハック
 
Desigining for evolvability
Desigining for evolvabilityDesigining for evolvability
Desigining for evolvability
 
Cuke4Duke JavaZone 2009
Cuke4Duke JavaZone 2009Cuke4Duke JavaZone 2009
Cuke4Duke JavaZone 2009
 
Test Driven Development - Workshop
Test Driven Development - WorkshopTest Driven Development - Workshop
Test Driven Development - Workshop
 

Similaire à How to eat Cucmber

Padrino - the Godfather of Sinatra
Padrino - the Godfather of SinatraPadrino - the Godfather of Sinatra
Padrino - the Godfather of SinatraStoyan Zhekov
 
FP - Découverte de Play Framework Scala
FP - Découverte de Play Framework ScalaFP - Découverte de Play Framework Scala
FP - Découverte de Play Framework ScalaKévin Margueritte
 
Monitoring web application behaviour with cucumber-nagios
Monitoring web application behaviour with cucumber-nagiosMonitoring web application behaviour with cucumber-nagios
Monitoring web application behaviour with cucumber-nagiosLindsay Holmwood
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Librariesjeresig
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Railsdosire
 
Framework Presentation
Framework PresentationFramework Presentation
Framework Presentationrmalik2
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsMark Rackley
 
Efficient JavaScript Development
Efficient JavaScript DevelopmentEfficient JavaScript Development
Efficient JavaScript Developmentwolframkriesing
 
The Dojo Build System
The Dojo Build SystemThe Dojo Build System
The Dojo Build Systemklipstein
 
Intro To Django
Intro To DjangoIntro To Django
Intro To DjangoUdi Bauman
 
PHP Development With MongoDB
PHP Development With MongoDBPHP Development With MongoDB
PHP Development With MongoDBFitz Agard
 
PHP Development with MongoDB (Fitz Agard)
PHP Development with MongoDB (Fitz Agard)PHP Development with MongoDB (Fitz Agard)
PHP Development with MongoDB (Fitz Agard)MongoSF
 
BDD / cucumber /Capybara
BDD / cucumber /CapybaraBDD / cucumber /Capybara
BDD / cucumber /CapybaraShraddhaSF
 
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...BradNeuberg
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)Doris Chen
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with CucumberBen Mabey
 

Similaire à How to eat Cucmber (20)

Padrino - the Godfather of Sinatra
Padrino - the Godfather of SinatraPadrino - the Godfather of Sinatra
Padrino - the Godfather of Sinatra
 
Road to Rails
Road to RailsRoad to Rails
Road to Rails
 
FP - Découverte de Play Framework Scala
FP - Découverte de Play Framework ScalaFP - Découverte de Play Framework Scala
FP - Découverte de Play Framework Scala
 
Sprockets
SprocketsSprockets
Sprockets
 
Monitoring web application behaviour with cucumber-nagios
Monitoring web application behaviour with cucumber-nagiosMonitoring web application behaviour with cucumber-nagios
Monitoring web application behaviour with cucumber-nagios
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Libraries
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Rails
 
Framework Presentation
Framework PresentationFramework Presentation
Framework Presentation
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentials
 
Efficient JavaScript Development
Efficient JavaScript DevelopmentEfficient JavaScript Development
Efficient JavaScript Development
 
The Dojo Build System
The Dojo Build SystemThe Dojo Build System
The Dojo Build System
 
Intro To Django
Intro To DjangoIntro To Django
Intro To Django
 
PHP Development With MongoDB
PHP Development With MongoDBPHP Development With MongoDB
PHP Development With MongoDB
 
PHP Development with MongoDB (Fitz Agard)
PHP Development with MongoDB (Fitz Agard)PHP Development with MongoDB (Fitz Agard)
PHP Development with MongoDB (Fitz Agard)
 
Jquery fundamentals
Jquery fundamentalsJquery fundamentals
Jquery fundamentals
 
BDD / cucumber /Capybara
BDD / cucumber /CapybaraBDD / cucumber /Capybara
BDD / cucumber /Capybara
 
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
 
Ruby Kaigi 2008 LT
Ruby Kaigi 2008 LTRuby Kaigi 2008 LT
Ruby Kaigi 2008 LT
 

How to eat Cucmber