Sha256: cf54571f7d0184865fd1f14679c3452fe6089a59939b2ec37b3e065d7c526003
Contents?: true
Size: 1021 Bytes
Versions: 2
Compression:
Stored size: 1021 Bytes
Contents
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib]) require 'redcloth' require 'yaml' def examples_from_yaml(&block) formatter = description.downcase define_method("format_as_#{formatter}", &block) fixtures.each do |name, doc| if doc[formatter] example("should output #{formatter} for #{name}") do output = method("format_as_#{formatter}").call(doc) output.should == doc[formatter] end else example("should not raise errors when rendering #{formatter} for #{name}") do lambda { method("format_as_#{formatter}").call(doc) }.should_not raise_error end end end end def fixtures return @fixtures if @fixtures @fixtures = {} Dir[File.join(File.dirname(__FILE__), *%w[fixtures *.yml])].each do |testfile| testgroup = File.basename(testfile, '.yml') num = 0 YAML::load_stream(File.open(testfile)) do |doc| name = doc['name'] || num @fixtures["#{testgroup} #{name}"] = doc num += 1 end end @fixtures end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
RedCloth-4.3.3 | spec/spec_helper.rb |
gv-RedCloth-4.3.2 | spec/spec_helper.rb |