Category Archives: Ruby

RSpec Hello World

class Squarer
  def square(starting_number)
    starting_number * starting_number
  end
end

describe Squarer do
  it 'square a number' do
    squarer = Squarer.new
    expect(squarer.square(2)).to eq(4)
  end
end

You can run this test by naming the file `squarer_spec.rb` and running `rspec squarer_spec.rb` on the command line.

If you don’t already have RSpec installed you can install it by running `gem install rspec`.