Sha256: bd246d0023b0bf09c1f605725969d1747aaa34b66a7ea74c558a6c388fd79cb3
Contents?: true
Size: 992 Bytes
Versions: 3
Compression:
Stored size: 992 Bytes
Contents
require 'muack/test' describe 'from README.md' do readme = File.read( "#{File.dirname(File.expand_path(__FILE__))}/../README.md") codes = readme.scan(/``` ruby(.+?)```/m).map(&:first) after{ Muack.reset } Context = Module.new{ include Muack::API def results; @results ||= []; end def p res ; results << res ; end def verify expects return if results.empty? results.zip(expects).each do |(res, exp)| next if exp == 'ok' if exp.start_with?('raise') res.should.kind_of eval(exp.sub('raise', '')) else res.should.eq eval(exp) end end end } codes.each.with_index do |code, index| should 'pass from README.md #%02d' % index do context = Module.new{extend Context} begin context.instance_eval(code, 'README.md', 0) rescue Muack::Failure => e context.p e end context.verify(code.scan(/# (.+)/).map(&:first)) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
muack-1.1.1 | test/test_from_readme.rb |
muack-1.1.0 | test/test_from_readme.rb |
muack-1.0.4 | test/test_from_readme.rb |