Testing in Ruby

Brian Douglas

Links

bit.ly/blocRubyTesting/

Feedback Survey

github/bdougie

Overview

  1. Types of Testing
  2. Setup Rspec
  3. The approach

Expectation

  • You should have a basic understanding of Ruby
  • Please particpate by answering my questions 😺

how confident are you with testing?

Things to consider

  • Tests should be reliable.
  • Tests should be easy to write.
  • Tests should be easy to understand.

Types of testing

Types of testing

What is better for Unit Testing? Minitest or Rspec

click to see answer

Testing Setup


describe "Solution" do
  it "should test for something" do
    Test.assert_equals("actual", "expected", "This is just an example of how you can write your own TDD tests")
  end
end
          

The Problem

Test Custom FizzBuzz

fizz_buzz_custom[15]                         # returns 16
fizz_buzz_custom[44]                         # returns "FizzBuzz" (45 is divisible by 3 and 5)
fizz_buzz_custom('Hey', 'There')[25]         # returns 26
fizz_buzz_custom('Hey', 'There')[11]         # returns "Hey" (12 is divisible by 3)
fizz_buzz_custom("What's ", "up?", 3, 7)[80] # returns "What's " (81 is divisible by 3)
          

Should I TDD?

click to see answer

The End