RSpec Hello World

by Jason Swett,
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`.

Leave a Reply

Your email address will not be published. Required fields are marked *