Permalink
Browse files

Exposing HTML and image supplements in the HTML

  • Loading branch information...
1 parent ba57013 commit bbf78c00027de863119f24ba07c4bdcf2099035c @agross agross committed with aaronjensen Dec 18, 2009
@@ -63,7 +63,7 @@ public class when_a_report_with_unordered_items_is_rendered : ReportSpecs
new Dictionary<string, string>
{
{ "text-some", "some <em>text</em>" },
- { "img-some", @"C:\some\image\file" },
+ { "img-some", @"C:\some\image\image" },
{ "html-some", @"C:\some\html\file" }
})),
Spec("a 2 c 1 c 2 specification 1", Result.Pass())
@@ -4,6 +4,8 @@
using Machine.Specifications.Reporting.Visitors;
using Machine.Specifications.Utility;
+using Rhino.Mocks;
+
namespace Machine.Specifications.Reporting.Specs
{
public class ReportSpecs
@@ -12,10 +14,13 @@ protected static Run Run(params Assembly[] assemblies)
{
var run = new Run(assemblies);
+ var fileSystem = MockRepository.GenerateStub<IFileSystem>();
+
new ISpecificationVisitor[]
{
new FailedSpecificationLinker(),
- new NotImplementedSpecificationLinker()
+ new NotImplementedSpecificationLinker(),
+ new FileBasedResultSupplementPreparation(fileSystem)
}
.Each(x => x.Visit(run));
@@ -36,6 +36,27 @@
<for each="var supplement in spec.Supplements">
<for each="var item in supplement.Value">
+ <if condition='item.Key.StartsWith("img-")'>
+ <var name="Guid.NewGuid()" />
+ <div>
+ [<a id="${name}_link" href="javascript:toggleVisibility('${name}', '${supplement.Key} ${item.Key}');">Show ${supplement.Key} ${item.Key}</a>]
+ </div>
+ <div id="${name}" class="supplement">
+ <a href="resources/${item.Value}">
+ <img width="80%" src="resources/${item.Value}" />
+ </a>
+ </div>
+ </if>
+ <if condition='item.Key.StartsWith("html-")'>
+ <var name="Guid.NewGuid()" />
+ <div>
+ [<a id="${name}_link" href="javascript:toggleVisibility('${name}', '${supplement.Key} ${item.Key}');">Show ${supplement.Key} ${item.Key}</a>]
+ </div>
+ <div id="${name}" class="supplement">
+ <iframe src="resources/${item.Value}" width="100%" height="600px">
+ </iframe>
+ </div>
+ </if>
<if condition='item.Key.StartsWith("text-")'>
<var name="Guid.NewGuid()" />
<div>
@@ -14,7 +14,7 @@ public class FileBasedResultSupplementPreparation : ISpecificationVisitor
const string ImageSupplementPrefix = "img-";
const string TextSupplementPrefix = "text-";
readonly IFileSystem _fileSystem;
- VisitorContext _context;
+ string _resourcePath = String.Empty;
public FileBasedResultSupplementPreparation() : this(new FileSystem())
{
@@ -27,7 +27,7 @@ public FileBasedResultSupplementPreparation(IFileSystem fileSystem)
public void Initialize(VisitorContext context)
{
- _context = context;
+ _resourcePath = context.ResourcePath;
}
public void Visit(Run run)
@@ -89,7 +89,7 @@ public void Visit(Specification specification)
string CopySupplementToResources(string file)
{
- var destinationFileName = Path.Combine(_context.ResourcePath, Path.GetFileName(file));
+ var destinationFileName = Path.Combine(_resourcePath, Path.GetFileName(file));
_fileSystem.Move(file, destinationFileName);
return destinationFileName;
}

0 comments on commit bbf78c0

Please sign in to comment.