Intro to RSpec Test Driven Development (TDD)

TDD Steps

  • This is usually done with pair programming
  • Write a test
  • Run the test - test will fail
  • Write bare minimum code to pass the test
  • Run the test - pass test
  • Refactor code
  • Run the test - pass test
  • Go to step 1

Rspec

Rspec is a Domain Specific Language (DSL). This means that it is written specifically for use with Ruby, but is not Ruby. Other examples would be cucumber for python, and jasmine for javascript.

General test structure:

A describe at the top of the test is for the class, then another describe is for the method being tested. The it line is the test:

describe Class do
  describe ".new" do
    it "creates a Class object" do
        #Test in here
    end
  end
end

results matching ""

    No results matching ""