Sha256: 1f9b0702ddecc3d5c5c9c87905fd846ec100cc8692e49ff7baff52e62d67acdb

Contents?: true

Size: 979 Bytes

Versions: 1

Compression:

Stored size: 979 Bytes

Contents

require 'minitest/autorun'
require 'minitest/reporters'
require 'rack/test'

require 'coderay'
require 'pygments'
require 'uv'

require File.expand_path('../../lib/rack/highlighter', __FILE__)

include Rack::Test::Methods

MiniTest::Reporters.use! MiniTest::Reporters::SpecReporter.new


def create_app(status, headers, content, highlighter, options)
  app = lambda { |env| [status, headers, [content]] }
  Rack::Highlighter.new(app, highlighter, options)
end

def generate_example(args)
  elements  = args[:elements].clone
  attribute = args[:attribute]
  value     = args[:value]
  content   = args[:content]

  doc = Nokogiri::HTML::DocumentFragment.parse('')
  current = doc

  until elements.empty?
    tmp = Nokogiri::XML::Node.new(elements.shift, doc)
    if elements.empty?
      tmp[attribute] = value
      tmp.content = content
    end

    current << tmp
    current = tmp
  end

  doc.to_html
end

def generate_example_with(klass, content, &block)
  doc.to_html
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-highlighter-0.1.0 spec/spec_helper.rb