Ruby Testing: Cucumber and RSpec

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    2 Favorites

    Ruby Testing: Cucumber and RSpec - Presentation Transcript

    1. RUBY TESTING Cucumber and RSpec
    2. WHO IS THIS GUY? James Thompson @plainprogrammer james@plainprograms.com Web Administrator & Student @ New Orleans Baptist Theological Seminary
    3. WHY DO WE TEST?
    4. WHAT DO WE TEST?
    5. WHAT DON’T WE TEST?
    6. HOW DO WE TEST?
    7. WHAT DO WE TEST WITH?
    8. WHAT IS CUCUMBER •Behavior driven development tool for Ruby •Focuses on higher level implementations such as acceptance tests •Focuses on story-style, plain English test descriptions •Follows the GWT (Given, When, Then) pattern for features
    9. WHAT IS RSPEC •Behavior driven development tool for Ruby •Provides a DSL for talking about what code should do
    10. A POSSIBLE PROCESS •Start with a feature •Define the steps for your feature •Write lower-level specs •Write code to pass specs •Rinse and Repeat until feature passes
    11. WRITE A FEATURE # features/calculator.feature Feature: Addition In Order to avoid silly mistakes As a math idiot I want to be told the sum of two numbers Scenario: Add two numbers Given I have entered 50 into the calculator And I have entered 70 into the calculator When I press add Then the result should be 120 on the screen
    12. WRITE STEPS # features/step_definitions/calculator_steps.rb Given /I have entered (.*) into the calculator/ do |n| calculator = Calculator.new calculator.push(n.to_i) end
    13. WRITE SPECS # spec/calculator.spec describe Calculator do before(:each) do @calculator = Calculator.new end it "should respond to push()" do @calculator.should respond_to(:push) end it "should respond to add()" do @calculator.should respond_to(:add) end end
    14. CODE UNTIL YOU PASS class Calculator def push(n) @args ||= [] @args << n end def add result = 0 @args.each do |n| result += n end result end end
    15. RINSE AND REPEAT
    16. QUESTIONS?
    17. MORE RESOURCES cukes.info rspec.info

    + James ThompsonJames Thompson, 4 months ago

    custom

    689 views, 2 favs, 0 embeds more stats

    Introductory presentation with basic examples for t more

    More info about this document

    CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

    Go to text version

    • Total Views 689
      • 689 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 18
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories