Archives de juin 2026
1 juin 2026 — code, gem, opensource, ruby
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.
est un développeur web vivant à Paris — Contact — Archives
Textes et contenus sous licence Creative Commons.