$30 off During Our Annual Pro Sale. View Details »

Neverfails: writes the code to make your tests pass (so you don’t have to)

Neverfails: writes the code to make your tests pass (so you don’t have to)

Presented at the L.A. Ruby meetup, August 2011

Claudio B.

August 11, 2011
Tweet

More Decks by Claudio B.

Other Decks in Programming

Transcript

  1. http://github.com/claudiob
    Neverfails:
    writes the code to
    make your tests pass
    (so you don’t have to)

    View Slide

  2. cukes.info

    View Slide

  3. github.com/claudiob/neverfails/tree/rails

    View Slide

  4. Step 1: Now go and create the model
    Feature: Apples
    Scenario: No apples left
    Given there are no apples
    When I browse the list of apples
    Then I should see the text "No apples left"
    Scenario: No apples left
    Given there are no apples
    No model found called Apple.
    When I browse the list of apples
    Then I should see the text "No apples left"
    + step definitions

    View Slide

  5. Step 2: Create the controller and the route
    rails g model apple
    rake db:migrate
    Scenario: No apples left
    Given there are no apples
    When I browse the list of apples
    No URL pattern found matching /apples.
    Then I should see the text "No apples left"
    + step definitions

    View Slide

  6. Step 3: Adapt the view
    rails g controller Apples index
    sed -i '' '
    /get "apples\/index"/ a\
    match "/apples" => "apples#index"
    ' config/routes.rb
    Scenario: No apples left
    Given there are no apples
    When I browse the list of apples
    Then I should see the text "No apples left"
    The text "No apples left" was not found
    + step definitions

    View Slide

  7. Hooray!
    Scenario: No apples left
    Given there are no apples
    When I browse the list of apples
    Then I should see the text "No apples left"
    + step definitions
    echo "No apples left" >| app/views/apples/
    index.html.erb

    View Slide

  8. curl http://git.io/_qrH0A -Ls | bash
    Feature: Bananas
    Scenario: No bananas left
    Given there are no bananas
    When I browse the list of bananas
    Then I should see the text "No bananas left"
    Neverfails
    Scenario: No bananas left
    Given there are no bananas
    When I browse the list of bananas
    Then I should see the text "No bananas left"

    View Slide

  9. Thanks!
    github.com/claudiob

    View Slide