forked from jgarber/redcloth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
101 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,36 @@ | ||
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib]) | ||
require 'redcloth' | ||
require 'yaml' | ||
|
||
class FormatterExampleGroup < Spec::Example::ExampleGroup | ||
|
||
def self.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 examples_from_yaml(&block) | ||
formatter = description.downcase | ||
define_method("format_as_#{formatter}", &block) | ||
|
||
def self.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 | ||
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 | ||
@fixtures | ||
end | ||
|
||
end | ||
|
||
Spec::Example::ExampleGroupFactory.register(:formatter, FormatterExampleGroup) | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
RSpec::Core::RakeTask.new(:rcov) do |t| | ||
t.rcov = true | ||
t.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/} | ||
end | ||
|
||
task :spec => [:ensure_diff_lcs, :compile] | ||
|
||
task :ensure_diff_lcs do | ||
# A little insurance against rake on JRuby not passing the error from load-diff-lcs.rb | ||
begin | ||
require 'diff/lcs' | ||
rescue LoadError | ||
begin | ||
require 'rubygems' unless ENV['NO_RUBYGEMS'] | ||
require 'diff/lcs' | ||
rescue LoadError | ||
raise "You must gem install diff-lcs to run the specs." | ||
end | ||
end | ||
end |