@victorhg




Largamos o Cucumber
              http://www.flickr.com/photos/stuartpilbrow/3687751382/
Falando sobre cucumber!




“BDD outside in” em 2011
Bom e velho cucumber

 
 Accessing website with true credentials
  When I am on the login page
   And I fill in "email" with "bla@email.com"
   And I fill in "password" with "qwerty"
   And I click button "Login"
  Then I should see "Olá, bla@email.com"



                 smell gerado pelo web_steps.rb
Text
Não é esse o ponto!!
+1 Camada de abstração
                       Mais código para manter

          Clientes
         Duplicando código em linguagem natural


    esperam LER a
     especificação
Clientes não
     querem escrever testes!
Alcançando Valor com
      Cucumber
Acessing website with true
credentials:
 When I am on the login page
  And I use my credentials
 Then I should see a welcome
 message
Manutenção continuou um
            saco!
     Duplicando
  rspecs & cucumber
        steps
  Refactoring não é
      perfeito
Cada vez menos testes
  de aceitação com
      cucumber

                        source
Mantendo “Valor”
User accessing website
  In order to easy accessing process, As a user
  I can use my facebook account to connect

 When a visitant doesn't have a website account
   Accessing the registration process with facebook
     Should automatically fill in his personal data
     Should not present the password information
rspec + capybara
specs/acceptance/
           facebook_integration.rb
describe "User acessing website", """
  In order to easy accessing process
  As a user
  I can use a facebook account to connect with website""" do
    
   context "When a user doesn't have a go2doc account" do
     context "Acessing registration process with facebook" do
        before do
        end
        it "Should automatically fill in personal data" do
          (CODIGO RSPEC)
        end
        it "Should not present password information" do
          (CODIGO RSPEC)
        end
      end
    end                   https://gist.github.com/2992243
end
Given(:stack) { stack_with(initial_contents) }
  context "when empty" do
    Given(:initial_contents) { [] }
    Then { stack.depth.should == 0 }

    context "when pushing" do
      When { stack.push(:an_item) }

      Then { stack.depth.should == 1 }
      Then { stack.top.should == :an_item }
    end
  end


https://github.com/jimweirich/rspec-given
feature "Articles", %q{
  In order to have an awesome blog
  As an author
  I want to create and manage articles
} do
  background do
    Article.create!(:title => 'One')
  end
  scenario "Article index" do
    visit '/articles'
    page.should have_content('One')
  end

end


https://github.com/cavalle/steak
No final, é
apenas ruby!
Obrigado!
@victorhg
www.Lambda3.com.br

Largamos o Cucumber!

  • 1.
    @victorhg Largamos o Cucumber http://www.flickr.com/photos/stuartpilbrow/3687751382/
  • 2.
    Falando sobre cucumber! “BDDoutside in” em 2011
  • 3.
    Bom e velhocucumber   Accessing website with true credentials When I am on the login page And I fill in "email" with "[email protected]" And I fill in "password" with "qwerty" And I click button "Login" Then I should see "Olá, [email protected]" smell gerado pelo web_steps.rb
  • 4.
  • 5.
    +1 Camada deabstração Mais código para manter Clientes Duplicando código em linguagem natural esperam LER a especificação Clientes não querem escrever testes!
  • 6.
    Alcançando Valor com Cucumber Acessing website with true credentials: When I am on the login page And I use my credentials Then I should see a welcome message
  • 7.
    Manutenção continuou um saco! Duplicando rspecs & cucumber steps Refactoring não é perfeito Cada vez menos testes de aceitação com cucumber source
  • 8.
    Mantendo “Valor” User accessingwebsite In order to easy accessing process, As a user I can use my facebook account to connect When a visitant doesn't have a website account Accessing the registration process with facebook Should automatically fill in his personal data Should not present the password information
  • 9.
  • 10.
    specs/acceptance/ facebook_integration.rb describe "User acessing website", """ In order to easy accessing process As a user I can use a facebook account to connect with website""" do      context "When a user doesn't have a go2doc account" do      context "Acessing registration process with facebook" do         before do         end         it "Should automatically fill in personal data" do           (CODIGO RSPEC)         end         it "Should not present password information" do           (CODIGO RSPEC)         end       end     end https://gist.github.com/2992243 end
  • 11.
    Given(:stack) { stack_with(initial_contents)}   context "when empty" do     Given(:initial_contents) { [] }     Then { stack.depth.should == 0 }     context "when pushing" do       When { stack.push(:an_item) }       Then { stack.depth.should == 1 }       Then { stack.top.should == :an_item }     end   end https://github.com/jimweirich/rspec-given
  • 12.
    feature "Articles", %q{ In order to have an awesome blog As an author I want to create and manage articles } do background do Article.create!(:title => 'One') end scenario "Article index" do visit '/articles' page.should have_content('One') end end https://github.com/cavalle/steak
  • 13.
  • 14.

Editor's Notes