Sunfox


Test your README

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.

Ajouter un commentaire

Vous pouvez y saupoudrer de l’HTML avec les balises et suivantes : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>. Vous pouvez avoir un avatar en créant un gravatar.

👨🏻‍🦰 Sunny Ripert

est un développeur web vivant à ParisContactArchives

Textes et contenus sous licence Creative Commons.