Sha256: 98f87f09d139d4b8e2779b41f7be70a5d4da6a07991c1256890f3fc10d4e20f5

Contents?: true

Size: 1023 Bytes

Versions: 50

Compression:

Stored size: 1023 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_documents(File.open(testfile)) do |doc|
      name = doc['name'] || num
      @fixtures["#{testgroup} #{name}"] = doc
      num += 1
    end
  end
  @fixtures
end

Version data entries

50 entries across 50 versions & 7 rubygems

Version Path
RedCloth-4.3.2 spec/spec_helper.rb
RedCloth-4.3.1 spec/spec_helper.rb
RedCloth-4.3.0 spec/spec_helper.rb
parity-RedCloth-4.2.13 spec/spec_helper.rb
parity-RedCloth-4.2.12 spec/spec_helper.rb
parity-RedCloth-4.2.11 spec/spec_helper.rb
parity-RedCloth-4.2.10 spec/spec_helper.rb
parity-RedCloth-4.2.9 spec/spec_helper.rb
YSRedCloth-4.2.18 spec/spec_helper.rb
assplecake-RedCloth-4.2.10 spec/spec_helper.rb
YSRedCloth-4.2.17 spec/spec_helper.rb
YSRedCloth-4.2.16 spec/spec_helper.rb
gv-RedCloth-4.2.9 spec/spec_helper.rb
YSRedCloth-4.2.15 spec/spec_helper.rb
YSRedCloth-4.2.14 spec/spec_helper.rb
YSRedCloth-4.2.13 spec/spec_helper.rb
YSRedCloth-4.2.12 spec/spec_helper.rb
YSRedCloth-4.2.11 spec/spec_helper.rb
YSRedCloth-4.2.10 spec/spec_helper.rb
YSRedCloth-4.2.9 spec/spec_helper.rb