Sunfox


Journal

Archives de juin 2026

Test your README

1 juin 2026 , , ,

In my tin_valid gem, this simple automated Ruby test never stops to make me smile:

RSpec.describe "README" do
  readme = File.read(File.join(__dir__, "../README.md"))
  code_blocks = readme.scan(/```rb\n(.*?)\n```/m).flatten
  code_blocks.each do |code|
    it "returns true for code #{code.inspect}" do
      expect(eval(code)).to be(true)
    end
  end
end

Now I can be sure that the Ruby code examples in the README will stay up to date and valid. Simple as that.

👨🏻‍🦰 Sunny Ripert

est un développeur web vivant à ParisContactArchives

Textes et contenus sous licence Creative Commons.