Sha256: 2df7d0b4c0c0668ea80498f427b418b2664a99d77e8b51da97df731148aec346
Contents?: true
Size: 986 Bytes
Versions: 2
Compression:
Stored size: 986 Bytes
Contents
require 'spec_helper' class MarkdownDocument def initialize(str) @str = str end def each_ruby_example example = nil line = nil @str.each_line.with_index(1) do |l, i| if example.nil? if example_beginning?(l) example = '' line = i + 1 end elsif example_end?(l) yield example, line example = nil else example += l end end end protected def example_beginning?(line) line =~ /^```ruby/ end def example_end?(line) line =~ /```/ end end %w(README.md).each do |path| describe path do readme_path = File.expand_path('../../' + path, __FILE__) readme = File.read readme_path doc = MarkdownDocument.new readme doc.each_ruby_example do |code, line| describe "example L#{line}" do it 'executes without failure' do cls = Class.new cls.class_eval(code, readme_path, line) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
calendarium-romanum-remote-0.2.0 | spec/readme_spec.rb |
calendarium-romanum-remote-0.1.0 | spec/readme_spec.rb |