Skip to content

Instantly share code, notes, and snippets.

@jordelver
Last active December 12, 2015 09:58
Show Gist options
  • Save jordelver/4755252 to your computer and use it in GitHub Desktop.
Save jordelver/4755252 to your computer and use it in GitHub Desktop.
Tests and code under test in the same file

Tests and code under test in the same file

The test will only run when run interactively (i.e. ruby ).

class Word
  def length
    10
  end
end

if __FILE__ == $0
  require 'minitest/spec'
  require 'minitest/autorun'

  describe Word do
    it "should be a certain size" do
      word = Word.new
      word.length.must_equal 10
    end
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment