Ruby Testing: Cucumber and RSpec
Upcoming SlideShare
Loading in...5
×
 

Ruby Testing: Cucumber and RSpec

on

  • 10,178 views

Introductory presentation with basic examples for the use of Cucumber and Rspec to do testing in Ruby.

Introductory presentation with basic examples for the use of Cucumber and Rspec to do testing in Ruby.

http://github.com/jwthompson2/barcamp-nola-2009/

Statistics

Views

Total Views
10,178
Views on SlideShare
10,134
Embed Views
44

Actions

Likes
6
Downloads
124
Comments
0

2 Embeds 44

http://www.slideshare.net 43
http://www.linkedin.com 1

Accessibility

Upload Details

Uploaded via as Apple Keynote

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Ruby Testing: Cucumber and RSpec Ruby Testing: Cucumber and RSpec Presentation Transcript

  • RUBY TESTING Cucumber and RSpec
  • WHO IS THIS GUY? James Thompson @plainprogrammer james@plainprograms.com Web Administrator & Student @ New Orleans Baptist Theological Seminary
  • WHY DO WE TEST?
  • WHAT DO WE TEST?
  • WHAT DON’T WE TEST?
  • HOW DO WE TEST?
  • WHAT DO WE TEST WITH?
  • 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
  • WHAT IS RSPEC •Behavior driven development tool for Ruby •Provides a DSL for talking about what code should do
  • 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
  • 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
  • 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
  • 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
  • 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
  • RINSE AND REPEAT
  • QUESTIONS?
  • MORE RESOURCES cukes.info rspec.info